18 Dec 2014 15:36:05 UTC
- Distribution: Protocol-CassandraCQL
- Module version: 0.12
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (2)
- Testers (725 / 41 / 10)
- KwaliteeBus factor: 1
- 86.97% Coverage
- License: perl_5
- Activity24 month
- Download (40.46KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest versionPEVANS Paul Evans
- $n = $meta->columns
- $name = $meta->column_name( $idx )
- ( $keyspace, $table, $column ) = $meta->column_name( $idx )
- $name = $meta->column_shortname( $idx )
- $type = $meta->column_type( $idx )
- $idx = $meta->find_column( $name )
- @bytes = $meta->encode_data( @data )
- @data = $meta->decode_data( @bytes )
- $bytes = $meta->paging_state
- $bool = $meta->has_metadata
Protocol::CassandraCQL::ColumnMeta- stores the column metadata of a Cassandra CQL query
Objects in this class interpret the column metadata from a message frame containing a
OPCODE_RESULTresponse to a query giving
RESULT_PREPARED. It provides lookup of column names and type information, and provides a convenient accessor to the encoding and decoding support functions, allowing encoding of bytestrings from perl data when executing a prepared statement, and decoding of bytestrings to perl data when obtaining query results.
It is also subclassed as Protocol::CassandraCQL::Result.
Returns a new column metadata object initialised from the given message frame at the given CQL version number. (Version will default to 1 if not supplied, but this may become a required parameter in a future version).
Returns a new column metadata object initialised directly from the given column data. This constructor is intended for use by unit test scripts, to create metadata directly from mocked connection objects or similar.
It takes the following named arguments:
- columns => ARRAY[ARRAY[STR, STR, STR, STR]]
An ARRAY reference containing the data about individual columns. Each row is represented by an ARRAY reference containing four strings; giving the three components of its name, and the name of its type:
[ $keyspace, $table, $column, $typename ]
Returns the number of columns
Returns the name of the column at the given (0-based) index; either as three separate strings, or all joined by ".".
Returns the short name of the column; which will be just the column name unless it requires the table or keyspace name as well to make it unique within the set.
Returns the type of the column at the given index as an instance of Protocol::CassandraCQL::Type.
Returns the index of the given named column. The name may be given as
columnif they are unique within the set. Returns
undefif no such column exists.
Returns a list of encoded bytestrings from the given data according to the type of each column. Checks each value is valid; if not throws an exception explaining which column failed and why.
An exception is thrown if the wrong number of values is passed.
Returns a list of decoded data from the given encoded bytestrings according to the type of each column.
Returns the CQLv2+ paging state, if it was contained in the given frame. This would be returned in an
OPCODE_RESULTmessage to a query or execute request that requested paging.
Returns a boolean indicating whether the column metadata (field names and types) is actually defined. Normally this would be true, except if the object is an instance of Protocol::CassandraCQL::Result returned by executing a prepared statement with metadata specifically disabled.
This code was paid for by
Paul Evans <email@example.com>
Module Install Instructions
To install Protocol::CassandraCQL, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Protocol::CassandraCQL
For more information on module installation, please visit the detailed CPAN module installation guide.