hallo guys, i have a question about cqlsh3.0 and cassandra-cli. (cassandra version 1.2.1)
i have created a table use cqlsh -3 and insert some data in it. However i got a error when i trying to use thrift api +java insert some information. Exception in thread "main" InvalidRequestException(why:Not enough bytes to read value of component 0)
then i created a same keyspace with identisch column family by using cassandra-cli.. it works... why? dose it mean, thrif api can not get access to the keyspace which created by cqlsh 3.0?
the code: quite simple
TTransport tr = new TSocket(HOST, PORT);
TFramedTransport tf = new TFramedTransport(tr);
TProtocol proto = new TBinaryProtocol(tf);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
String Key_user_id = "userno1";
long timestamp = System.currentTimeMillis();
client.set_keyspace("schema1"); // schema1 was created by cqlsh, got error, then i changed to schema created by cassandra-cli, it works....
ColumnParent parent = new ColumnParent("users");
Column first_Column = new Column(toByteBuffer("first"));
first_Column = setColumn(first_Column, "testjava", timestamp);
client.insert(toByteBuffer(Key_user_id), parent, first_Column, CL);
Column last_idColumn = new Column(toByteBuffer("last"));
last_idColumn = setColumn(last_idColumn, "javatest", timestamp);
client.insert(toByteBuffer(Key_user_id), parent, last_idColumn, CL);
Column age_Column = new Column(toByteBuffer("age"));
age_Column = setColumn(age_Column, "333", timestamp);
client.insert(toByteBuffer(Key_user_id), parent, age_Column, CL);
tr.close();
