我需要根据行键读取 cassandra 列族中的所有值。我只得到一个行键。我想查询列族中的所有键。
列族的架构
rowKey 是字符串,值在列名本身中,例如 date:subject:marks 即在 db 2013-04-13 00:00:00 UTC,science,99 中保存为 rowkey=1
像这样尝试
Cluster cluster = HFactory.getOrCreateCluster("Test Cluster", "localhost:9160");
Keyspace keyspaceOperator = HFactory.createKeyspace(student, cluster);
System.out.println( "Connected to cassandra " + cluster);
String rowKey = "1";
SliceQuery<String,String,String> columnQuery = HFactory.createSliceQuery(keyspaceOperator, StringSerializer.get(), StringSerializer.get(), StringSerializer.get());
columnQuery.setColumnFamily("studentInfo").setKey(rowKey).setRange(null, null, false, 100);
System.out.println(columnQuery);
QueryResult<ColumnSlice<String,String>> result = columnQuery.execute();
for (HColumn<String, String> column : result.get().getColumns()) {
System.out.println(column.getName());
}