Class DefaultVenicePartitioner


  • public class DefaultVenicePartitioner
    extends VenicePartitioner
    Default implementation of the VenicePartitioner class. It uses a hashing algorithm (MD5 by default) to determine the appropriate partition for each message.
    • 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 of ByteBuffer 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 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 of ByteBuffer 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 class VenicePartitioner
      • 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 class VenicePartitioner
        Parameters:
        keyBytes - - A key that will be mapped into a partition
        numPartitions - - The number of total partitions available in Kafka/storage
        Returns:
      • getPartitionId

        public int getPartitionId​(java.nio.ByteBuffer keyByteBuffer,
                                  int numPartitions)
        Specified by:
        getPartitionId in class VenicePartitioner