Class RandomPartitioner

  • All Implemented Interfaces:
    IPartitioner

    public class RandomPartitioner
    extends java.lang.Object
    implements IPartitioner
    This class generates a BigIntegerToken using MD5 hash.
    • Constructor Detail

      • RandomPartitioner

        public RandomPartitioner()
    • Method Detail

      • decorateKey

        public DecoratedKey decorateKey​(java.nio.ByteBuffer key)
        Description copied from interface: IPartitioner
        Transform key to object representation of the on-disk format.
        Specified by:
        decorateKey in interface IPartitioner
        Parameters:
        key - the raw, client-facing key
        Returns:
        decorated version of key
      • midpoint

        public Token midpoint​(Token ltoken,
                              Token rtoken)
        Description copied from interface: IPartitioner
        Calculate a Token representing the approximate "middle" of the given range.
        Specified by:
        midpoint in interface IPartitioner
        Returns:
        The approximate midpoint between left and right.
      • split

        public Token split​(Token ltoken,
                           Token rtoken,
                           double ratioToLeft)
        Description copied from interface: IPartitioner
        Calculate a Token which take approximate 0 <= ratioToLeft <= 1 ownership of the given range.
        Specified by:
        split in interface IPartitioner
      • preservesOrder

        public boolean preservesOrder()
        Specified by:
        preservesOrder in interface IPartitioner
        Returns:
        True if the implementing class preserves key order in the Tokens it generates.
      • getToken

        public RandomPartitioner.BigIntegerToken getToken​(java.nio.ByteBuffer key)
        Specified by:
        getToken in interface IPartitioner
        Returns:
        a Token that can be used to route a given key (This is NOT a method to create a Token from its string representation; for that, use TokenFactory.fromString.)
      • describeOwnership

        public java.util.Map<Token,​java.lang.Float> describeOwnership​(java.util.List<Token> sortedTokens)
        Description copied from interface: IPartitioner
        Calculate the deltas between tokens in the ring in order to compare relative sizes.
        Specified by:
        describeOwnership in interface IPartitioner
        Parameters:
        sortedTokens - a sorted List of Tokens
        Returns:
        the mapping from 'token' to 'percentage of the ring owned by that token'.
      • getMaximumToken

        public Token getMaximumToken()
        Description copied from interface: IPartitioner
        The biggest token for this partitioner, unlike getMinimumToken, this token is actually used and users wanting to include all tokens need to do getMaximumToken().maxKeyBound() Not implemented for the ordered partitioners
        Specified by:
        getMaximumToken in interface IPartitioner
      • partitionOrdering

        public AbstractType<?> partitionOrdering​(AbstractType<?> partitionKeyType)
        Description copied from interface: IPartitioner
        Abstract type that orders the same way as DecoratedKeys provided by this partitioner. Used by secondary indices.
        Specified by:
        partitionOrdering in interface IPartitioner
        Parameters:
        partitionKeyType - partition key type for PartitionerDefinedOrder