我使用此代碼獲取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()));
}
現在問題就出在這裏,我根據自己的具體類型
如果什麼查詢會隨機變換等領域?如何處理這種情況?
Plz嘗試使用不同的BufferSerialezer而不是ByteBufferSerializer,通過這個u將始終獲取字節流中的所有數據,嘗試從數據庫中提取數據以其存儲的實際格式。 – 2013-02-22 12:10:50