Module cqerl

Main interface to CQErl cassandra client.

Behaviours: gen_server.

Authors: Mathieu D'Amours (matt@forest.io).

Description

Main interface to CQErl cassandra client.

Data Types

client()

abstract datatype: client()

inet()

inet() = {inet:ip_address() | string(), Port::integer()} | inet:ip_address() | string() | binary() | {}

Function Index

all_rows/1Returns a list of rows as property lists.
all_rows/2
code_change/3
fetch_more/1Fetch the next page of result from Cassandra for a given continuation.
fetch_more_async/1Asynchronously fetch the next page of result from cassandra for a given continuation.
get_client/0
get_client/1
get_client/2
get_global_opts/0
get_protocol_version/0
handle_call/3
handle_cast/2
handle_info/2
has_more_pages/1Check to see if there are more result available.
head/1Returns the first row of result, as a property list.
head/2
init/1
make_option_getter/2
next/1Returns a tuple of {HeadRow, ResultTail}.
prepare_node_info/1
put_protocol_version/1
run_query/2Send a query to cassandra for execution.
send_query/2Send a query to be executed asynchronously.
size/1The number of rows in a result set.
start_link/0
tail/1Returns all rows of result, except the first one.
terminate/2

Function Details

all_rows/1

all_rows(Cql_result) -> any()

Returns a list of rows as property lists

all_rows/2

all_rows(Cql_result, Opts) -> any()

code_change/3

code_change(OldVsn, State, Extra) -> any()

fetch_more/1

fetch_more(Continuation::#cql_result{}) -> no_more_result | {ok, #cql_result{}}

Fetch the next page of result from Cassandra for a given continuation. The function will return with the result from Cassandra (synchronously).

fetch_more_async/1

fetch_more_async(Continuation::#cql_result{}) -> reference() | no_more_result

Asynchronously fetch the next page of result from cassandra for a given continuation.

A success or error message will be sent in response some time later (see send_query/2 for details) unless the connection is dropped.

get_client/0

get_client() -> {ok, client()} | {error, term()}

get_client/1

get_client(ClusterKeyOrInet::atom() | inet()) -> {ok, client()} | {error, term()}

get_client/2

get_client(Inet::inet(), Opts::[tuple() | atom()]) -> {ok, client()} | {error, term()}

get_global_opts/0

get_global_opts() -> any()

get_protocol_version/0

get_protocol_version() -> integer()

handle_call/3

handle_call(Msg, From, State) -> any()

handle_cast/2

handle_cast(Msg, State) -> any()

handle_info/2

handle_info(Msg, State) -> any()

has_more_pages/1

has_more_pages(Continuation::#cql_result{}) -> true | false

Check to see if there are more result available

head/1

head(Cql_result) -> any()

Returns the first row of result, as a property list

head/2

head(Cql_result, Opts) -> any()

init/1

init(X1) -> any()

make_option_getter/2

make_option_getter(Local, Global) -> any()

next/1

next(Cql_result) -> any()

Returns a tuple of {HeadRow, ResultTail}.

This can be used to iterate over a result set efficiently. Successively call this function over the result set to go through all rows, until it returns the empty_dataset atom.

prepare_node_info/1

prepare_node_info(NodeInfo::any()) -> Node::inet()

put_protocol_version/1

put_protocol_version(Val::integer()) -> ok

run_query/2

run_query(ClientRef::client(), Query::binary() | string() | #cql_query{} | #cql_query_batch{}) -> {ok, void} | {ok, #cql_result{}} | {error, term()}

Send a query to cassandra for execution. The function will return with the result from Cassandra (synchronously).

The Query parameter can be a string, a binary UTF8 string or a #cql_query{} record

#cql_query{
      statement :: binary(),
      reusable :: boolean(),
      consistency :: consistency_level(),
      named :: boolean(),
      bindings :: list(number() | boolean() | binary() | list() | inet() | ) | list(tuple())
  }

Reusable is a boolean indicating whether the query should be reused. Reusing a query means sending it to Cassandra to be prepared, which allows later executions of the same query to be performed faster. This parameter is true by default when you provide bindings in the query (positional ? parameters or named :var parameters), and false by default when you don't. You can override the defaults.

Consistency is represented as an atom and can be any of any, one, two, three, quorum, all, local_quorum, each_quorum, serial, local_serial or local_one.

How values is used depends on the named value. Named is a boolean value indicating whether the parameters in the query are named parameters (:var1). Otherwise, they are assumed to be positional (?). In both cases, values is a property list (see proplists) or map, where keys match the parameter names.

send_query/2

send_query(ClientRef::client(), Query::binary() | string() | #cql_query{} | #cql_query_batch{}) -> reference()

Send a query to be executed asynchronously. This method returns immediately with a unique tag.

When a successful response is received from cassandra, a {result, Tag, Result :: #cql_result{}} message is sent to the calling process.

If there is an error with the query, a {error, Tag, Error :: #cql_error{}} will be sent to the calling process.

Neither of these messages will be sent if the connection is dropped before receiving a response (see new_client/0 for how to handle this case).

size/1

size(Cql_result) -> any()

The number of rows in a result set

start_link/0

start_link() -> any()

tail/1

tail(Cql_result) -> any()

Returns all rows of result, except the first one

terminate/2

terminate(Reason, State) -> any()


Generated by EDoc