-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
I'm a newbie to Pandra.
How about data retrieval?
I'm using these techniques by now:
Suppose to have this array
$myArrayKeyValues = array(
'key1' => 'val1',
'key2' => 'val2',
);
// 1. Clause plugins extensions
class PandraClauseInAddon extends PandraClauseIn {
public function match($value) {
// you can implement here your matching logic
return ( in_array($value, $this->getValueIn()) );
}
}
And then apply the plugin to a key name array to retrieve all keys
$matches=$someSuperColumn->getColumn(
new PandraClauseInAddon(
array_keys( $myArrayKeyValues ) )
);
// 2. Slicing - you'love it! Look at Pandra Examples
$result = PandraCore::getCFSlice($ks,
$keyID,
new cassandra_ColumnParent(array(
'column_family' => $cfName,
)),
new PandraSlicePredicate(
PandraSlicePredicate::TYPE_RANGE,
array('start' => '0',
'finish' => '10',
'count' => 5,
'reversed' => true))
);
NOTE: Due to a bug in previous 0.6.3 Cassandra binaries , you've got an error if you don't specifiy 'start' and 'finish' values when comparing UUID types (CompareWith="TimeUUIDType"). That (fixed) bug described here: https://issues.apache.org/jira/browse/CASSANDRA-377
// 3. Iterating over columns to match inner values. I really hate this!
$subColumns=$col->getColumns(); // get sub - columns
foreach($subColumns as $sub) {
if ( in_array($sub->getValue(),$myArrayKeyValues) ) {
// found some item
}
}
// Best ways to match values / retrieve keys using great Pandra functionalities?
Metadata
Metadata
Assignees
Labels
No labels