Pankas
Pankas

Reputation: 137

phpcassa: cassandra\NotFoundException when instantiating ColumnFamily class

I'm trying to query a Cassandra 2.0.2 server using the phpcassa libraray.

I do the following:

<?php

require('phpcassa/lib/autoload.php');

use phpcassa\ColumnFamily;
use phpcassa\ColumnSlice;
use phpcassa\Connection\ConnectionPool;

$pool = new ConnectionPool('Cronnection', array('MY_SERVER_IP:9160'));

$conversations = new ColumnFamily($pool, 'conversations');

var_dump( $conversations->get('2521b0f0-8e36-11e3-a489-8f038e859082') );

When I do this I get an uncaught 'cassandra\NotFoundException' exception.

After reading in the source I see that this is because the column family 'conversations' is not getting loaded into the cloumn families array created by the ConnectionPool::describe_keyspace() method.

When I print the result of "describe_keyspace", using the following code, I can see that only one of my column families, called user_profiles, is getting loaded into my column families array.

<?php

require('phpcassa/lib/autoload.php');

use phpcassa\ColumnFamily;
use phpcassa\ColumnSlice;
use phpcassa\Connection\ConnectionPool;

$pool = new ConnectionPool('Cronnection', array('MY_SERVER_IP:9160'));

echo '<pre>';
var_dump($pool->describe_keyspace());

There are 6 column families defined in that keyspace but phpcassa is only listing "user_profiles"; the only difference between "user_profiles" and the other CFs is that "user_profiles" is using the "WITH COMPACT STORAGE" property.

Any thoughts on how to solve this or why is this happenning?

Thanks!

PS: I created the column families using CQL3 through cqlsh, when I do "describe" using cassandra-cli I can't see my column families, only the "user_profiles" one that I mentioned, could this somehow be related?

Upvotes: 0

Views: 737

Answers (1)

Tyler Hobbs
Tyler Hobbs

Reputation: 6932

Yes, this is in fact related to COMPACT STORAGE and cassandra-cli not showing your other column families. phpcassa and other Thrift-based clients (such as cassandra-cli) can only use tables created through CQL3 if they are created WITH COMPACT STORAGE.

In short, I suggest sticking to COMPACT STORAGE tables if you will be working with phpcassa. If you want to read more, there is a somewhat advanced article that shows explains how Thrift, CQL3 and compact storage fit together.

Upvotes: 2

Related Questions