简体   繁体   中英

Cassandra CompositeType as row key Validator

I'm working on some POC.

I have the Column Family which stores server event. Avoiding to get row oversize we are splitting each row to N another rows using compositeType in row key:

CREATE COLUMN FAMILY logs with comparator='ReversedType(TimeUUIDType)' and key_validation_class='CompositeType(UTF8Type,IntegerType)' and default_validation_class=UTF8Type;

so for each server name we have N rows and we are writing data to each row using Very Simple Round Robin algorithm.

I have no problem to write data to any row:

   Mutator<Composite> mutator = HFactory.createMutator(keySpace, CompositeSerializer.get());
    HColumn<UUID,String> col = 
    HFactory.createColumn( TimeUUIDUtils.getUniqueTimeUUIDinMillis(), log);
    Composite rowName = new Composite();
    rowName.addComponent(serverName, StringSerializer.get());
    rowName.addComponent(this.roundRobinDestributor.getRow(), IntegerSerializer.get());
    mutator.insert(rowName, columnFamilyName, col);
}

So far so good, but now I have two quetions:

1) Due to the fact that if I want to get all logs for some serverName I would scan row keys, should I use ByteOrderedPartitioner ?

2) Can any body help me, or point me on some help how to create Hector query which will bring all rows for server1 ( {server1:0}, {server1:1} {server1:2), etc...)? I saw a lot of example using CompositeType as comparator, but no example for key validator.

Any help or comment is highly appreciated.

First of all, row oversizing shouldn't be a problem in cassandra. Despite that, it might worth to spilt rows, since data distribution across cluster will be more even in this situation.

  1. ByteOrderedPartitioner doesn't look like a good option here, since it would be hard to achieve uniform distribution of rows across cluster, that will lead to hotspots.

  2. There's no way to query range of keys when using RandomPartitioner . However, if the maximum N value is reasonably small (up to 256) MultigetSliceQuery might be used to query whole set of rows.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM