i need read values in cassandra column family according row key. getting 1 row key. want query keys in column family.
schema of column family
rowkey string , values in column names date:subject:marks i.e saved in db 2013-04-13 00:00:00 utc,science,99 rowkey=1
trying this
cluster cluster = hfactory.getorcreatecluster("test cluster", "localhost:9160"); keyspace keyspaceoperator = hfactory.createkeyspace(student, cluster); system.out.println( "connected 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(); (hcolumn<string, string> column : result.get().getcolumns()) { system.out.println(column.getname()); }
can try this???
slicequery<string,string,string> columnquery = hfactory.createslicequery(ksp, stringserializer.get(), stringserializer.get(), stringserializer.get()); columnquery.setcolumnfamily("studentinfo").setkey(rowkey).setcolumnnames("id","name"); queryresult<columnslice<string,string>> result = columnquery.execute();
Comments
Post a Comment