|host => STRING|
|hosts => ARRAY of STRING||The hostnames of Cassandra node to connect to initially. If more than one host is provided in an array, they will be attempted sequentially until one succeeds during the intial connect phase.|
|service => STRING||Optional. The service name or port number to connect to.|
|username => STRING|
|password => STRING||Optional. Authentication details to use for PasswordAuthenticator.|
|keyspace => STRING||Optional. If set, a USE keyspace query will be issued as part of the connect method.|
|default_consistency => INT||Optional. Default consistency level to use if none is provided to query or execute.|
|primaries => INT||Optional. The number of primary node connections to maintain. Defaults to 1 if not specified.|
|prefer_dc => STRING||Optional. If set, prefer to pick primary nodes from the given data center, only falling back on others if there are not enough available.|
|cql_version => INT||Optional. Version of the CQL wire protocol to negotiate during connection. Defaults to 1.|
CW$str = CW$cass->quote( CW$str )Quotes a string argument suitable for inclusion in an immediate CQL query string.
In general, it is better to use a prepared query and pass the value as an execute parameter though.
CW$str = CW$cass->quote_identifier( CW$str )Quotes an identifier name suitable for inclusion in a CQL query string.
CW$cass->connect( CW%args ) ==> ()Connects to the Cassandra node and starts up the connection. The returned Future will yield nothing on success.
Takes the following named arguments:
A set of host names are required, either as a named argument or as a configured value on the object. If the service name is missing, the default CQL port will be used instead.
host => STRING hosts => ARRAY of STRING service => STRING
CW$cass->close_when_idle ==> CW$cassStops accepting new queries and prepares all the existing connections to be closed once every outstanding query has been responded to. Returns a future that will eventually yield the CassandraCQL object, when all the connections are closed.
After calling this method it will be an error to invoke query, prepare, execute or the various other methods derived from them.
CW$cass->close_nowImmediately closes all node connections and shuts down the object. Any outstanding or queued queries will immediately fail. Consider this as a last resort failure shutdown, as compared to the graceful draining behaviour of close_when_idle.
CW$cass->query( CW$cql, CW$consistency, CW%other_args ) ==> ( CW$type, CW$result )Performs a CQL query. On success, the values returned from the Future will depend on the type of query.
For USE queries, the type is keyspace and $result is a string giving the name of the new keyspace.
For CREATE, ALTER and DROP queries, the type is schema_change and $result is a 3-element ARRAY reference containing the type of change, the keyspace and the table name.
For SELECT queries, the type is rows and $result is an instance of Protocol::CassandraCQL::Result containing the returned row data.
For other queries, such as INSERT, UPDATE and DELETE, the future returns nothing.
%other_args may be any of the following, when using cql_version 2 or above:
skip_metadata => BOOL Requests the server does not include result metadata in the response. It will be up to the caller to provide this, via set_metadata on the returned Result object, before it can be used. page_size => INT Requests that the server returns at most the given number of rows. If any further remain, the result object will include the paging_state field. This can be passed in another query call to obtain the next set of data. paging_state => INT Requests that the server continues a paged request from this position, given in a previous response. serial_consistency => INT Sets the consistency level for serial operations in the query. Must be one of CONSISTENCY_SERIAL or CONSISTENCY_LOCAL_SERIAL.
CW$cass->query_rows( CW$cql, CW$consistency, CW%other_args ) ==> CW$resultA shortcut wrapper for query which expects a rows result and returns it directly. Any other result is treated as an error. The returned Future returns a Protocol::CassandraCQL::Result directly
CW$cass->prepare( CW$cql ) ==> CW$queryPrepares a CQL query for later execution. On success, the returned Future yields an instance of a prepared query object (see below).
Query objects stored internally cached by the CQL string; subsequent calls to prepare with the same exact CQL string will yield the same object immediately, saving a roundtrip.
CW$cass->execute( CW$query, CW$data, CW$consistency, CW%other_args ) ==> ( CW$type, CW$result )Executes a previously-prepared statement, given the binding data. On success, the returned Future will yield results of the same form as the query method. $data should contain a list of encoded byte-string values.
Normally this method is not directly required - instead, use the execute method on the query object itself, as this will encode the parameters correctly.
%other_args may be as for the query method.
The following wrapper methods all wrap the basic query operation.
CW$cass->schema_keyspaces ==> CW$resultA shortcut to a SELECT query on system.schema_keyspaces, which returns a result object listing all the keyspaces.
Exact details of the returned columns will depend on the Cassandra version, but the result should at least be keyed by the first column, called keyspace_name.
my $keyspaces = $result->rowmap_hash( "keyspace_name" )
CW$cass->schema_columnfamilies( CW$keyspace ) ==> CW$resultA shortcut to a SELECT query on system.schema_columnfamilies, which returns a result object listing all the columnfamilies of the given keyspace.
Exact details of the returned columns will depend on the Cassandra version, but the result should at least be keyed by the first column, called columnfamily_name.
my $columnfamilies = $result->rowmap_hash( "columnfamily_name" )
CW$cass->schema_columns( CW$keyspace, CW$columnfamily ) ==> CW$resultA shortcut to a SELECT query on system.schema_columns, which returns a result object listing all the columns of the given columnfamily.
Exact details of the returned columns will depend on the Cassandra version, but the result should at least be keyed by the first column, called column_name.
my $columns = $result->rowmap_hash( "column_name" )
o Allow other load-balancing strategies than roundrobin. o Adjust connected primary nodes when changing primaries parameter. o Allow backup nodes, for faster connection failover. o Support LZ4 compression when using CQL version 2.
This is blocked on RT #92825
This code was paid for by
o Perceptyx <http://www.perceptyx.com/> o Shadowcat Systems <http://www.shadow.cat>
Paul Evans <email@example.com>
|perl v5.20.3||NET::ASYNC::CASSANDRACQL (3)||2016-04-03|