0

我在 cassandra 中有一个键空间,其列族(让 A)具有复合键另一个列族(让 B)我正在存储存在于 A 列族中的确切行数。当我使用 multiget 获取数据时,它没有给出实际的排序数据。

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";

我的代码

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);
}

它给出的输出为

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

它以混乱的顺序给出输出......如何以排序方式获得?以及如何获得超过 100 行?

4

1 回答 1

0

Multiget 不做任何订购保证,完全停止。至于如何获得超过 100 行......你问错了问题,大型 multigets 是一种反模式。您需要进行非规范化,以便您可以使用单个切片获取所需的数据。在此处查看我的“时间线”示例:http ://www.datastax.com/dev/blog/schema-in-cassandra-1-1

于 2012-09-28T19:20:56.620 回答