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

发布于 2024-12-28 17:31:51 字数 1280 浏览 5 评论 0原文

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

嗨.. 我目前正在尝试创建具有以下规格的列族:

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

我已创建以下代码:

创建列族:

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);

感谢您提前的帮助。我一直在到处寻找图茨/文档..但我最终无处可去...

Requirements:
Composite Column(Not DynamicComposite), Hector Template Implementation

Hi..
I am currently trying to create a columnfamily with the below specs:

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

I have created the following code:

To Create The 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);

Thanks for the help in advance. I've been looking for tuts/docs everywhere.. But i ended up nowhere...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文