Right now, I have to manually generate the composite key by formatting the subkeys together. It's ugly and not efficient. I wonder if Hector provides such set of APIs to handle composite keys in a more decent way.
Does Hector provide APIs to support composite key?
yes it does.
You can look at DynamicCompositeTest for examples:
@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);
thanks! on top of that, what the schema should look like for such column family? –
Planetary
So since it's called DynamicComposite, there is nothing we can do on schema to "describe" it, is that right? –
Planetary
Something liek this: create column family StateNpaIndexDynamic with comparator = 'DynamicCompositeType(s=>UTF8Type,l=>LongType)' and key_validation_class = 'UTF8Type' and default_validation_class = 'UTF8Type'; –
Statement
© 2022 - 2024 — McMap. All rights reserved.