2010-03-15 106 views
4

假设以下数据集:Cassandra API相当于“SELECT ... FROM ... WHERE id IN('...','...','...');”

id  age city  phone 
==  === ====  ===== 
alfred 30 london 3281283 
jeff  43 sydney 2342734 
joe  29 tokyo  1283881 
kelly 54 new york 2394929 
molly 20 london 1823881 
rob  39 sydney 4928381 

得到以下结果集..

id  age phone 
==  === ===== 
alfred 30 3281283 
joe  29 1283881 
molly 20 1823881 

..用SQL一个会发出..

SELECT id, age, phone FROM dataset WHERE id IN ('alfred', 'joe', 'molly'); 

什么是相应的Cassandra API调用会在一个命令中产生相同的结果集?

+1

除了jbellis答案:客户节俭在API部分的Cassandra维基页面上很好地解释了API:http://wiki.apache.org/cassandra/API – Schildmeijer 2010-03-15 15:19:39

回答

4

如下所述,你会做一个multiget_slice W /阿尔弗雷德,乔,莫莉和ID,年龄,电话的SlicePredicate COLUMN_NAMES的键

2

一个卡桑德拉相当于可以近似:

Users = { //this is a ColumnFamily 
    "alfred": { //this is the key to this Row inside the CF 
    "age":"30", 
    "city":"london", 
    "phone":"3281283" 
    }, // end row 
    // more rows... 
} 

其中“alfred”是你的(行)键,该行有三列;年龄,城市和电话。 (省略时间戳字段(为简单起见)为三列)

相关问题