Permalink
Browse files

Fixed issued #1 and #2

- integer columns handled correctly
- special character strings unpacked correctly
  • Loading branch information...
1 parent 78de67e commit 6b700a8fb4b1ea3098b50ee209f6548acf2c17fa @kallaspriit kallaspriit committed with Aug 15, 2011
Showing with 28 additions and 15 deletions.
  1. +4 −12 Cassandra.php
  2. +1 −1 README
  3. +23 −2 test/CassandraTest.php
View
@@ -2312,15 +2312,13 @@ public function getMultiple(
for ($i = 0; $i < $setCount; $i++) {
$setKeys = array_slice($keys, $i * $bufferSize, $bufferSize);
- $setResponse = $this->cassandra->call(
+ $responses += $this->cassandra->call(
'multiget_slice',
$setKeys,
$columnParent,
$slicePredicate,
$consistency
);
-
- $responses = array_merge($responses, $setResponse);
}
foreach ($responses as $key => $response) {
@@ -2947,10 +2945,7 @@ public function parseSlicesResponse(array $responses) {
$results[$key] = array();
foreach ($row->columns as $row) {
- $results[$key] = array_merge(
- $results[$key],
- $this->parseSliceRow($row)
- );
+ $results[$key] += $this->parseSliceRow($row);
}
}
@@ -2970,10 +2965,7 @@ public function parseSliceResponse(array $response) {
$results = array();
foreach ($response as $row) {
- $results = array_merge(
- $results,
- $this->parseSliceRow($row)
- );
+ $results += $this->parseSliceRow($row);
}
return $results;
@@ -3283,7 +3275,7 @@ public static function unpackInteger($value) {
* @return string Unpacked data
*/
public static function unpackString($value, $length) {
- $unpacked = unpack('c'.$length.'chars', $value);
+ $unpacked = unpack('C'.$length.'chars', $value);
$out = '';
foreach($unpacked as $element) {
View
2 README
@@ -25,7 +25,7 @@ The following example covers most of what you need to know to use this library.
It should work out-of-box on a machine with default cassandra setup running. The
example file is contained in the download.
-Open https://github.com/kallaspriit/Cassandra-PHP-Client/blob/master/example.php
+Open https://github.com/kallaspriit/Cassandra-PHP-Client-Library/blob/master/example.php
for prettier code.
<?php
View
@@ -536,6 +536,26 @@ public function testStoresAndFetchesStandardColumns() {
);
}
+ public function testSpecialCharactersAreProperlyUnpacked() {
+ $this->cassandra->set(
+ 'user.special',
+ array(
+ 'email' => 'Jèna@grùber.com',
+ 'name' => 'Jèna Grùber',
+ 'age' => 41
+ )
+ );
+
+ $this->assertEquals(
+ array(
+ 'email' => 'Jèna@grùber.com',
+ 'name' => 'Jèna Grùber',
+ 'age' => 41
+ ),
+ $this->cassandra->get('user.special')
+ );
+ }
+
/**
* @expectedException CassandraInvalidPatternException
*/
@@ -861,8 +881,8 @@ public function testRowColumnsCanBeCounted2() {
);
}
- //* Run only with
- // * partitioner: org.apache.cassandra.dht.CollatingOrderPreservingPartitioner
+ /* Run only with partitioner:
+ * org.apache.cassandra.dht.CollatingOrderPreservingPartitioner
public function testKeysCanBeFetchedByRange() {
$expected = array();
$expected2 = array();
@@ -891,6 +911,7 @@ public function testKeysCanBeFetchedByRange() {
$this->assertEquals($expected, $results);
}
+ */
public function testKeysCanBeFetchedByRange2() {
$expected = array();

0 comments on commit 6b700a8

Please sign in to comment.