cassandra-thrift-1.1.2.jar
问题代码:
ColumnOrSuperColumn cosc = null;
org.apache.cassandra.thrift.Column c = new org.apache.cassandra.thrift.Column ();
c.setName("full_name".getBytes("UTF-8"));
c.setValue("测试名称".getBytes("UTF-8"));
c.setTimestamp (System.currentTimeMillis());
// 插入数据
// 长时间戳 = System.currentTimeMillis();
尝试 {
client.set_keyspace("CClient");
bb=ByteBuffer.allocate (10);
client.insert (bb.putInt(1),
新的 ColumnParent(“用户”),
C,
一致性级别.QUORUM);
bb.putInt(2);
cosc = client.get (bb, cp, ConsistencyLevel.QUORUM);
}
捕捉(TimedOutException 脚趾){
System.out.println(toe.getMessage());
}
捕捉(org.apache.cassandra.thrift.UnavailableException e){
// TODO 自动生成的 catch 块
e.printStackTrace();
}
捕获(异常 e){
e.printStackTrace();
}
最后 {
System.out.println(new String (cosc.getColumn().getName()) + "-" + new String (cosc.getColumn().getValue()));
}
上面显示的代码在数据库中插入了一些垃圾或空值,我不明白为什么?
在 CLI 上查看它的外观:
行键: =>(列=全名,值=测试名称,时间戳=1345743985973)
非常感谢您对此的任何帮助。
谢谢。