Package com.linkedin.venice.unit.kafka
Class SimplePartitioner
- java.lang.Object
-
- com.linkedin.venice.partitioner.VenicePartitioner
-
- com.linkedin.venice.unit.kafka.SimplePartitioner
-
public class SimplePartitioner extends VenicePartitioner
ThisVenicePartitioner
implementation takes the first byte of the key, and computes the partition as such: firstByte % numPartitions It is meant to be used in tests where we want to control the partition that a key belongs to, but without needing to work out a proper input that yields the desired partition when hashed by theDefaultVenicePartitioner
.
-
-
Field Summary
-
Fields inherited from class com.linkedin.venice.partitioner.VenicePartitioner
props
-
-
Constructor Summary
Constructors Constructor Description SimplePartitioner()
SimplePartitioner(VeniceProperties props)
SimplePartitioner(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(java.nio.ByteBuffer keyByteBuffer, int numPartitions)
-
Methods inherited from class com.linkedin.venice.partitioner.VenicePartitioner
checkSchema, getPartitionId
-
-
-
-
Constructor Detail
-
SimplePartitioner
public SimplePartitioner()
-
SimplePartitioner
public SimplePartitioner(VeniceProperties props)
-
SimplePartitioner
public SimplePartitioner(VeniceProperties props, org.apache.avro.Schema schema)
-
-
Method Detail
-
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
-
-