Class: Humboldt::DropBinaryPrefixPartitioner

Inherits:
BinaryPrefixPartitioner show all
Defined in:
lib/humboldt/prefix_grouping.rb

Instance Method Summary collapse

Methods inherited from BinaryPrefixPartitioner

#initialize

Constructor Details

This class inherits a constructor from Humboldt::BinaryPrefixPartitioner

Instance Method Details

#partition(key, value, num_partitions) ⇒ Object



20
21
22
23
24
# File 'lib/humboldt/prefix_grouping.rb', line 20

def partition(key, value, num_partitions)
  length = key.length > @cutoff_index ? key.length - @cutoff_index : 0
  prefix = String.from_java_bytes(key.bytes)[0, length]
  Zlib.crc32(prefix) % num_partitions
end