## org.apache.cassandra.dht
Class RandomPartitioner

    java.lang.Object
      org.apache.cassandra.dht.RandomPartitioner

All Implemented Interfaces:
  IPartitioner<BigIntegerToken>

    public class RandomPartitioner

extends java.lang.Object
implements IPartitioner<BigIntegerToken>

This class generates a BigIntegerToken using MD5 hash.

Field Summary
`static BigIntegerToken` `MINIMUM`
`static java.math.BigInteger` `TWO`

Constructor Summary
`RandomPartitioner()`

Method Summary
`DecoratedKey<BigIntegerToken>` `convertFromDiskFormat(java.lang.String key)` Convert the on disk representation to a DecoratedKey object
`java.lang.String` `convertToDiskFormat(DecoratedKey<BigIntegerToken> key)` Convert the DecoratedKey to the on disk format used for this partitioner.
`DecoratedKey<BigIntegerToken>` `decorateKey(java.lang.String key)` Transform key to object representation of the on-disk format.
`BigIntegerToken` `getMinimumToken()`
`BigIntegerToken` `getRandomToken()`
`BigIntegerToken` `getToken(java.lang.String key)`
`Token.TokenFactory<java.math.BigInteger>` `getTokenFactory()`
`BigIntegerToken` `midpoint(BigIntegerToken ltoken, BigIntegerToken rtoken)` Calculate a Token representing the approximate "middle" of the given range.
`boolean` `preservesOrder()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### TWO

    public static final java.math.BigInteger TWO

### MINIMUM

    public static final BigIntegerToken MINIMUM

Constructor Detail

### RandomPartitioner

    public RandomPartitioner()

Method Detail

### decorateKey

    public DecoratedKey<BigIntegerToken> decorateKey(java.lang.String key)

  Description copied from interface: `IPartitioner`
  Transform key to object representation of the on-disk format.

  Specified by:
    `decorateKey` in interface `IPartitioner<BigIntegerToken>`
  Parameters:
    `key` - the raw, client-facing key
  Returns:
    decorated version of key

### convertFromDiskFormat

    public DecoratedKey<BigIntegerToken> convertFromDiskFormat(java.lang.String key)

  Description copied from interface: `IPartitioner`
  Convert the on disk representation to a DecoratedKey object

  Specified by:
    `convertFromDiskFormat` in interface `IPartitioner<BigIntegerToken>`
  Parameters:
    `key` - On disk representation
  Returns:
    DecoratedKey object

### convertToDiskFormat

    public java.lang.String convertToDiskFormat(DecoratedKey<BigIntegerToken> key)

  Description copied from interface: `IPartitioner`
  Convert the DecoratedKey to the on disk format used for this partitioner.

  Specified by:
    `convertToDiskFormat` in interface `IPartitioner<BigIntegerToken>`
  Parameters:
    `key` - The DecoratedKey in question
  Returns:

### midpoint

    public BigIntegerToken midpoint(BigIntegerToken ltoken,
                                    BigIntegerToken rtoken)

  Description copied from interface: `IPartitioner`
  Calculate a Token representing the approximate "middle" of the given range.

  Specified by:
    `midpoint` in interface `IPartitioner<BigIntegerToken>`
  Returns:
    The approximate midpoint between left and right.

### getMinimumToken

    public BigIntegerToken getMinimumToken()

  Specified by:
    `getMinimumToken` in interface `IPartitioner<BigIntegerToken>`
  Returns:
    The minimum possible Token in the range that is being partitioned.

### getRandomToken

    public BigIntegerToken getRandomToken()

  Specified by:
    `getRandomToken` in interface `IPartitioner<BigIntegerToken>`
  Returns:
    a randomly generated token

### getTokenFactory

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

  Specified by:
    `getTokenFactory` in interface `IPartitioner<BigIntegerToken>`

### preservesOrder

    public boolean preservesOrder()

  Specified by:
    `preservesOrder` in interface `IPartitioner<BigIntegerToken>`
  Returns:
    True if the implementing class preserves key order in the Tokens it generates.

### getToken

    public BigIntegerToken getToken(java.lang.String key)

  Specified by:
    `getToken` in interface `IPartitioner<BigIntegerToken>`
  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.)

Copyright © 2010 The Apache Software Foundation