我正在使用此代码获取 user_id 和 user_code
Keyspace keyspace = HFactory.createKeyspace("test", cluster);
CqlQuery<String,String,ByteBuffer> cqlQuery = new CqlQuery<String,String,ByteBuffer>(keyspace, stringSerializer, stringSerializer, new ByteBufferSerializer());
cqlQuery.setQuery("select user_id,user_code from User");
QueryResult<CqlRows<String,String,ByteBuffer>> result = cqlQuery.execute();
Iterator iterator = result.get().iterator();
while(iterator.hasNext()) {
Row<String, String, ByteBuffer> row = (Row<String, String, ByteBuffer>) iterator.next();
System.out.println("\nInserted data is as follows:\n" + row.getColumnSlice().getColumns().get(0).getValue().getInt());
System.out.println("\nInserted data is as follows:\n" + Charset.forName("UTF-8").decode(row.getColumnSlice().getColumns().get(1).getValueBytes()));
}
现在问题出在这里,我正在根据它们的特定类型转换字段
如果查询是随机的怎么办?如何处理这种情况?