cassandra - How to create super column using Hector API? -
my code:
public class insertsupercolumn { private static stringserializer stringserializer = stringserializer.get(); public static void main(string[] args) throws exception { cluster cluster = hfactory.getorcreatecluster("testcluster", "localhost:9160"); keyspace keyspaceoperator = hfactory.createkeyspace("keyspace1", cluster); try { mutator<string> mutator = hfactory.createmutator(keyspaceoperator, stringserializer); mutator.insert("billing", "super1", hfactory.createsupercolumn("jsmith", arrays.aslist(hfactory.createstringcolumn("first", "john")), stringserializer, stringserializer, stringserializer)); supercolumnquery<string, string, string, string> supercolumnquery = hfactory.createsupercolumnquery(keyspaceoperator, stringserializer, stringserializer, stringserializer, stringserializer); supercolumnquery.setcolumnfamily("super1").setkey("billing").setsupername("jsmith"); queryresult<hsupercolumn<string, string, string>> result = supercolumnquery.execute(); system.out.println("read hsupercolumn cassandra: " + result.get()); system.out.println("verify on cli with: keyspace1.super1['billing']['jsmith'] "); } catch (hectorexception e) { e.printstacktrace(); } cluster.getconnectionmanager().shutdown(); } } i getting error :
exception in thread "main" me.prettyprint.hector.api.exceptions.hinvalidrequestexception: invalidrequestexception(why:keyspace names must case-insensitively unique ("new2" conflicts "new2"))
the problem creating keyspace , column family store super column multiple times. cant that, keyspaces , column families must uniquely named. exception telling you:
why:keyspace names must case-insensitively unique ("new2" conflicts "new2") so far code concerned, have created supercolumn correctly. try verifying using cassandra cli.
Comments
Post a Comment