Class HashFunctionPartitioner

java.lang.Object
org.infinispan.distribution.ch.impl.HashFunctionPartitioner
All Implemented Interfaces:
ToIntFunction<Object>, Matchable<KeyPartitioner>, KeyPartitioner
Direct Known Subclasses:
AffinityPartitioner, RESPHashFunctionPartitioner

public class HashFunctionPartitioner extends Object implements KeyPartitioner
Key partitioner that computes a key's segment based on a hash function.
Since:
8.2
Author:
Dan Berindei
  • Field Details

    • hashFunction

      protected Hash hashFunction
    • numSegments

      protected int numSegments
  • Constructor Details

    • HashFunctionPartitioner

      public HashFunctionPartitioner()
    • HashFunctionPartitioner

      public HashFunctionPartitioner(int numSegments)
  • Method Details

    • instance

      public static HashFunctionPartitioner instance(int numSegments)
    • init

      public void init(HashConfiguration configuration)
      Description copied from interface: KeyPartitioner
      Initialization.

      The partitioner can also use injection to access other cache-level or global components. This method will be called before any other injection methods.

      Does not need to be thread-safe (Infinispan safely publishes the instance after initialization).

      Specified by:
      init in interface KeyPartitioner
      Parameters:
      configuration -
    • init

      public void init(KeyPartitioner other)
      Specified by:
      init in interface KeyPartitioner
    • init

      protected void init(int numSegments)
    • bitsToUse

      protected int bitsToUse()
    • getSegment

      public int getSegment(Object key)
      Description copied from interface: KeyPartitioner
      Obtains the segment for a key. Must be thread-safe.
      Specified by:
      getSegment in interface KeyPartitioner
    • getHashForKey

      public int getHashForKey(Object key)
    • getSegmentForHash

      public int getSegmentForHash(int hash)
    • getHash

      public Hash getHash()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object