我在cassandra中有一个键空间,其中columnfamily(让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行?
答案 0 :(得分:0)
Multiget没有订购保证,完全停止。至于如何获得超过100行...你问的是错误的问题,大型多项目是反模式。您需要进行非规范化,以便您可以使用单个切片获得所需的数据。在这里查看我的“时间轴”示例:http://www.datastax.com/dev/blog/schema-in-cassandra-1-1