问题
I can create a new SuperColumn that has Columns - no problem. I can create a new Column - no problem. But how do I add a new Column to an existing SuperColumn?
回答1:
But how do I add a new Column to an existing SuperColumn?
You should really look into the class SuperCfTemplate
and class SuperCfUpdater
in hector. Once they are initialize, do what is needed (example in your question, add a new cf within this scf), then update the changes using the template. Below are a snippet.
SuperCfTemplate<String, String, String> template = new ThriftSuperCfTemplate<String, String, String>(keyspace, "Super1", stringSerializer, stringSerializer, stringSerializer);
SuperCfUpdater<String, String, String> updater = template.createUpdater("key", "newcf");
updater.setString("subname", "1");
template.update(updater);
来源:https://stackoverflow.com/questions/10047346/hector-cassandra-how-do-i-add-a-column-to-an-existing-supercolumn