Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make it work with version 0.4.2 of Cassandra

  • Loading branch information...
commit fb67ee6b4ea4cb1dc4cc15ab08b5cbeb50dc0fa6 1 parent e189d78
@acme authored
View
1  MANIFEST
@@ -11,6 +11,7 @@ lib/Net/Cassandra/Backend/Thrift/FramedTransport.pm
lib/Net/Cassandra/Backend/Thrift/HttpClient.pm
lib/Net/Cassandra/Backend/Thrift/MemoryBuffer.pm
lib/Net/Cassandra/Backend/Thrift/Protocol.pm
+lib/Net/Cassandra/Backend/Thrift/Server.pm
lib/Net/Cassandra/Backend/Thrift/Socket.pm
lib/Net/Cassandra/Backend/Thrift/Transport.pm
lib/Net/Cassandra/Backend/Types.pm
View
43 README
@@ -2,32 +2,57 @@ NAME
Net::Cassandra - Interface to Cassandra
SYNOPSIS
- my $cassandra = Net::Cassandra->new;
+ my $cassandra = Net::Cassandra->new( hostname => 'localhost' );
my $client = $cassandra->client;
my $key = '123';
my $timestamp = time;
eval {
- $client->insert( 'Table1', $key, 'Standard1:name', 'Leon Brocard',
- $timestamp, 0 );
+ $client->insert(
+ 'Keyspace1',
+ $key,
+ Net::Cassandra::Backend::ColumnPath->new(
+ { column_family => 'Standard1', column => 'name' }
+ ),
+ 'Leon Brocard',
+ $timestamp,
+ Net::Cassandra::Backend::ConsistencyLevel::ZERO
+ );
};
die $@->why if $@;
eval {
- $client->remove( 'Table1', $key, 'Standard1:age', $timestamp );
+ my $what = $client->get(
+ 'Keyspace1',
+ $key,
+ Net::Cassandra::Backend::ColumnPath->new(
+ { column_family => 'Standard1', column => 'name' }
+ ),
+ Net::Cassandra::Backend::ConsistencyLevel::QUORUM
+ );
+ my $value = $what->column->value;
+ my $timestamp = $what->column->timestamp;
+ warn "$value / $timestamp";
};
die $@->why if $@;
- my $column;
- eval { $column = $client->get_column( 'Table1', $key, 'Standard1:name' ); };
+ eval {
+ $client->remove(
+ 'Keyspace1',
+ $key,
+ Net::Cassandra::Backend::ColumnPath->new(
+ { column_family => 'Standard1', column => 'name' }
+ ),
+ $timestamp
+ );
+ };
die $@->why if $@;
- say $column->{columnName}, ', ', $column->{value}, ', ', $column->{timestamp};
DESCRIPTION
This module provides an interface the to Cassandra distributed database.
- It uses the Thrift interface. This is changing rapidly and supports the
- development version of Cassandra built from Subversion trunk.
+ It uses the Thrift interface. This is changing rapidly and supports
+ version 0.4.2 of Cassandra.
AUTHOR
Leon Brocard <acme@astray.com>.
View
195 examples/simple.pl
@@ -5,33 +5,202 @@
use Net::Cassandra;
use Perl6::Say;
-my $cassandra = Net::Cassandra->new;
-my $client = $cassandra->client;
+my $cassandra = Net::Cassandra->new( hostname => 'localhost' );
+my $client = $cassandra->client;
my $key = '123';
my $timestamp = time;
+# void insert(1:required string keyspace,
+# 2:required string key,
+# 3:required ColumnPath column_path,
+# 4:required binary value,
+# 5:required i64 timestamp,
+# 6:required ConsistencyLevel consistency_level=0)
+# throws (1: InvalidRequestException ire, 2: UnavailableException ue),
eval {
- $client->insert( 'Table1', $key, 'Standard1:name', 'Leon Brocard',
- $timestamp, 0 );
+ $client->insert(
+ 'Keyspace1',
+ $key,
+ Net::Cassandra::Backend::ColumnPath->new(
+ { column_family => 'Standard1', column => 'name' }
+ ),
+ 'Leon Brocard',
+ $timestamp,
+ Net::Cassandra::Backend::ConsistencyLevel::ZERO
+ );
};
die $@->why if $@;
+# void batch_insert(1:required string keyspace,
+# 2:required string key,
+# 3:required map<string, list<ColumnOrSuperColumn>> cfmap,
+# 4:required ConsistencyLevel consistency_level=0)
+# throws (1: InvalidRequestException ire, 2: UnavailableException ue),
eval {
+ $client->batch_insert(
+ 'Keyspace1',
+ $key,
+ { 'Standard1' => [
+ Net::Cassandra::Backend::ColumnOrSuperColumn->new(
+ { column => Net::Cassandra::Backend::Column->new(
+ { name => 'name',
+ value => 'Leon Brocard',
+ timestamp => $timestamp,
+ }
+ )
+ }
+ )
+ ],
+ },
+ Net::Cassandra::Backend::ConsistencyLevel::ZERO
+ );
+};
+die $@->why if $@;
- $client->remove( 'Table1', $key, 'Standard1:age', $timestamp );
+# ColumnOrSuperColumn get(1:required string keyspace,
+# 2:required string key,
+# 3:required ColumnPath column_path,
+# 4:required ConsistencyLevel consistency_level=1)
+# throws (1: InvalidRequestException ire, 2: NotFoundException nfe, 3: UnavailableException ue),
+eval {
+ my $what = $client->get(
+ 'Keyspace1',
+ $key,
+ Net::Cassandra::Backend::ColumnPath->new(
+ { column_family => 'Standard1', column => 'name' }
+ ),
+ Net::Cassandra::Backend::ConsistencyLevel::QUORUM
+ );
+ my $value = $what->column->value;
+ my $timestamp = $what->column->timestamp;
+ warn "$value / $timestamp";
};
die $@->why if $@;
-my $column;
-eval { $column = $client->get_column( 'Table1', $key, 'Standard1:name' ); };
+# list<ColumnOrSuperColumn> get_slice(1:required string keyspace,
+# 2:required string key,
+# 3:required ColumnParent column_parent,
+# 4:required SlicePredicate predicate,
+# 5:required ConsistencyLevel consistency_level=1)
+# throws (1: InvalidRequestException ire, 3: UnavailableException ue),
+eval {
+ my $what = $client->get_slice(
+ 'Keyspace1',
+ $key,
+ Net::Cassandra::Backend::ColumnParent->new(
+ { column_family => 'Standard1' }
+ ),
+ Net::Cassandra::Backend::SlicePredicate->new(
+ { column_names => ['name'],
+ slice_range => Net::Cassandra::Backend::SliceRange->new(
+ { start => '', finish => '', count => 100 }
+ )
+ }
+ ),
+ Net::Cassandra::Backend::ConsistencyLevel::QUORUM
+ );
+ my $value = $what->[0]->column->value;
+ my $timestamp = $what->[0]->column->timestamp;
+ warn "$value / $timestamp";
+};
die $@->why if $@;
-say $column->{columnName}, ', ', $column->{value}, ', ', $column->{timestamp};
-my $slice;
-eval { $slice = $client->get_slice( 'Table1', $key, 'Standard1', -1, -1 ); };
+# map<string,ColumnOrSuperColumn> multiget(1:required string keyspace,
+# 2:required list<string> keys,
+# 3:required ColumnPath column_path,
+# 4:required ConsistencyLevel consistency_level=1)
+# throws (1: InvalidRequestException ire, 2: UnavailableException ue),
+eval {
+ my $what = $client->multiget(
+ 'Keyspace1',
+ [$key],
+ Net::Cassandra::Backend::ColumnPath->new(
+ { column_family => 'Standard1', column => 'name' }
+ ),
+ Net::Cassandra::Backend::ConsistencyLevel::QUORUM
+ );
+ my $value = $what->{$key}->column->value;
+ my $timestamp = $what->{$key}->column->timestamp;
+ warn "$value / $timestamp";
+};
+die $@->why if $@;
+
+# map<string,list<ColumnOrSuperColumn>> multiget_slice(1:required string keyspace,
+# 2:required list<string> keys,
+# 3:required ColumnParent column_parent,
+# 4:required SlicePredicate predicate,
+# 5:required ConsistencyLevel consistency_level=1)
+# throws (1: InvalidRequestException ire, 2: UnavailableException ue),
+eval {
+ my $what = $client->multiget_slice(
+ 'Keyspace1',
+ [$key],
+ Net::Cassandra::Backend::ColumnParent->new(
+ { column_family => 'Standard1' }
+ ),
+ Net::Cassandra::Backend::SlicePredicate->new(
+ { column_names => ['name'],
+ slice_range => Net::Cassandra::Backend::SliceRange->new(
+ { start => '', finish => '', count => 100 }
+ )
+ }
+ ),
+ Net::Cassandra::Backend::ConsistencyLevel::QUORUM
+ );
+ my $value = $what->{$key}->[0]->column->value;
+ my $timestamp = $what->{$key}->[0]->column->timestamp;
+ warn "$value / $timestamp";
+};
die $@->why if $@;
-foreach my $row (@$slice) {
- say $row->{columnName}, ', ', $row->{timestamp}, ', ', $row->{value};
-}
+# i32 get_count(1:required string keyspace,
+# 2:required string key,
+# 3:required ColumnParent column_parent,
+# 4:required ConsistencyLevel consistency_level=1)
+# throws (1: InvalidRequestException ire, 2: UnavailableException ue),
+eval {
+ my $what = $client->get_count(
+ 'Keyspace1',
+ $key,
+ Net::Cassandra::Backend::ColumnParent->new(
+ { column_family => 'Standard1' }
+ ),
+ Net::Cassandra::Backend::ConsistencyLevel::QUORUM
+ );
+ warn "$what columns";
+};
+die $@->why if $@;
+
+# list<string> get_key_range(1:required string keyspace,
+# 2:required string column_family,
+# 3:required string start="",
+# 4:required string finish="",
+# 5:required i32 count=100,
+# 6:required ConsistencyLevel consistency_level=1)
+# throws (1: InvalidRequestException ire, 2: UnavailableException ue),
+eval {
+ my $what
+ = $client->get_key_range( 'Keyspace1', 'Standard1', '', '', 100,
+ Net::Cassandra::Backend::ConsistencyLevel::QUORUM );
+ warn "Keys: ", join( ', ', @$what );
+};
+warn $@->why if $@;
+
+# void remove(1:required string keyspace,
+# 2:required string key,
+# 3:required ColumnPath column_path,
+# 4:required i64 timestamp,
+# 5:ConsistencyLevel consistency_level=0)
+# throws (1: InvalidRequestException ire, 2: UnavailableException ue),
+eval {
+ $client->remove(
+ 'Keyspace1',
+ $key,
+ Net::Cassandra::Backend::ColumnPath->new(
+ { column_family => 'Standard1', column => 'name' }
+ ),
+ $timestamp
+ );
+};
+die $@->why if $@;
View
43 lib/Net/Cassandra.pm
@@ -46,33 +46,58 @@ Net::Cassandra - Interface to Cassandra
=head1 SYNOPSIS
- my $cassandra = Net::Cassandra->new;
+ my $cassandra = Net::Cassandra->new( hostname => 'localhost' );
my $client = $cassandra->client;
my $key = '123';
my $timestamp = time;
eval {
- $client->insert( 'Table1', $key, 'Standard1:name', 'Leon Brocard',
- $timestamp, 0 );
+ $client->insert(
+ 'Keyspace1',
+ $key,
+ Net::Cassandra::Backend::ColumnPath->new(
+ { column_family => 'Standard1', column => 'name' }
+ ),
+ 'Leon Brocard',
+ $timestamp,
+ Net::Cassandra::Backend::ConsistencyLevel::ZERO
+ );
};
die $@->why if $@;
eval {
- $client->remove( 'Table1', $key, 'Standard1:age', $timestamp );
+ my $what = $client->get(
+ 'Keyspace1',
+ $key,
+ Net::Cassandra::Backend::ColumnPath->new(
+ { column_family => 'Standard1', column => 'name' }
+ ),
+ Net::Cassandra::Backend::ConsistencyLevel::QUORUM
+ );
+ my $value = $what->column->value;
+ my $timestamp = $what->column->timestamp;
+ warn "$value / $timestamp";
};
die $@->why if $@;
- my $column;
- eval { $column = $client->get_column( 'Table1', $key, 'Standard1:name' ); };
+ eval {
+ $client->remove(
+ 'Keyspace1',
+ $key,
+ Net::Cassandra::Backend::ColumnPath->new(
+ { column_family => 'Standard1', column => 'name' }
+ ),
+ $timestamp
+ );
+ };
die $@->why if $@;
- say $column->{columnName}, ', ', $column->{value}, ', ', $column->{timestamp};
=head1 DESCRIPTION
This module provides an interface the to Cassandra distributed database.
-It uses the Thrift interface. This is changing rapidly and supports the
-development version of Cassandra built from Subversion trunk.
+It uses the Thrift interface. This is changing rapidly and supports
+version 0.4.2 of Cassandra.
=head1 AUTHOR
View
4,711 lib/Net/Cassandra/Backend/Cassandra.pm
1,740 additions, 2,971 deletions not shown
View
4 lib/Net/Cassandra/Backend/Thrift/BinaryProtocol.pm
@@ -477,7 +477,7 @@ sub readStringBody
#
# Binary Protocol Factory
#
-package Net::Cassandra::Backend::TBinaryProtocolFactory;
+package Net::Cassandra::Backend::Thrift::BinaryProtocolFactory;
use base('Net::Cassandra::Backend::TProtocolFactory');
sub new
@@ -492,7 +492,7 @@ sub getProtocol{
my $self = shift;
my $trans = shift;
- return new TBinaryProtocol($trans);
+ return new Net::Cassandra::Backend::Thrift::BinaryProtocol($trans);
}
1;
View
27 lib/Net/Cassandra/Backend/Thrift/BufferedTransport.pm
@@ -106,4 +106,31 @@ sub flush
}
+#
+# BufferedTransport factory creates buffered transport objects from transports
+#
+package Net::Cassandra::Backend::Thrift::BufferedTransportFactory;
+
+sub new {
+ my $classname = shift;
+ my $self = {};
+
+ return bless($self,$classname);
+}
+
+#
+# Build a buffered transport from the base transport
+#
+# @return Thrift::BufferedTransport transport
+#
+sub getTransport
+{
+ my $self = shift;
+ my $trans = shift;
+
+ my $buffered = Net::Cassandra::Backend::Thrift::BufferedTransport->new($trans);
+ return $buffered;
+}
+
+
1;
View
20 lib/Net/Cassandra/Backend/Thrift/MemoryBuffer.pm
@@ -109,6 +109,26 @@ sub read
return $ret;
}
+sub readAll
+{
+ my $self = shift;
+ my $len = shift;
+
+ my $avail = ($self->{wPos} - $self->{rPos});
+ if ($avail < $len) {
+ die new Net::Cassandra::Backend::TTransportException("Attempt to readAll($len) found only $avail available");
+ }
+
+ my $data = '';
+ my $got = 0;
+
+ while (($got = length($data)) < $len) {
+ $data .= $self->read($len - $got);
+ }
+
+ return $data;
+}
+
sub write
{
my $self = shift;
View
313 lib/Net/Cassandra/Backend/Thrift/Server.pm
@@ -0,0 +1,313 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+require 5.6.0;
+use strict;
+use warnings;
+
+use Net::Cassandra::Backend::Thrift;
+use Net::Cassandra::Backend::Thrift::BufferedTransport;
+use Net::Cassandra::Backend::Thrift::BinaryProtocol;
+
+#
+# Server base class module
+#
+package Net::Cassandra::Backend::Thrift::Server;
+
+# 3 possible constructors:
+# 1. (processor, serverTransport)
+# 2. (processor, serverTransport, transportFactory, protocolFactory)
+# 3. (processor, serverTransport,
+# inputTransportFactory, outputTransportFactory,
+# inputProtocolFactory, outputProtocolFactory)
+sub new
+{
+ my $classname = shift;
+ my @args = @_;
+
+ my $self;
+
+ if (scalar @args == 2)
+ {
+ $self = _init($args[0], $args[1],
+ Net::Cassandra::Backend::Thrift::BufferedTransportFactory->new(),
+ Net::Cassandra::Backend::Thrift::BufferedTransportFactory->new(),
+ Net::Cassandra::Backend::Thrift::BinaryProtocolFactory->new(),
+ Net::Cassandra::Backend::Thrift::BinaryProtocolFactory->new());
+ }
+ elsif (scalar @args == 4)
+ {
+ $self = _init($args[0], $args[1], $args[2], $args[2], $args[3], $args[3]);
+ }
+ elsif (scalar @args == 6)
+ {
+ $self = _init($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
+ }
+ else
+ {
+ die "Thrift::Server expects exactly 2, 4, or 6 args";
+ }
+
+ return bless($self,$classname);
+}
+
+sub _init
+{
+ my $processor = shift;
+ my $serverTransport = shift;
+ my $inputTransportFactory = shift;
+ my $outputTransportFactory = shift;
+ my $inputProtocolFactory = shift;
+ my $outputProtocolFactory = shift;
+
+ my $self = {
+ processor => $processor,
+ serverTransport => $serverTransport,
+ inputTransportFactory => $inputTransportFactory,
+ outputTransportFactory => $outputTransportFactory,
+ inputProtocolFactory => $inputProtocolFactory,
+ outputProtocolFactory => $outputProtocolFactory,
+ };
+}
+
+sub serve
+{
+ die "abstract";
+}
+
+sub _clientBegin
+{
+ my $self = shift;
+ my $iprot = shift;
+ my $oprot = shift;
+
+ if (exists $self->{serverEventHandler} and
+ defined $self->{serverEventHandler})
+ {
+ $self->{serverEventHandler}->clientBegin($iprot, $oprot);
+ }
+}
+
+sub _handleException
+{
+ my $self = shift;
+ my $e = shift;
+
+ if ($e =~ m/TException/ and exists $e->{message}) {
+ my $message = $e->{message};
+ my $code = $e->{code};
+ my $out = $code . ':' . $message;
+
+ $message =~ m/TTransportException/ and die $out;
+ if ($message =~ m/TSocket/) {
+ # suppress TSocket messages
+ } else {
+ warn $out;
+ }
+ } else {
+ warn $e;
+ }
+}
+
+
+#
+# SimpleServer from the Server base class that handles one connection at a time
+#
+package Net::Cassandra::Backend::Thrift::SimpleServer;
+use base qw( Thrift::Server );
+
+sub new
+{
+ my $classname = shift;
+ my @args = @_;
+
+ my $self = $classname->SUPER::new(@args);
+ return bless($self,$classname);
+}
+
+sub serve
+{
+ my $self = shift;
+
+ $self->{serverTransport}->listen();
+ while (1)
+ {
+ my $client = $self->{serverTransport}->accept();
+ my $itrans = $self->{inputTransportFactory}->getTransport($client);
+ my $otrans = $self->{outputTransportFactory}->getTransport($client);
+ my $iprot = $self->{inputProtocolFactory}->getProtocol($itrans);
+ my $oprot = $self->{outputProtocolFactory}->getProtocol($otrans);
+ eval {
+ $self->_clientBegin($iprot, $oprot);
+ while (1)
+ {
+ $self->{processor}->process($iprot, $oprot);
+ }
+ }; if($@) {
+ $self->_handleException($@);
+ }
+
+ $itrans->close();
+ $otrans->close();
+ }
+}
+
+
+#
+# ForkingServer that forks a new process for each request
+#
+package Net::Cassandra::Backend::Thrift::ForkingServer;
+use base qw( Thrift::Server );
+
+use POSIX ":sys_wait_h";
+
+sub new
+{
+ my $classname = shift;
+ my @args = @_;
+
+ my $self = $classname->SUPER::new(@args);
+ return bless($self,$classname);
+}
+
+
+sub serve
+{
+ my $self = shift;
+
+ $self->{serverTransport}->listen();
+ while (1)
+ {
+ my $client = $self->{serverTransport}->accept();
+ $self->_client($client);
+ }
+}
+
+sub _client
+{
+ my $self = shift;
+ my $client = shift;
+
+ eval {
+ my $itrans = $self->{inputTransportFactory}->getTransport($client);
+ my $otrans = $self->{outputTransportFactory}->getTransport($client);
+
+ my $iprot = $self->{inputProtocolFactory}->getProtocol($itrans);
+ my $oprot = $self->{outputProtocolFactory}->getProtocol($otrans);
+
+ $self->_clientBegin($iprot, $oprot);
+
+ my $pid = fork();
+
+ if ($pid) #parent
+ {
+ $self->_parent($pid, $itrans, $otrans);
+ } else {
+ $self->_child($itrans, $otrans, $iprot, $oprot);
+ }
+ }; if($@) {
+ $self->_handleException($@);
+ }
+}
+
+sub _parent
+{
+ my $self = shift;
+ my $pid = shift;
+ my $itrans = shift;
+ my $otrans = shift;
+
+ # add before collect, otherwise you race w/ waitpid
+ $self->{children}->{$pid} = 1;
+ $self->_collectChildren();
+
+ # Parent must close socket or the connection may not get closed promptly
+ $self->tryClose($itrans);
+ $self->tryClose($otrans);
+}
+
+sub _child
+{
+ my $self = shift;
+ my $itrans = shift;
+ my $otrans = shift;
+ my $iprot = shift;
+ my $oprot = shift;
+
+ my $ecode = 0;
+ eval {
+ while (1)
+ {
+ $self->{processor}->process($iprot, $oprot);
+ }
+ }; if($@) {
+ $ecode = 1;
+ $self->_handleException($@);
+ }
+
+ $self->tryClose($itrans);
+ $self->tryClose($otrans);
+
+ exit($ecode);
+}
+
+sub tryClose
+{
+ my $self = shift;
+ my $file = shift;
+
+ eval {
+ if (defined $file)
+ {
+ $file->close();
+ }
+ }; if($@) {
+ if ($@ =~ m/TException/ and exists $@->{message}) {
+ my $message = $@->{message};
+ my $code = $@->{code};
+ my $out = $code . ':' . $message;
+
+ warn $out;
+ } else {
+ warn $@;
+ }
+ }
+}
+
+sub _collectChildren
+{
+ my $self = shift;
+
+ while (scalar keys %{$self->{children}})
+ {
+ my $pid = waitpid(-1, WNOHANG);
+
+ if ($pid>0)
+ {
+ delete $self->{children}->{$pid};
+ }
+ else
+ {
+ last;
+ }
+ }
+}
+
+
+1;
View
75 lib/Net/Cassandra/Backend/Thrift/Socket.pm
@@ -33,9 +33,9 @@ use base('Net::Cassandra::Backend::Thrift::Transport');
sub new
{
- my $classname = shift;
- my $host = shift || "localhost";
- my $port = shift || 9090;
+ my $classname = shift;
+ my $host = shift || "localhost";
+ my $port = shift || 9090;
my $debugHandler = shift;
my $self = {
@@ -43,8 +43,8 @@ sub new
port => $port,
debugHandler => $debugHandler,
debug => 0,
- sendTimeout => 100,
- recvTimeout => 750,
+ sendTimeout => 10000,
+ recvTimeout => 10000,
handle => undef,
};
@@ -132,7 +132,7 @@ sub close
my $self = shift;
if( defined $self->{handle} ){
- close( ($self->{handle}->handles())[0] );
+ CORE::close( ($self->{handle}->handles())[0] );
}
}
@@ -196,7 +196,7 @@ sub read
return unless defined $self->{handle};
#check for timeout
- my @sockets = $self->{handle}->can_read( $self->{sendTimeout} / 1000 );
+ my @sockets = $self->{handle}->can_read( $self->{recvTimeout} / 1000 );
if(@sockets == 0){
die new Net::Cassandra::Backend::Thrift::TException('TSocket: timed out reading '.$len.' bytes from '.
@@ -236,7 +236,7 @@ sub write
#check for timeout
- my @sockets = $self->{handle}->can_write( $self->{recvTimeout} / 1000 );
+ my @sockets = $self->{handle}->can_write( $self->{sendTimeout} / 1000 );
if(@sockets == 0){
die new Net::Cassandra::Backend::Thrift::TException('TSocket: timed out writing to bytes from '.
@@ -268,4 +268,63 @@ sub flush
my $ret = ($self->{handle}->handles())[0]->flush;
}
+
+#
+# Build a ServerSocket from the ServerTransport base class
+#
+package Net::Cassandra::Backend::Thrift::ServerSocket;
+
+use base qw( Net::Cassandra::Backend::Thrift::Socket Net::Cassandra::Backend::Thrift::ServerTransport );
+
+use constant LISTEN_QUEUE_SIZE => 128;
+
+sub new
+{
+ my $classname = shift;
+ my $port = shift;
+
+ my $self = $classname->SUPER::new(undef, $port, undef);
+ return bless($self,$classname);
+}
+
+sub listen
+{
+ my $self = shift;
+
+ # Listen to a new socket
+ my $sock = IO::Socket::INET->new(LocalAddr => undef, # any addr
+ LocalPort => $self->{port},
+ Proto => 'tcp',
+ Listen => LISTEN_QUEUE_SIZE,
+ ReuseAddr => 1)
+ || do {
+ my $error = 'TServerSocket: Could not bind to ' .
+ $self->{host} . ':' . $self->{port} . ' (' . $! . ')';
+
+ if ($self->{debug}) {
+ $self->{debugHandler}->($error);
+ }
+
+ die new Net::Cassandra::Backend::Thrift::TException($error);
+ };
+
+ $self->{handle} = $sock;
+}
+
+sub accept
+{
+ my $self = shift;
+
+ if ( exists $self->{handle} and defined $self->{handle} )
+ {
+ my $client = $self->{handle}->accept();
+ my $result = new Net::Cassandra::Backend::Thrift::Socket;
+ $result->{handle} = new IO::Select($client);
+ return $result;
+ }
+
+ return 0;
+}
+
+
1;
View
48 lib/Net/Cassandra/Backend/Thrift/Transport.pm
@@ -125,5 +125,53 @@ sub write
#
sub flush {}
+
+#
+# TransportFactory creates transport objects from transports
+#
+package Net::Cassandra::Backend::Thrift::TransportFactory;
+
+sub new {
+ my $classname = shift;
+ my $self = {};
+
+ return bless($self,$classname);
+}
+
+#
+# Build a transport from the base transport
+#
+# @return Thrift::Transport transport
+#
+sub getTransport
+{
+ my $self = shift;
+ my $trans = shift;
+
+ return $trans;
+}
+
+
+#
+# ServerTransport base class module
+#
+package Net::Cassandra::Backend::Thrift::ServerTransport;
+
+sub listen
+{
+ die "abstract";
+}
+
+sub accept
+{
+ die "abstract";
+}
+
+sub close
+{
+ die "abstract";
+}
+
+
1;
View
809 lib/Net/Cassandra/Backend/Types.pm
@@ -8,20 +8,25 @@ use strict;
use warnings;
use Net::Cassandra::Backend::Thrift;
-package Net::Cassandra::Backend::column_t;
-use Class::Accessor;
-use base('Class::Accessor');
-Net::Cassandra::Backend::column_t->mk_accessors( qw( columnName value timestamp ) );
+package Net::Cassandra::Backend::ConsistencyLevel;
+use constant ZERO => 0;
+use constant ONE => 1;
+use constant QUORUM => 2;
+use constant ALL => 3;
+package Net::Cassandra::Backend::Column;
+use base qw(Class::Accessor);
+Net::Cassandra::Backend::Column->mk_accessors( qw( name value timestamp ) );
+
sub new {
-my $classname = shift;
-my $self = {};
-my $vals = shift || {};
-$self->{columnName} = undef;
-$self->{value} = undef;
-$self->{timestamp} = undef;
+ my $classname = shift;
+ my $self = {};
+ my $vals = shift || {};
+ $self->{name} = undef;
+ $self->{value} = undef;
+ $self->{timestamp} = undef;
if (UNIVERSAL::isa($vals,'HASH')) {
- if (defined $vals->{columnName}) {
- $self->{columnName} = $vals->{columnName};
+ if (defined $vals->{name}) {
+ $self->{name} = $vals->{name};
}
if (defined $vals->{value}) {
$self->{value} = $vals->{value};
@@ -30,16 +35,15 @@ $self->{timestamp} = undef;
$self->{timestamp} = $vals->{timestamp};
}
}
-return bless($self,$classname);
+ return bless ($self, $classname);
}
sub getName {
- return 'Net::Cassandra::Backend::column_t';
+ return 'Column';
}
sub read {
- my $self = shift;
- my $input = shift;
+ my ($self, $input) = @_;
my $xfer = 0;
my $fname;
my $ftype = 0;
@@ -54,7 +58,7 @@ sub read {
SWITCH: for($fid)
{
/^1$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
- $xfer += $input->readString(\$self->{columnName});
+ $xfer += $input->readString(\$self->{name});
} else {
$xfer += $input->skip($ftype);
}
@@ -80,13 +84,12 @@ sub read {
}
sub write {
- my $self = shift;
- my $output = shift;
+ my ($self, $output) = @_;
my $xfer = 0;
- $xfer += $output->writeStructBegin('Net::Cassandra::Backend::column_t');
- if (defined $self->{columnName}) {
- $xfer += $output->writeFieldBegin('columnName', Net::Cassandra::Backend::TType::STRING, 1);
- $xfer += $output->writeString($self->{columnName});
+ $xfer += $output->writeStructBegin('Column');
+ if (defined $self->{name}) {
+ $xfer += $output->writeFieldBegin('name', Net::Cassandra::Backend::TType::STRING, 1);
+ $xfer += $output->writeString($self->{name});
$xfer += $output->writeFieldEnd();
}
if (defined $self->{value}) {
@@ -104,38 +107,33 @@ sub write {
return $xfer;
}
-package Net::Cassandra::Backend::batch_mutation_t;
-use Class::Accessor;
-use base('Class::Accessor');
-Net::Cassandra::Backend::batch_mutation_t->mk_accessors( qw( table key cfmap ) );
+package Net::Cassandra::Backend::SuperColumn;
+use base qw(Class::Accessor);
+Net::Cassandra::Backend::SuperColumn->mk_accessors( qw( name columns ) );
+
sub new {
-my $classname = shift;
-my $self = {};
-my $vals = shift || {};
-$self->{table} = undef;
-$self->{key} = undef;
-$self->{cfmap} = undef;
+ my $classname = shift;
+ my $self = {};
+ my $vals = shift || {};
+ $self->{name} = undef;
+ $self->{columns} = undef;
if (UNIVERSAL::isa($vals,'HASH')) {
- if (defined $vals->{table}) {
- $self->{table} = $vals->{table};
- }
- if (defined $vals->{key}) {
- $self->{key} = $vals->{key};
+ if (defined $vals->{name}) {
+ $self->{name} = $vals->{name};
}
- if (defined $vals->{cfmap}) {
- $self->{cfmap} = $vals->{cfmap};
+ if (defined $vals->{columns}) {
+ $self->{columns} = $vals->{columns};
}
}
-return bless($self,$classname);
+ return bless ($self, $classname);
}
sub getName {
- return 'Net::Cassandra::Backend::batch_mutation_t';
+ return 'SuperColumn';
}
sub read {
- my $self = shift;
- my $input = shift;
+ my ($self, $input) = @_;
my $xfer = 0;
my $fname;
my $ftype = 0;
@@ -150,46 +148,25 @@ sub read {
SWITCH: for($fid)
{
/^1$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
- $xfer += $input->readString(\$self->{table});
- } else {
- $xfer += $input->skip($ftype);
- }
- last; };
- /^2$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
- $xfer += $input->readString(\$self->{key});
+ $xfer += $input->readString(\$self->{name});
} else {
$xfer += $input->skip($ftype);
}
last; };
- /^3$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::MAP) {
+ /^2$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::LIST) {
{
my $_size0 = 0;
- $self->{cfmap} = {};
- my $_ktype1 = 0;
- my $_vtype2 = 0;
- $xfer += $input->readMapBegin(\$_ktype1, \$_vtype2, \$_size0);
+ $self->{columns} = [];
+ my $_etype3 = 0;
+ $xfer += $input->readListBegin(\$_etype3, \$_size0);
for (my $_i4 = 0; $_i4 < $_size0; ++$_i4)
{
- my $key5 = '';
- my $val6 = [];
- $xfer += $input->readString(\$key5);
- {
- my $_size7 = 0;
- $val6 = [];
- my $_etype10 = 0;
- $xfer += $input->readListBegin(\$_etype10, \$_size7);
- for (my $_i11 = 0; $_i11 < $_size7; ++$_i11)
- {
- my $elem12 = undef;
- $elem12 = new Net::Cassandra::Backend::column_t();
- $xfer += $elem12->read($input);
- push(@{$val6},$elem12);
- }
- $xfer += $input->readListEnd();
- }
- $self->{cfmap}->{$key5} = $val6;
+ my $elem5 = undef;
+ $elem5 = new Net::Cassandra::Backend::Column();
+ $xfer += $elem5->read($input);
+ push(@{$self->{columns}},$elem5);
}
- $xfer += $input->readMapEnd();
+ $xfer += $input->readListEnd();
}
} else {
$xfer += $input->skip($ftype);
@@ -204,41 +181,25 @@ sub read {
}
sub write {
- my $self = shift;
- my $output = shift;
+ my ($self, $output) = @_;
my $xfer = 0;
- $xfer += $output->writeStructBegin('Net::Cassandra::Backend::batch_mutation_t');
- if (defined $self->{table}) {
- $xfer += $output->writeFieldBegin('table', Net::Cassandra::Backend::TType::STRING, 1);
- $xfer += $output->writeString($self->{table});
- $xfer += $output->writeFieldEnd();
- }
- if (defined $self->{key}) {
- $xfer += $output->writeFieldBegin('key', Net::Cassandra::Backend::TType::STRING, 2);
- $xfer += $output->writeString($self->{key});
+ $xfer += $output->writeStructBegin('SuperColumn');
+ if (defined $self->{name}) {
+ $xfer += $output->writeFieldBegin('name', Net::Cassandra::Backend::TType::STRING, 1);
+ $xfer += $output->writeString($self->{name});
$xfer += $output->writeFieldEnd();
}
- if (defined $self->{cfmap}) {
- $xfer += $output->writeFieldBegin('cfmap', Net::Cassandra::Backend::TType::MAP, 3);
+ if (defined $self->{columns}) {
+ $xfer += $output->writeFieldBegin('columns', Net::Cassandra::Backend::TType::LIST, 2);
{
- $output->writeMapBegin(Net::Cassandra::Backend::TType::STRING, Net::Cassandra::Backend::TType::LIST, scalar(keys %{$self->{cfmap}}));
+ $output->writeListBegin(Net::Cassandra::Backend::TType::STRUCT, scalar(@{$self->{columns}}));
{
- while( my ($kiter13,$viter14) = each %{$self->{cfmap}})
+ foreach my $iter6 (@{$self->{columns}})
{
- $xfer += $output->writeString($kiter13);
- {
- $output->writeListBegin(Net::Cassandra::Backend::TType::STRUCT, scalar(@{${viter14}}));
- {
- foreach my $iter15 (@{${viter14}})
- {
- $xfer += ${iter15}->write($output);
- }
- }
- $output->writeListEnd();
- }
+ $xfer += ${iter6}->write($output);
}
}
- $output->writeMapEnd();
+ $output->writeListEnd();
}
$xfer += $output->writeFieldEnd();
}
@@ -247,34 +208,33 @@ sub write {
return $xfer;
}
-package Net::Cassandra::Backend::superColumn_t;
-use Class::Accessor;
-use base('Class::Accessor');
-Net::Cassandra::Backend::superColumn_t->mk_accessors( qw( name columns ) );
+package Net::Cassandra::Backend::ColumnOrSuperColumn;
+use base qw(Class::Accessor);
+Net::Cassandra::Backend::ColumnOrSuperColumn->mk_accessors( qw( column super_column ) );
+
sub new {
-my $classname = shift;
-my $self = {};
-my $vals = shift || {};
-$self->{name} = undef;
-$self->{columns} = undef;
+ my $classname = shift;
+ my $self = {};
+ my $vals = shift || {};
+ $self->{column} = undef;
+ $self->{super_column} = undef;
if (UNIVERSAL::isa($vals,'HASH')) {
- if (defined $vals->{name}) {
- $self->{name} = $vals->{name};
+ if (defined $vals->{column}) {
+ $self->{column} = $vals->{column};
}
- if (defined $vals->{columns}) {
- $self->{columns} = $vals->{columns};
+ if (defined $vals->{super_column}) {
+ $self->{super_column} = $vals->{super_column};
}
}
-return bless($self,$classname);
+ return bless ($self, $classname);
}
sub getName {
- return 'Net::Cassandra::Backend::superColumn_t';
+ return 'ColumnOrSuperColumn';
}
sub read {
- my $self = shift;
- my $input = shift;
+ my ($self, $input) = @_;
my $xfer = 0;
my $fname;
my $ftype = 0;
@@ -288,27 +248,16 @@ sub read {
}
SWITCH: for($fid)
{
- /^1$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
- $xfer += $input->readString(\$self->{name});
+ /^1$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRUCT) {
+ $self->{column} = new Net::Cassandra::Backend::Column();
+ $xfer += $self->{column}->read($input);
} else {
$xfer += $input->skip($ftype);
}
last; };
- /^2$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::LIST) {
- {
- my $_size16 = 0;
- $self->{columns} = [];
- my $_etype19 = 0;
- $xfer += $input->readListBegin(\$_etype19, \$_size16);
- for (my $_i20 = 0; $_i20 < $_size16; ++$_i20)
- {
- my $elem21 = undef;
- $elem21 = new Net::Cassandra::Backend::column_t();
- $xfer += $elem21->read($input);
- push(@{$self->{columns}},$elem21);
- }
- $xfer += $input->readListEnd();
- }
+ /^2$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRUCT) {
+ $self->{super_column} = new Net::Cassandra::Backend::SuperColumn();
+ $xfer += $self->{super_column}->read($input);
} else {
$xfer += $input->skip($ftype);
}
@@ -322,27 +271,17 @@ sub read {
}
sub write {
- my $self = shift;
- my $output = shift;
+ my ($self, $output) = @_;
my $xfer = 0;
- $xfer += $output->writeStructBegin('Net::Cassandra::Backend::superColumn_t');
- if (defined $self->{name}) {
- $xfer += $output->writeFieldBegin('name', Net::Cassandra::Backend::TType::STRING, 1);
- $xfer += $output->writeString($self->{name});
+ $xfer += $output->writeStructBegin('ColumnOrSuperColumn');
+ if (defined $self->{column}) {
+ $xfer += $output->writeFieldBegin('column', Net::Cassandra::Backend::TType::STRUCT, 1);
+ $xfer += $self->{column}->write($output);
$xfer += $output->writeFieldEnd();
}
- if (defined $self->{columns}) {
- $xfer += $output->writeFieldBegin('columns', Net::Cassandra::Backend::TType::LIST, 2);
- {
- $output->writeListBegin(Net::Cassandra::Backend::TType::STRUCT, scalar(@{$self->{columns}}));
- {
- foreach my $iter22 (@{$self->{columns}})
- {
- $xfer += ${iter22}->write($output);
- }
- }
- $output->writeListEnd();
- }
+ if (defined $self->{super_column}) {
+ $xfer += $output->writeFieldBegin('super_column', Net::Cassandra::Backend::TType::STRUCT, 2);
+ $xfer += $self->{super_column}->write($output);
$xfer += $output->writeFieldEnd();
}
$xfer += $output->writeFieldStop();
@@ -350,38 +289,77 @@ sub write {
return $xfer;
}
-package Net::Cassandra::Backend::batch_mutation_super_t;
-use Class::Accessor;
-use base('Class::Accessor');
-Net::Cassandra::Backend::batch_mutation_super_t->mk_accessors( qw( table key cfmap ) );
+package Net::Cassandra::Backend::NotFoundException;
+use base qw(Net::Cassandra::Backend::Thrift::TException);
+use base qw(Class::Accessor);
+
sub new {
-my $classname = shift;
-my $self = {};
-my $vals = shift || {};
-$self->{table} = undef;
-$self->{key} = undef;
-$self->{cfmap} = undef;
- if (UNIVERSAL::isa($vals,'HASH')) {
- if (defined $vals->{table}) {
- $self->{table} = $vals->{table};
+ my $classname = shift;
+ my $self = {};
+ my $vals = shift || {};
+ return bless ($self, $classname);
+}
+
+sub getName {
+ return 'NotFoundException';
+}
+
+sub read {
+ my ($self, $input) = @_;
+ my $xfer = 0;
+ my $fname;
+ my $ftype = 0;
+ my $fid = 0;
+ $xfer += $input->readStructBegin(\$fname);
+ while (1)
+ {
+ $xfer += $input->readFieldBegin(\$fname, \$ftype, \$fid);
+ if ($ftype == Net::Cassandra::Backend::TType::STOP) {
+ last;
}
- if (defined $vals->{key}) {
- $self->{key} = $vals->{key};
+ SWITCH: for($fid)
+ {
+ $xfer += $input->skip($ftype);
}
- if (defined $vals->{cfmap}) {
- $self->{cfmap} = $vals->{cfmap};
+ $xfer += $input->readFieldEnd();
+ }
+ $xfer += $input->readStructEnd();
+ return $xfer;
+}
+
+sub write {
+ my ($self, $output) = @_;
+ my $xfer = 0;
+ $xfer += $output->writeStructBegin('NotFoundException');
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+}
+
+package Net::Cassandra::Backend::InvalidRequestException;
+use base qw(Net::Cassandra::Backend::Thrift::TException);
+use base qw(Class::Accessor);
+Net::Cassandra::Backend::InvalidRequestException->mk_accessors( qw( why ) );
+
+sub new {
+ my $classname = shift;
+ my $self = {};
+ my $vals = shift || {};
+ $self->{why} = undef;
+ if (UNIVERSAL::isa($vals,'HASH')) {
+ if (defined $vals->{why}) {
+ $self->{why} = $vals->{why};
}
}
-return bless($self,$classname);
+ return bless ($self, $classname);
}
sub getName {
- return 'Net::Cassandra::Backend::batch_mutation_super_t';
+ return 'InvalidRequestException';
}
sub read {
- my $self = shift;
- my $input = shift;
+ my ($self, $input) = @_;
my $xfer = 0;
my $fname;
my $ftype = 0;
@@ -396,47 +374,7 @@ sub read {
SWITCH: for($fid)
{
/^1$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
- $xfer += $input->readString(\$self->{table});
- } else {
- $xfer += $input->skip($ftype);
- }
- last; };
- /^2$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
- $xfer += $input->readString(\$self->{key});
- } else {
- $xfer += $input->skip($ftype);
- }
- last; };
- /^3$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::MAP) {
- {
- my $_size23 = 0;
- $self->{cfmap} = {};
- my $_ktype24 = 0;
- my $_vtype25 = 0;
- $xfer += $input->readMapBegin(\$_ktype24, \$_vtype25, \$_size23);
- for (my $_i27 = 0; $_i27 < $_size23; ++$_i27)
- {
- my $key28 = '';
- my $val29 = [];
- $xfer += $input->readString(\$key28);
- {
- my $_size30 = 0;
- $val29 = [];
- my $_etype33 = 0;
- $xfer += $input->readListBegin(\$_etype33, \$_size30);
- for (my $_i34 = 0; $_i34 < $_size30; ++$_i34)
- {
- my $elem35 = undef;
- $elem35 = new Net::Cassandra::Backend::superColumn_t();
- $xfer += $elem35->read($input);
- push(@{$val29},$elem35);
- }
- $xfer += $input->readListEnd();
- }
- $self->{cfmap}->{$key28} = $val29;
- }
- $xfer += $input->readMapEnd();
- }
+ $xfer += $input->readString(\$self->{why});
} else {
$xfer += $input->skip($ftype);
}
@@ -450,81 +388,93 @@ sub read {
}
sub write {
- my $self = shift;
- my $output = shift;
+ my ($self, $output) = @_;
my $xfer = 0;
- $xfer += $output->writeStructBegin('Net::Cassandra::Backend::batch_mutation_super_t');
- if (defined $self->{table}) {
- $xfer += $output->writeFieldBegin('table', Net::Cassandra::Backend::TType::STRING, 1);
- $xfer += $output->writeString($self->{table});
- $xfer += $output->writeFieldEnd();
- }
- if (defined $self->{key}) {
- $xfer += $output->writeFieldBegin('key', Net::Cassandra::Backend::TType::STRING, 2);
- $xfer += $output->writeString($self->{key});
+ $xfer += $output->writeStructBegin('InvalidRequestException');
+ if (defined $self->{why}) {
+ $xfer += $output->writeFieldBegin('why', Net::Cassandra::Backend::TType::STRING, 1);
+ $xfer += $output->writeString($self->{why});
$xfer += $output->writeFieldEnd();
}
- if (defined $self->{cfmap}) {
- $xfer += $output->writeFieldBegin('cfmap', Net::Cassandra::Backend::TType::MAP, 3);
+ $xfer += $output->writeFieldStop();
+ $xfer += $output->writeStructEnd();
+ return $xfer;
+}
+
+package Net::Cassandra::Backend::UnavailableException;
+use base qw(Net::Cassandra::Backend::Thrift::TException);
+use base qw(Class::Accessor);
+
+sub new {
+ my $classname = shift;
+ my $self = {};
+ my $vals = shift || {};
+ return bless ($self, $classname);
+}
+
+sub getName {
+ return 'UnavailableException';
+}
+
+sub read {
+ my ($self, $input) = @_;
+ my $xfer = 0;
+ my $fname;
+ my $ftype = 0;
+ my $fid = 0;
+ $xfer += $input->readStructBegin(\$fname);
+ while (1)
+ {
+ $xfer += $input->readFieldBegin(\$fname, \$ftype, \$fid);
+ if ($ftype == Net::Cassandra::Backend::TType::STOP) {
+ last;
+ }
+ SWITCH: for($fid)
{
- $output->writeMapBegin(Net::Cassandra::Backend::TType::STRING, Net::Cassandra::Backend::TType::LIST, scalar(keys %{$self->{cfmap}}));
- {
- while( my ($kiter36,$viter37) = each %{$self->{cfmap}})
- {
- $xfer += $output->writeString($kiter36);
- {
- $output->writeListBegin(Net::Cassandra::Backend::TType::STRUCT, scalar(@{${viter37}}));
- {
- foreach my $iter38 (@{${viter37}})
- {
- $xfer += ${iter38}->write($output);
- }
- }
- $output->writeListEnd();
- }
- }
- }
- $output->writeMapEnd();
+ $xfer += $input->skip($ftype);
}
- $xfer += $output->writeFieldEnd();
+ $xfer += $input->readFieldEnd();
}
+ $xfer += $input->readStructEnd();
+ return $xfer;
+}
+
+sub write {
+ my ($self, $output) = @_;
+ my $xfer = 0;
+ $xfer += $output->writeStructBegin('UnavailableException');
$xfer += $output->writeFieldStop();
$xfer += $output->writeStructEnd();
return $xfer;
}
-package Net::Cassandra::Backend::CqlResult_t;
-use Class::Accessor;
-use base('Class::Accessor');
-Net::Cassandra::Backend::CqlResult_t->mk_accessors( qw( errorCode errorTxt resultSet ) );
+package Net::Cassandra::Backend::ColumnParent;
+use base qw(Class::Accessor);
+Net::Cassandra::Backend::ColumnParent->mk_accessors( qw( column_family super_column ) );
+
sub new {
-my $classname = shift;
-my $self = {};
-my $vals = shift || {};
-$self->{errorCode} = undef;
-$self->{errorTxt} = undef;
-$self->{resultSet} = undef;
+ my $classname = shift;
+ my $self = {};
+ my $vals = shift || {};
+ $self->{column_family} = undef;
+ $self->{super_column} = undef;
if (UNIVERSAL::isa($vals,'HASH')) {
- if (defined $vals->{errorCode}) {
- $self->{errorCode} = $vals->{errorCode};
- }
- if (defined $vals->{errorTxt}) {
- $self->{errorTxt} = $vals->{errorTxt};
+ if (defined $vals->{column_family}) {
+ $self->{column_family} = $vals->{column_family};
}
- if (defined $vals->{resultSet}) {
- $self->{resultSet} = $vals->{resultSet};
+ if (defined $vals->{super_column}) {
+ $self->{super_column} = $vals->{super_column};
}
}
-return bless($self,$classname);
+ return bless ($self, $classname);
}
sub getName {
- return 'Net::Cassandra::Backend::CqlResult_t';
+ return 'ColumnParent';
}
sub read {
- my $self = shift;
- my $input = shift;
+ my ($self, $input) = @_;
my $xfer = 0;
my $fname;
my $ftype = 0;
@@ -538,47 +488,14 @@ sub read {
}
SWITCH: for($fid)
{
- /^1$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::I32) {
- $xfer += $input->readI32(\$self->{errorCode});
- } else {
- $xfer += $input->skip($ftype);
- }
- last; };
- /^2$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
- $xfer += $input->readString(\$self->{errorTxt});
+ /^3$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
+ $xfer += $input->readString(\$self->{column_family});
} else {
$xfer += $input->skip($ftype);
}
last; };
- /^3$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::LIST) {
- {
- my $_size39 = 0;
- $self->{resultSet} = [];
- my $_etype42 = 0;
- $xfer += $input->readListBegin(\$_etype42, \$_size39);
- for (my $_i43 = 0; $_i43 < $_size39; ++$_i43)
- {
- my $elem44 = undef;
- {
- my $_size45 = 0;
- $elem44 = {};
- my $_ktype46 = 0;
- my $_vtype47 = 0;
- $xfer += $input->readMapBegin(\$_ktype46, \$_vtype47, \$_size45);
- for (my $_i49 = 0; $_i49 < $_size45; ++$_i49)
- {
- my $key50 = '';
- my $val51 = '';
- $xfer += $input->readString(\$key50);
- $xfer += $input->readString(\$val51);
- $elem44->{$key50} = $val51;
- }
- $xfer += $input->readMapEnd();
- }
- push(@{$self->{resultSet}},$elem44);
- }
- $xfer += $input->readListEnd();
- }
+ /^4$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
+ $xfer += $input->readString(\$self->{super_column});
} else {
$xfer += $input->skip($ftype);
}
@@ -592,42 +509,17 @@ sub read {
}
sub write {
- my $self = shift;
- my $output = shift;
+ my ($self, $output) = @_;
my $xfer = 0;
- $xfer += $output->writeStructBegin('Net::Cassandra::Backend::CqlResult_t');
- if (defined $self->{errorCode}) {
- $xfer += $output->writeFieldBegin('errorCode', Net::Cassandra::Backend::TType::I32, 1);
- $xfer += $output->writeI32($self->{errorCode});
+ $xfer += $output->writeStructBegin('ColumnParent');
+ if (defined $self->{column_family}) {
+ $xfer += $output->writeFieldBegin('column_family', Net::Cassandra::Backend::TType::STRING, 3);
+ $xfer += $output->writeString($self->{column_family});
$xfer += $output->writeFieldEnd();
}
- if (defined $self->{errorTxt}) {
- $xfer += $output->writeFieldBegin('errorTxt', Net::Cassandra::Backend::TType::STRING, 2);
- $xfer += $output->writeString($self->{errorTxt});
- $xfer += $output->writeFieldEnd();
- }
- if (defined $self->{resultSet}) {
- $xfer += $output->writeFieldBegin('resultSet', Net::Cassandra::Backend::TType::LIST, 3);
- {
- $output->writeListBegin(Net::Cassandra::Backend::TType::MAP, scalar(@{$self->{resultSet}}));
- {
- foreach my $iter52 (@{$self->{resultSet}})
- {
- {
- $output->writeMapBegin(Net::Cassandra::Backend::TType::STRING, Net::Cassandra::Backend::TType::STRING, scalar(keys %{${iter52}}));
- {
- while( my ($kiter53,$viter54) = each %{${iter52}})
- {
- $xfer += $output->writeString($kiter53);
- $xfer += $output->writeString($viter54);
- }
- }
- $output->writeMapEnd();
- }
- }
- }
- $output->writeListEnd();
- }
+ if (defined $self->{super_column}) {
+ $xfer += $output->writeFieldBegin('super_column', Net::Cassandra::Backend::TType::STRING, 4);
+ $xfer += $output->writeString($self->{super_column});
$xfer += $output->writeFieldEnd();
}
$xfer += $output->writeFieldStop();
@@ -635,24 +527,37 @@ sub write {
return $xfer;
}
-package Net::Cassandra::Backend::NotFoundException;
-use base('Net::Cassandra::Backend::Thrift::TException');
-use Class::Accessor;
-use base('Class::Accessor');
+package Net::Cassandra::Backend::ColumnPath;
+use base qw(Class::Accessor);
+Net::Cassandra::Backend::ColumnPath->mk_accessors( qw( column_family super_column column ) );
+
sub new {
-my $classname = shift;
-my $self = {};
-my $vals = shift || {};
-return bless($self,$classname);
+ my $classname = shift;
+ my $self = {};
+ my $vals = shift || {};
+ $self->{column_family} = undef;
+ $self->{super_column} = undef;
+ $self->{column} = undef;
+ if (UNIVERSAL::isa($vals,'HASH')) {
+ if (defined $vals->{column_family}) {
+ $self->{column_family} = $vals->{column_family};
+ }
+ if (defined $vals->{super_column}) {
+ $self->{super_column} = $vals->{super_column};
+ }
+ if (defined $vals->{column}) {
+ $self->{column} = $vals->{column};
+ }
+ }
+ return bless ($self, $classname);
}
sub getName {
- return 'Net::Cassandra::Backend::NotFoundException';
+ return 'ColumnPath';
}
sub read {
- my $self = shift;
- my $input = shift;
+ my ($self, $input) = @_;
my $xfer = 0;
my $fname;
my $ftype = 0;
@@ -666,6 +571,24 @@ sub read {
}
SWITCH: for($fid)
{
+ /^3$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
+ $xfer += $input->readString(\$self->{column_family});
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ last; };
+ /^4$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
+ $xfer += $input->readString(\$self->{super_column});
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ last; };
+ /^5$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
+ $xfer += $input->readString(\$self->{column});
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ last; };
$xfer += $input->skip($ftype);
}
$xfer += $input->readFieldEnd();
@@ -675,40 +598,64 @@ sub read {
}
sub write {
- my $self = shift;
- my $output = shift;
+ my ($self, $output) = @_;
my $xfer = 0;
- $xfer += $output->writeStructBegin('Net::Cassandra::Backend::NotFoundException');
+ $xfer += $output->writeStructBegin('ColumnPath');
+ if (defined $self->{column_family}) {
+ $xfer += $output->writeFieldBegin('column_family', Net::Cassandra::Backend::TType::STRING, 3);
+ $xfer += $output->writeString($self->{column_family});
+ $xfer += $output->writeFieldEnd();
+ }
+ if (defined $self->{super_column}) {
+ $xfer += $output->writeFieldBegin('super_column', Net::Cassandra::Backend::TType::STRING, 4);
+ $xfer += $output->writeString($self->{super_column});
+ $xfer += $output->writeFieldEnd();
+ }
+ if (defined $self->{column}) {
+ $xfer += $output->writeFieldBegin('column', Net::Cassandra::Backend::TType::STRING, 5);
+ $xfer += $output->writeString($self->{column});
+ $xfer += $output->writeFieldEnd();
+ }
$xfer += $output->writeFieldStop();
$xfer += $output->writeStructEnd();
return $xfer;
}
-package Net::Cassandra::Backend::InvalidRequestException;
-use base('Net::Cassandra::Backend::Thrift::TException');
-use Class::Accessor;
-use base('Class::Accessor');
-Net::Cassandra::Backend::InvalidRequestException->mk_accessors( qw( why ) );
+package Net::Cassandra::Backend::SliceRange;
+use base qw(Class::Accessor);
+Net::Cassandra::Backend::SliceRange->mk_accessors( qw( start finish reversed count ) );
+
sub new {
-my $classname = shift;
-my $self = {};
-my $vals = shift || {};
-$self->{why} = undef;
+ my $classname = shift;
+ my $self = {};
+ my $vals = shift || {};
+ $self->{start} = undef;
+ $self->{finish} = undef;
+ $self->{reversed} = 0;
+ $self->{count} = 100;
if (UNIVERSAL::isa($vals,'HASH')) {
- if (defined $vals->{why}) {
- $self->{why} = $vals->{why};
+ if (defined $vals->{start}) {
+ $self->{start} = $vals->{start};
+ }
+ if (defined $vals->{finish}) {
+ $self->{finish} = $vals->{finish};
+ }
+ if (defined $vals->{reversed}) {
+ $self->{reversed} = $vals->{reversed};
+ }
+ if (defined $vals->{count}) {
+ $self->{count} = $vals->{count};
}
}
-return bless($self,$classname);
+ return bless ($self, $classname);
}
sub getName {
- return 'Net::Cassandra::Backend::InvalidRequestException';
+ return 'SliceRange';
}
sub read {
- my $self = shift;
- my $input = shift;
+ my ($self, $input) = @_;
my $xfer = 0;
my $fname;
my $ftype = 0;
@@ -723,7 +670,25 @@ sub read {
SWITCH: for($fid)
{
/^1$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
- $xfer += $input->readString(\$self->{why});
+ $xfer += $input->readString(\$self->{start});
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ last; };
+ /^2$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRING) {
+ $xfer += $input->readString(\$self->{finish});
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ last; };
+ /^3$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::BOOL) {
+ $xfer += $input->readBool(\$self->{reversed});
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ last; };
+ /^4$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::I32) {
+ $xfer += $input->readI32(\$self->{count});
} else {
$xfer += $input->skip($ftype);
}
@@ -737,13 +702,27 @@ sub read {
}
sub write {
- my $self = shift;
- my $output = shift;
+ my ($self, $output) = @_;
my $xfer = 0;
- $xfer += $output->writeStructBegin('Net::Cassandra::Backend::InvalidRequestException');
- if (defined $self->{why}) {
- $xfer += $output->writeFieldBegin('why', Net::Cassandra::Backend::TType::STRING, 1);
- $xfer += $output->writeString($self->{why});
+ $xfer += $output->writeStructBegin('SliceRange');
+ if (defined $self->{start}) {
+ $xfer += $output->writeFieldBegin('start', Net::Cassandra::Backend::TType::STRING, 1);
+ $xfer += $output->writeString($self->{start});
+ $xfer += $output->writeFieldEnd();
+ }
+ if (defined $self->{finish}) {
+ $xfer += $output->writeFieldBegin('finish', Net::Cassandra::Backend::TType::STRING, 2);
+ $xfer += $output->writeString($self->{finish});
+ $xfer += $output->writeFieldEnd();
+ }
+ if (defined $self->{reversed}) {
+ $xfer += $output->writeFieldBegin('reversed', Net::Cassandra::Backend::TType::BOOL, 3);
+ $xfer += $output->writeBool($self->{reversed});
+ $xfer += $output->writeFieldEnd();
+ }
+ if (defined $self->{count}) {
+ $xfer += $output->writeFieldBegin('count', Net::Cassandra::Backend::TType::I32, 4);
+ $xfer += $output->writeI32($self->{count});
$xfer += $output->writeFieldEnd();
}
$xfer += $output->writeFieldStop();
@@ -751,24 +730,33 @@ sub write {
return $xfer;
}
-package Net::Cassandra::Backend::UnavailableException;
-use base('Net::Cassandra::Backend::Thrift::TException');
-use Class::Accessor;
-use base('Class::Accessor');
+package Net::Cassandra::Backend::SlicePredicate;
+use base qw(Class::Accessor);
+Net::Cassandra::Backend::SlicePredicate->mk_accessors( qw( column_names slice_range ) );
+
sub new {
-my $classname = shift;
-my $self = {};
-my $vals = shift || {};
-return bless($self,$classname);
+ my $classname = shift;
+ my $self = {};
+ my $vals = shift || {};
+ $self->{column_names} = undef;
+ $self->{slice_range} = undef;
+ if (UNIVERSAL::isa($vals,'HASH')) {
+ if (defined $vals->{column_names}) {
+ $self->{column_names} = $vals->{column_names};
+ }
+ if (defined $vals->{slice_range}) {
+ $self->{slice_range} = $vals->{slice_range};
+ }
+ }
+ return bless ($self, $classname);
}
sub getName {
- return 'Net::Cassandra::Backend::UnavailableException';
+ return 'SlicePredicate';
}
sub read {
- my $self = shift;
- my $input = shift;
+ my ($self, $input) = @_;
my $xfer = 0;
my $fname;
my $ftype = 0;
@@ -782,6 +770,31 @@ sub read {
}
SWITCH: for($fid)
{
+ /^1$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::LIST) {
+ {
+ my $_size7 = 0;
+ $self->{column_names} = [];
+ my $_etype10 = 0;
+ $xfer += $input->readListBegin(\$_etype10, \$_size7);
+ for (my $_i11 = 0; $_i11 < $_size7; ++$_i11)
+ {
+ my $elem12 = undef;
+ $xfer += $input->readString(\$elem12);
+ push(@{$self->{column_names}},$elem12);
+ }
+ $xfer += $input->readListEnd();
+ }
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ last; };
+ /^2$/ && do{ if ($ftype == Net::Cassandra::Backend::TType::STRUCT) {
+ $self->{slice_range} = new Net::Cassandra::Backend::SliceRange();
+ $xfer += $self->{slice_range}->read($input);
+ } else {
+ $xfer += $input->skip($ftype);
+ }
+ last; };
$xfer += $input->skip($ftype);
}
$xfer += $input->readFieldEnd();
@@ -791,10 +804,28 @@ sub read {
}
sub write {
- my $self = shift;
- my $output = shift;
+ my ($self, $output) = @_;
my $xfer = 0;
- $xfer += $output->writeStructBegin('Net::Cassandra::Backend::UnavailableException');
+ $xfer += $output->writeStructBegin('SlicePredicate');
+ if (defined $self->{column_names}) {
+ $xfer += $output->writeFieldBegin('column_names', Net::Cassandra::Backend::TType::LIST, 1);
+ {
+ $output->writeListBegin(Net::Cassandra::Backend::TType::STRING, scalar(@{$self->{column_names}}));
+ {
+ foreach my $iter13 (@{$self->{column_names}})
+ {
+ $xfer += $output->writeString($iter13);
+ }
+ }
+ $output->writeListEnd();
+ }
+ $xfer += $output->writeFieldEnd();
+ }
+ if (defined $self->{slice_range}) {
+ $xfer += $output->writeFieldBegin('slice_range', Net::Cassandra::Backend::TType::STRUCT, 2);
+ $xfer += $self->{slice_range}->write($output);
+ $xfer += $output->writeFieldEnd();
+ }
$xfer += $output->writeFieldStop();
$xfer += $output->writeStructEnd();
return $xfer;
Please sign in to comment.
Something went wrong with that request. Please try again.