0

I have a keyspace in cassandra with columnfamily(let A) which is having composite key another column family(let B) i am storing an exact number of rows which exist in the A column family. when i am fetching the data using multiget it's not giving the actual sorted data.

A: [1] = 13;

B:
   [6014:2:0] = "aaaaaa";
   [6014:2:1] = "bbbbbb";
   [6014:2:2] = "cccccc";
   [6014:2:3] = "dddddd";
   [6014:2:4] = "eeeeee";
   [6014:2:5] = "ffffff";
   [6014:2:6] = "gggggg";
   [6014:2:7] = "hhhhhh";
   [6014:2:8] = "iiiiii";
   [6014:2:9] = "jjjjjj";
   [6014:2:10] = "kkkkkkk";
   [6014:2:11] = "lllllll";
   [6014:2:12] = "mmmmmmm";

my code

require_once(__DIR__.'/phpcassa/lib/autoload.php');
use phpcassa\Connection\ConnectionPool;
use phpcassa\ColumnFamily;
use phpcassa\SystemManager;
use phpcassa\Schema\StrategyClass;

$connection = new ConnectionPool('KEYSPACE', array('XXXX', 'YYYY', 'ZZZZ'));
$numDtls = new ColumnFamily($connection, 'A');
$key = 1;
$num_details = $numDtls->get($key);
$num = $num_details;

$json = '';
$key_array = array();
if(isset($num)){
    $str = new ColumnFamily($connection, 'B');
    for($i = 0;$i <= $num; $i++){
        $key_array[] = array($table, $flag, $i);
    }

    $detail = $str->multiget($key_array);
    $json = json_encode($detail);
}

its giving the output as

6014:2:0
6014:2:6
6014:2:9
6014:2:11
6014:2:4
6014:2:1
6014:2:12
6014:2:8
6014:2:7
6014:2:10
6014:2:3
6014:2:5
6014:2:2

it giving output in jumbled order... How to get in sorted manner? And how to get more than 100 rows?

Priya
  • 1,522
  • 1
  • 14
  • 31
  • Just for future reference, take a look at the changes I made in your question for formatting. It will probably help you format your questions in a friendlier format in the future :) – Fluffeh Sep 27 '12 at 10:01

1 Answers1

0

Multiget makes no ordering guarantees, full stop. As to how to get more than 100 rows... you're asking the wrong question, large multigets are an antipattern. You need to denormalize so you can get the data you want with a single slice, instead. Check out my "timeline" example here: http://www.datastax.com/dev/blog/schema-in-cassandra-1-1

jbellis
  • 19,347
  • 2
  • 38
  • 47