Does Hector provide APIs to support composite key?

核能气质少年 提交于 2019-12-06 04:36:28

yes it does.

You can look at DynamicCompositeTest for examples:

https://github.com/rantav/hector/blob/master/core/src/test/java/me/prettyprint/hector/api/beans/DynamicCompositeTest.java

@Test
public void allTypesSerialize() {
    DynamicComposite composite = new DynamicComposite();

    UUID lexUUID = UUID.randomUUID();
    com.eaio.uuid.UUID timeUUID = new com.eaio.uuid.UUID();


    //add all forward comparators
    composite.addComponent(0, "AsciiText", AsciiSerializer.get(), "AsciiType", ComponentEquality.EQUAL);
    composite.addComponent(1, new byte[]{0, 1, 2, 3}, BytesArraySerializer.get(), "BytesType", ComponentEquality.EQUAL);
    composite.addComponent(2, -1, IntegerSerializer.get(), "IntegerType", ComponentEquality.EQUAL);
    composite.addComponent(3,  lexUUID, UUIDSerializer.get(), "LexicalUUIDType", ComponentEquality.EQUAL);
    composite.addComponent(4, -1l, LongSerializer.get(), "LongType", ComponentEquality.EQUAL);
    composite.addComponent(5, timeUUID, TimeUUIDSerializer.get(), "TimeUUIDType", ComponentEquality.EQUAL);
    composite.addComponent(6, "UTF8Text", StringSerializer.get(), "UTF8Type", ComponentEquality.EQUAL);
    composite.addComponent(7,  lexUUID, UUIDSerializer.get(), "UUIDType", ComponentEquality.EQUAL);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!