Skip to content

Commit

Permalink
Upgrade phpcassa
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastien Giroux committed Nov 8, 2012
1 parent 41b6b7e commit 9890064
Show file tree
Hide file tree
Showing 8 changed files with 1,094 additions and 1,070 deletions.
1,073 changes: 1,073 additions & 0 deletions include/phpcassa/AbstractColumnFamily.php

Large diffs are not rendered by default.

1,057 changes: 1 addition & 1,056 deletions include/phpcassa/ColumnFamily.php

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion include/phpcassa/Schema/DataType/CompositeType.php
Expand Up @@ -29,7 +29,8 @@ public function pack($value, $is_name=true, $slice_end=null, $is_data=false) {
$item = $value[$i];
$eoc = 0x00;
if (is_array($item)) {
list($item, $inclusive) = $item;
list($actual_item, $inclusive) = $item;
$item = $actual_item;
if ($inclusive) {
if ($slice_end == ColumnFamily::SLICE_START)
$eoc = 0xFF;
Expand Down
4 changes: 2 additions & 2 deletions include/phpcassa/Schema/DataType/DoubleType.php
Expand Up @@ -13,11 +13,11 @@ class DoubleType extends CassandraType implements Serialized
public function pack($value, $is_name=true, $slice_end=null, $is_data=false) {
if ($is_name && $is_data)
$value = unserialize($value);
return pack("d", $value);
return strrev(pack("d", $value));
}

public function unpack($data, $is_name=true) {
$value = current(unpack("d", $data));
$value = current(unpack("d", strrev($data)));
if ($is_name) {
return serialize($value);
} else {
Expand Down
4 changes: 2 additions & 2 deletions include/phpcassa/Schema/DataType/FloatType.php
Expand Up @@ -13,11 +13,11 @@ class FloatType extends CassandraType implements Serialized
public function pack($value, $is_name=true, $slice_end=null, $is_data=false) {
if ($is_name && $is_data)
$value = unserialize($value);
return pack("f", $value);
return strrev(pack("f", $value));
}

public function unpack($data, $handle_serialize=true) {
$value = current(unpack("f", $data));
$value = current(unpack("f", strrev($data)));
if ($handle_serialize) {
return serialize($value);
} else {
Expand Down
10 changes: 7 additions & 3 deletions include/phpcassa/Schema/DataType/IntegerType.php
Expand Up @@ -12,6 +12,7 @@ class IntegerType extends CassandraType {

public function pack($value, $is_name=null, $slice_end=null, $is_data=null)
{
$value = (int)$value;
$out = array();
if ($value >= 0) {
while ($value >= 256) {
Expand All @@ -28,10 +29,13 @@ public function pack($value, $is_name=null, $slice_end=null, $is_data=null)
$out[] = pack('C', 0xff & ~$value);
$value >>= 8;
}
if ($value <= 127)
if ($value <= 127) {
$out[] = pack('C', 0xff & ~$value);
else
$out[] = pack('n', 0xffff & ~$value);
} else {
$top = pack('n', 0xffff & ~$value);
// we have two bytes, need to reverse them
$out[] = strrev($top);
}
}

return strrev(implode($out));
Expand Down
12 changes: 7 additions & 5 deletions include/phpcassa/SuperColumnFamily.php
Expand Up @@ -2,6 +2,7 @@
namespace phpcassa;

use phpcassa\ColumnFamily;
use phpcassa\ColumnSlice;

use cassandra\Deletion;
use cassandra\ColumnParent;
Expand All @@ -20,7 +21,7 @@
*
* @package phpcassa
*/
class SuperColumnFamily extends ColumnFamily {
class SuperColumnFamily extends AbstractColumnFamily {

/**
* Fetch a single super column.
Expand Down Expand Up @@ -98,7 +99,8 @@ public function get_subcolumn_count($key,
$consistency_level=null) {

$cp = $this->create_column_parent($super_column);
$slice = $this->create_slice_predicate($column_names, $column_slice);
$slice = $this->create_slice_predicate(
$column_names, $column_slice, ColumnSlice::MAX_COUNT);

return $this->_get_count($key, $cp, $slice, $consistency_level);
}
Expand All @@ -123,7 +125,8 @@ public function multiget_subcolumn_count($keys,
$consistency_level=null) {

$cp = $this->create_column_parent($super_column);
$slice = $this->create_slice_predicate($column_names, $column_slice);
$slice = $this->create_slice_predicate(
$column_names, $column_slice, ColumnSlice::MAX_COUNT);

return $this->_multiget_count($keys, $cp, $slice, $consistency_level);
}
Expand Down Expand Up @@ -225,8 +228,7 @@ public function remove_super_column($key, $super_column, $subcolumns=null,
$deletion = new Deletion();
$deletion->super_column = $this->pack_name($super_column, true);
if ($subcolumns !== null) {
$predicate = $this->create_slice_predicate($subcolumns, '', '', false,
self::DEFAULT_COLUMN_COUNT);
$predicate = $this->create_slice_predicate($subcolumns, null);
$deletion->predicate = $predicate;
}
return $this->_remove_multi($key, $deletion, $consistency_level);
Expand Down
1 change: 0 additions & 1 deletion include/phpcassa/SystemManager.php
Expand Up @@ -142,7 +142,6 @@ protected function make_ksdef($name, $attrs, $orig=NULL) {
if (strpos($value, ".") === false)
$value = "org.apache.cassandra.locator.$value";
$ksdef->strategy_class = $value;
break;
} else {
$ksdef->$attr = $value;
}
Expand Down

0 comments on commit 9890064

Please sign in to comment.