Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added longtype + example, fixed a unit test fail on core during connect
- Loading branch information
Showing
4 changed files
with
157 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,59 @@ | |||
<?php | |||
/** | |||
* Example LongType ColumnFamily vs default Cassandra storage-conf.xml | |||
* | |||
* <ColumnFamily Name="StandardByLong1" CompareWith="LongType" /> | |||
* | |||
* Script performs a save, plus two cross checks - loading directly from an | |||
* anonymous columnfamily model, and populating a model from a slice. | |||
* | |||
*/ | |||
|
|||
require_once('../config.php'); | |||
|
|||
PandraCore::connectSeededKeyspace('localhost'); | |||
|
|||
$ks = 'Keyspace1'; | |||
$cfName = 'StandardByLong1'; | |||
$keyID = 'PandraTestLong1'; | |||
|
|||
$cf = new PandraColumnFamily($keyID, $ks, $cfName, PandraColumnFamily::TYPE_LONG); | |||
|
|||
$cf->addColumn(PandraCore::getTime())->setValue('numericly indexed!'); | |||
echo 'Saving...<br>'; | |||
print_r($cf->toJSON()); | |||
$cf->save(); | |||
|
|||
// load from model | |||
echo '<br><br>Loading via CF container...<br>'; | |||
$cfNew = new PandraColumnFamily($keyID, $ks, $cfName, PandraColumnFamily::TYPE_LONG); | |||
|
|||
$cfNew->limit(5)->load(); | |||
echo '<br>Loaded...<br>'; | |||
print_r($cfNew->toJSON()); | |||
|
|||
// get slice | |||
echo '<br><br>Loading Slice...<br>'; | |||
$result = PandraCore::getCFSlice($ks, | |||
$keyID, | |||
new cassandra_ColumnParent(array( | |||
'column_family' => $cfName | |||
)), | |||
new PandraSlicePredicate( | |||
PandraSlicePredicate::TYPE_RANGE, | |||
array('start' => '', | |||
'finish' => '', | |||
'count' => 5, | |||
'reversed' => true)) | |||
); | |||
|
|||
var_dump($result); | |||
|
|||
$cfNew = new PandraColumnFamily($keyID, $ks, $cfName, PandraColumnFamily::TYPE_LONG); | |||
|
|||
$cfNew->populate($result); | |||
|
|||
echo '<br>Imported...<br>'; | |||
print_r($cfNew->toJSON()); | |||
|
|||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters