PandraCore::getRangeKeys()

10 views
Skip to first unread message

loretoparisi

unread,
Sep 2, 2010, 7:13:18 AM9/2/10
to pandra-dev
Hi,
I'm trying to get the range keys with

PandraCore::getRangeKeys()

such this

$res=PandraCore::getRangeKeys(
'MyKeyspace1',
array('start' => '0', 'finish' => '10'),
new cassandra_ColumnParent(array(
'column_family' => 'MyCF',
)),
new PandraSlicePredicate(
PandraSlicePredicate::TYPE_RANGE,
array('start' => '0',
'finish' => '10',
'count' => 10,
'reversed' => false))
);

but getting no results.

What's wrong with the code ?

I found out the usage of the function looking at its definition in
Core.class.php, but I'm probabily wrong with the SlicePredicate usage
here.

Any hint?

loretoparisi

unread,
Sep 2, 2010, 7:58:09 AM9/2/10
to pandra-dev
I tried also this way as stated by mjpearson in a previous post

// an 'anonymous' column family
$cf = new PandraColumnFamily('', 'MyKeyspace1', 'MyCF');
$cf->setAutoCreate(TRUE);
$start = '';
while ($cf->start($start)->limit(10)->load()) {
foreach ($cf as $column) {
// render the column for example
echo $column->getName();
}
$start = $cf->current()->getName();

}

but having not column.
The aim was data to be retrieved both by object key and reference key.

loretoparisi

unread,
Sep 2, 2010, 10:10:03 AM9/2/10
to pandra-dev
I was able to go further on this issue,

doing (I want a slice of last 5 items starting from the most recent):

$result=PandraCore::getRangeKeys(
'MyKeyspace',
array('start'=>'','finish'=>''),
new cassandra_ColumnParent(array(
'column_family' => 'MyCF',
)),
new PandraSlicePredicate(
PandraSlicePredicate::TYPE_RANGE,
array('start' => '',
'finish' => '',
'count' => 5,
'reversed' => true))
);


having:

object(cassandra_KeySlice)#249 (2) { ["key"]=> string(9) "loreto
parisi" ["columns"]=> array(3) { [0]=>
object(cassandra_ColumnOrSuperColumn)#250 (2) { ["column"]=>
object(cassandra_Column)#251 (3) { ["name"]=> string(16) "ÿÿÿÿ
°t ß rcasscl" ["value"]=> string(32)
"87bae9fc66be69a9652e0c7770de1a4c" ["timestamp"]=>
float(1.28343930726E+15) } ["super_column"]=> NULL } [1]=>
object(cassandra_ColumnOrSuperColumn)#252 (2) { ["column"]=>
object(cassandra_Column)#253 (3) { ["name"]=> string(16) "ÿÿÿÿ¯–
߸Åcasscl" ["value"]=> string(32)
"e133e1e311ca9dcc9670691e0f88fd44" ["timestamp"]=>
float(1.28343930726E+15) } ["super_column"]=> NULL } [2]=>
object(cassandra_ColumnOrSuperColumn)#254 (2) { ["column"]=>
object(cassandra_Column)#255 (3) { ["name"]=> string(16) "ÿÿÿÿ¯– ß
¤casscl" ["value"]=> string(32)
"feb1bff670750345fa9da9f7b558b054" ["timestamp"]=>
float(1.28343930726E+15) } ["super_column"]=> NULL } } }

This seems to be a KeySlice object array.

Tried to access the object by populating a new column family, but
getting errors like:

$myNewCf->populate($result);

Uncaught exception 'RuntimeException' with message 'Column Name (0)
cannot be converted'

Maybe I have to access those elements directly?
Reply all
Reply to author
Forward
0 new messages