Hector / Cassandra:如何向现有SuperColumn添加列? [英] Hector/Cassandra: How do I add a Column to an existing SuperColumn?
问题描述
我可以创建一个新的SuperColumn有列 - 没有问题。我可以创建一个新的列 - 没有问题。但是如何向现有的SuperColumn添加新的列?
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?
推荐答案
一个新列到现有的SuperColumn?
But how do I add a new Column to an existing SuperColumn?
你应该真正看看 SuperCfTemplate
和类 SuperCfUpdater
。一旦初始化,执行所需的操作(例如,在您的问题中,在此scf中添加一个新的cf),然后使用模板更新更改。以下是一个代码段。
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);
这篇关于Hector / Cassandra:如何向现有SuperColumn添加列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!