且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Hector / Cassandra:如何向现有SuperColumn添加列?

更新时间:2023-12-01 08:29:10


一个新列到现有的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);