使用Hector模板在Cassandra中创建复合列

时间:2012-01-25 18:00:36

标签: java cassandra hector

要求: 复合列(非DynamicComposite),Hector模板实现

您好.. 我目前正在尝试使用以下规范创建一个列家族:

somekeyId UUID
Site URL UTF8Type
Page URL UTF8Type
   - parentURL UTF8Type (Composite)
   - anchortext UTF8Type (Composite)

我创建了以下代码:

创建ColumnFamily:

List<ColumnDefinition> columnList = new    ArrayList<ColumnDefinition>();
...

ColumnFamilyDefinition cfDef = HFactory.createColumnFamilyDefinition(keyspaceName, "page_internal_links", ComparatorType.COMPOSITETYPE, columnList);
    cfDef.setComparatorTypeAlias("(UTF8Type, UTF8Type, UTF8Type)");
    cfDef.setKeyValidationClass(ComparatorType.UTF8TYPE.getTypeName());

Composite key = new Composite();
key.addComponent(parentURL, StringSerializer.get());
key.addComponent(anchorText, StringSerializer.get());

ColumnFamilyTemplate<String, Composite> compTemplate = 
            new ThriftColumnFamilyTemplate<String, Composite>(
                    ksp, "linksCF", StringSerializer.get(), CompositeSerializer.get());
ColumnFamilyUpdater<String, Composite> compUpdater = compTemplate.createUpdater("key"); // In this row key, I want to provide somekeyId UUID
// Any suggestions here ??
compTemplate.update(compUpdater);

提前感谢您的帮助。我到处都在寻找tuts / docs ..但我最终无处可去......

0 个答案:

没有答案