kafka.partitioner package¶
Submodules¶
kafka.partitioner.base module¶
-
class
kafka.partitioner.base.
Partitioner
(partitions)¶ Bases:
object
Base class for a partitioner
-
partition
(key, partitions=None)¶ Takes a string key and num_partitions as argument and returns a partition to be used for the message
Parameters: - key – the key to use for partitioning
- partitions – (optional) a list of partitions.
-
kafka.partitioner.hashed module¶
-
kafka.partitioner.hashed.
HashedPartitioner
¶ alias of
LegacyPartitioner
-
class
kafka.partitioner.hashed.
LegacyPartitioner
(partitions)¶ Bases:
kafka.partitioner.base.Partitioner
DEPRECATED – See Issue 374
Implements a partitioner which selects the target partition based on the hash of the key
-
partition
(key, partitions=None)¶
-
-
class
kafka.partitioner.hashed.
Murmur2Partitioner
(partitions)¶ Bases:
kafka.partitioner.base.Partitioner
Implements a partitioner which selects the target partition based on the hash of the key. Attempts to apply the same hashing function as mainline java client.
-
partition
(key, partitions=None)¶
-
-
kafka.partitioner.hashed.
murmur2
(key)¶ Pure-python Murmur2 implementation.
Based on java client, see org.apache.kafka.common.utils.Utils.murmur2
Parameters: key – if not a bytes type, encoded using default encoding Returns: MurmurHash2 of key bytearray
kafka.partitioner.roundrobin module¶
-
class
kafka.partitioner.roundrobin.
RoundRobinPartitioner
(partitions)¶ Bases:
kafka.partitioner.base.Partitioner
Implements a round robin partitioner which sends data to partitions in a round robin fashion
-
partition
(key, partitions=None)¶
-
Module contents¶
-
class
kafka.partitioner.
RoundRobinPartitioner
(partitions)¶ Bases:
kafka.partitioner.base.Partitioner
Implements a round robin partitioner which sends data to partitions in a round robin fashion
-
partition
(key, partitions=None)¶
-
-
kafka.partitioner.
HashedPartitioner
¶ alias of
LegacyPartitioner
-
class
kafka.partitioner.
Murmur2Partitioner
(partitions)¶ Bases:
kafka.partitioner.base.Partitioner
Implements a partitioner which selects the target partition based on the hash of the key. Attempts to apply the same hashing function as mainline java client.
-
partition
(key, partitions=None)¶
-
-
class
kafka.partitioner.
LegacyPartitioner
(partitions)¶ Bases:
kafka.partitioner.base.Partitioner
DEPRECATED – See Issue 374
Implements a partitioner which selects the target partition based on the hash of the key
-
partition
(key, partitions=None)¶
-