Package com.linkedin.venice.partitioner
Class DefaultVenicePartitioner
- java.lang.Object
-
- com.linkedin.venice.partitioner.VenicePartitioner
-
- com.linkedin.venice.partitioner.DefaultVenicePartitioner
-
public class DefaultVenicePartitioner extends VenicePartitioner
Default implementation of theVenicePartitioner
class. It uses a hashing algorithm (MD5 by default) to determine the appropriate partition for each message.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
MD5_HASH_ALGORITHM
-
Fields inherited from class com.linkedin.venice.partitioner.VenicePartitioner
props
-
-
Constructor Summary
Constructors Constructor Description DefaultVenicePartitioner()
DefaultVenicePartitioner(VeniceProperties props)
DefaultVenicePartitioner(VeniceProperties props, org.apache.avro.Schema schema)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getPartitionId(byte[] keyBytes, int numPartitions)
A function that returns the partitionId based on the key and partition count.int
getPartitionId(byte[] keyBytes, int offset, int length, int numPartitions)
Implementors of this class can optionally provide an implementation of this function, which would result in eliminating an instantiation ofByteBuffer
in the case where the provided offset and length do not map to the boundaries of the byte[].int
getPartitionId(java.nio.ByteBuffer keyByteBuffer, int numPartitions)
-
Methods inherited from class com.linkedin.venice.partitioner.VenicePartitioner
checkSchema
-
-
-
-
Field Detail
-
MD5_HASH_ALGORITHM
public static final java.lang.String MD5_HASH_ALGORITHM
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultVenicePartitioner
public DefaultVenicePartitioner()
-
DefaultVenicePartitioner
public DefaultVenicePartitioner(VeniceProperties props)
-
DefaultVenicePartitioner
public DefaultVenicePartitioner(VeniceProperties props, org.apache.avro.Schema schema)
-
-
Method Detail
-
getPartitionId
public int getPartitionId(byte[] keyBytes, int offset, int length, int numPartitions)
Description copied from class:VenicePartitioner
Implementors of this class can optionally provide an implementation of this function, which would result in eliminating an instantiation ofByteBuffer
in the case where the provided offset and length do not map to the boundaries of the byte[]. This is just a minor optimization.- Overrides:
getPartitionId
in classVenicePartitioner
-
getPartitionId
public int getPartitionId(byte[] keyBytes, int numPartitions)
Description copied from class:VenicePartitioner
A function that returns the partitionId based on the key and partition count.- Specified by:
getPartitionId
in classVenicePartitioner
- Parameters:
keyBytes
- - A key that will be mapped into a partitionnumPartitions
- - The number of total partitions available in Kafka/storage- Returns:
-
getPartitionId
public int getPartitionId(java.nio.ByteBuffer keyByteBuffer, int numPartitions)
- Specified by:
getPartitionId
in classVenicePartitioner
-
-