Can't get contents of slice from supercolumns

3 views
Skip to first unread message

Noah

unread,
Sep 2, 2010, 3:51:30 PM9/2/10
to pandra-user
Hi,

I'm stuck on a query.

I want to get all the columns within a supercolumn.

I'm using the following (from the examples.) but can't find a way to
then iterate through the results to get the actual columns.

-----------------------------------------------------------
$results = PandraCore::getCFSlice($ks,
$keyID,
new cassandra_ColumnParent(
array(
'column_family' => $cfName,
'super_column' => $tag
)
),
new PandraSlicePredicate(
PandraSlicePredicate::TYPE_RANGE,
array('start' => '',
'finish' => '',
'count' => 5,
'reversed' => true
)
)
);

foreach($results as $result){

-----------------------------------------------------

mjpearson

unread,
Sep 2, 2010, 6:02:48 PM9/2/10
to pandra-user
The easiest way to pull out a range of columns in a supercolumn would
be to use an anonymous supercolumn object - it will build the proper
predicate etc. for you and there'll be no need to deal with Thrift
directly.

so something like :

// Create the supercolumn that's aware of its name ($tag), it's key
($keyId) and keyspace ($ks)
$sc = new PandraSuperColumn($tag, $keyId, $ks);
// Bind it to a column family
$sc->setColumnFamilyName($cfName);
// predicate shortcuts... reversed, limit 5
$sc->limit(5)->reverse()->load();

// You can then iterate over the supercolumn as if it were an array...
// columns etc. can be changed/saved independently
foreach ($sc as $column) {
echo "$column->getName() timestamp is $column->timestamp value
$column->getValue()<br>";
var_dump($column);
}

... should work for you. FYI there's a few methods for retrieving
SuperColumns detailed in the UUID examples (http://github.com/
mjpearson/Pandra/blob/master/examples/uuid_supercolumn.class.php)
which might also help.

-michael
Reply all
Reply to author
Forward
0 new messages