cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kevin Withnall <>
Subject PHP access to get or get_slice
Date Mon, 04 Oct 2010 04:02:40 GMT
I've just installed the latest version of cassandra (0.7.0 beta 2) and
re-made the relevant thrift libraries.

There doesn't seem to be many php examples around so i'm struggling to
get something basic to work. I had it working under 0.6.0 but had
other issues hence the upgrade.

I've tried to execute 'get' as well as get_slice but theres something
im missing i think. the cassandra cli will show the data thats
inserted as the first part of this but I can't read it back.

[default@Keyspace1] get Standard1['1']
=> (column=656d61696c,, timestamp=1286162622)
Returned 1 results.

The error I get from php is
exception 'TProtocolException' with message 'Bad type in structure.'

Any ideas would be really appreciated.

--- cut here ---
    $GLOBALS['THRIFT_ROOT'] = '/var/www/cassandra';
    require_once $GLOBALS['THRIFT_ROOT'].'/packages/cassandra/Cassandra.php';
    require_once $GLOBALS['THRIFT_ROOT'].'/transport/TSocket.php';
    require_once $GLOBALS['THRIFT_ROOT'].'/protocol/TBinaryProtocol.php';
    require_once $GLOBALS['THRIFT_ROOT'].'/transport/TFramedTransport.php';
    require_once $GLOBALS['THRIFT_ROOT'].'/transport/TBufferedTransport.php';

    // Make a connection to the Thrift interface to Cassandra
    $socket = new TSocket("", 9160);
    $transport = new TFramedTransport($socket, 10240, 10240);
    $protocol = new TBinaryProtocolAccelerated($transport);
    $client = new CassandraClient($protocol);

    $col = new cassandra_Column();

    $columnParent = new cassandra_ColumnParent();
    $columnParent->column_family = "Standard1";
    $columnParent->super_column = NULL;

    $consistency_level = cassandra_ConsistencyLevel::ZERO;
    $retval=$client->insert($key, $columnParent, $col, $consistency_level);

    $sliceRange = new cassandra_SliceRange();
    $sliceRange->start = '';
    $sliceRange->finish = '';
    $predicate = new cassandra_SlicePredicate();
    $predicate->slice_range = $sliceRange;
    $consistency_level = cassandra_ConsistencyLevel::ONE;
    $result = $client->get_slice("Keyspace1", $key, $columnParent,
$predicate, $consistency_level);
--- cut here ---

View raw message