public class Murmur3StreamGrouping extends Object implements CustomStreamGrouping
Simple CustomStreamGrouping that uses Murmur3 algorithm to choose the target task of a tuple.
This stream grouping may be used to optimise writes to Apache Cassandra.
| Constructor and Description |
|---|
Murmur3StreamGrouping(List<String> partitionKeyNames)
Creates a new
Murmur3StreamGrouping instance. |
Murmur3StreamGrouping(String... partitionKeyNames)
Creates a new
Murmur3StreamGrouping instance. |
| Modifier and Type | Method and Description |
|---|---|
List<Integer> |
chooseTasks(int taskId,
List<Object> values) |
static long |
hashes(List<Object> values)
Computes the murmur3 hash for the specified values.
|
void |
prepare(WorkerTopologyContext context,
GlobalStreamId stream,
List<Integer> targetTasks) |
public Murmur3StreamGrouping(String... partitionKeyNames)
Creates a new Murmur3StreamGrouping instance.
partitionKeyNames - partitionKeyNames.public Murmur3StreamGrouping(List<String> partitionKeyNames)
Creates a new Murmur3StreamGrouping instance.
partitionKeyNames - partitionKeyNames.public void prepare(WorkerTopologyContext context, GlobalStreamId stream, List<Integer> targetTasks)
prepare in interface CustomStreamGroupingpublic List<Integer> chooseTasks(int taskId, List<Object> values)
chooseTasks in interface CustomStreamGroupingpublic static long hashes(List<Object> values) throws IOException
Computes the murmur3 hash for the specified values. http://stackoverflow.com/questions/27212797/cassandra-hashing-algorithm-with-composite-keys https://github.com/apache/cassandra/blob/trunk/src/java/org/apache/cassandra/db/marshal/CompositeType.java
values - the fields which are part of the (compose) partition key.IOExceptionCopyright © 2018 The Apache Software Foundation. All Rights Reserved.