org.apache.cassandra.dht
Class RandomPartitioner

java.lang.Object
  extended by org.apache.cassandra.dht.AbstractPartitioner<BigIntegerToken>
      extended by org.apache.cassandra.dht.RandomPartitioner
All Implemented Interfaces:
IPartitioner<BigIntegerToken>

public class RandomPartitioner
extends AbstractPartitioner<BigIntegerToken>

This class generates a BigIntegerToken using MD5 hash.


Field Summary
static java.math.BigInteger MAXIMUM
           
static BigIntegerToken MINIMUM
           
static java.math.BigInteger ZERO
           
 
Constructor Summary
RandomPartitioner()
           
 
Method Summary
 DecoratedKey convertFromDiskFormat(java.nio.ByteBuffer fromdisk)
           
 DecoratedKey decorateKey(java.nio.ByteBuffer key)
          Transform key to object representation of the on-disk format.
 java.util.Map<Token,java.lang.Float> describeOwnership(java.util.List<Token> sortedTokens)
          Calculate the deltas between tokens in the ring in order to compare relative sizes.
 BigIntegerToken getMinimumToken()
           
 BigIntegerToken getRandomToken()
           
 BigIntegerToken getToken(java.nio.ByteBuffer key)
           
 Token.TokenFactory<java.math.BigInteger> getTokenFactory()
           
 AbstractType<?> getTokenValidator()
           
 Token midpoint(Token ltoken, Token rtoken)
          Calculate a Token representing the approximate "middle" of the given range.
 boolean preservesOrder()
           
 
Methods inherited from class org.apache.cassandra.dht.AbstractPartitioner
minValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO

public static final java.math.BigInteger ZERO

MINIMUM

public static final BigIntegerToken MINIMUM

MAXIMUM

public static final java.math.BigInteger MAXIMUM
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.

Parameters:
key - the raw, client-facing key
Returns:
decorated version of key

convertFromDiskFormat

public DecoratedKey convertFromDiskFormat(java.nio.ByteBuffer fromdisk)
Parameters:
fromdisk - On disk representation
Returns:
DecoratedKey object

midpoint

public Token midpoint(Token ltoken,
                      Token rtoken)
Description copied from interface: IPartitioner
Calculate a Token representing the approximate "middle" of the given range.

Returns:
The approximate midpoint between left and right.

getMinimumToken

public BigIntegerToken getMinimumToken()
Returns:
The minimum possible Token in the range that is being partitioned.

getRandomToken

public BigIntegerToken getRandomToken()
Returns:
a randomly generated token

getTokenFactory

public Token.TokenFactory<java.math.BigInteger> getTokenFactory()

preservesOrder

public boolean preservesOrder()
Returns:
True if the implementing class preserves key order in the Tokens it generates.

getToken

public BigIntegerToken getToken(java.nio.ByteBuffer key)
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.

Parameters:
sortedTokens - a sorted List of Tokens
Returns:
the mapping from 'token' to 'percentage of the ring owned by that token'.

getTokenValidator

public AbstractType<?> getTokenValidator()


Copyright © 2013 The Apache Software Foundation