The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Protocol::CassandraCQL::ColumnMeta - stores the column metadata of a Cassandra CQL query

DESCRIPTION

Objects in this class interpret the column metadata from a message frame containing a OPCODE_RESULT response to a query giving RESULT_ROWS or 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.

CONSTRUCTOR

$meta = Protocol::CassandraCQL::ColumnMeta->from_frame( $frame )

Returns a new result object initialised from the given message frame.

METHODS

$n = $meta->columns

Returns the number of columns

$name = $meta->column_name( $idx )

( $keyspace, $table, $column ) = $meta->column_name( $idx )

Returns the name of the column at the given (0-based) index; either as three separate strings, or all joined by ".".

$name = $meta->column_shortname( $idx )

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.

$type = $meta->column_type( $idx )

Returns the type of the column at the given index as an instance of Protocol::CassandraCQL::Type.

$idx = $meta->find_column( $name )

Returns the index of the given named column. The name may be given as keyspace.table.column, or table.column or column if they are unique within the set. Returns undef if no such column exists.

@bytes = $meta->encode_data( @data )

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.

@data = $meta->decode_data( @bytes )

Returns a list of decoded data from the given encoded bytestrings according to the type of each column.

SPONSORS

This code was paid for by

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>