org.apache.cassandra.dht
Class OrderPreservingPartitioner

java.lang.Object
  extended by org.apache.cassandra.dht.OrderPreservingPartitioner
All Implemented Interfaces:
IPartitioner<StringToken>

public class OrderPreservingPartitioner
extends java.lang.Object
implements IPartitioner<StringToken>


Field Summary
static StringToken MINIMUM
           
 
Constructor Summary
OrderPreservingPartitioner()
           
 
Method Summary
 java.lang.String decorateKey(java.lang.String key)
          Transform key to on-disk format s.t.
 java.util.Comparator<java.lang.String> getDecoratedKeyComparator()
           
 StringToken getDefaultToken()
           
 StringToken getMinimumToken()
           
 java.util.Comparator<java.lang.String> getReverseDecoratedKeyComparator()
           
 StringToken getToken(java.lang.String key)
           
 Token.TokenFactory<java.lang.String> getTokenFactory()
           
 StringToken midpoint(StringToken ltoken, StringToken rtoken)
          Calculate a Token representing the approximate "middle" of the given range.
 boolean preservesOrder()
           
 java.lang.String undecorateKey(java.lang.String decoratedKey)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINIMUM

public static final StringToken MINIMUM
Constructor Detail

OrderPreservingPartitioner

public OrderPreservingPartitioner()
Method Detail

decorateKey

public java.lang.String decorateKey(java.lang.String key)
Description copied from interface: IPartitioner
Transform key to on-disk format s.t. keys are stored in node comparison order. This lets bootstrap rip out parts of the sstable sequentially instead of doing random seeks.

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

undecorateKey

public java.lang.String undecorateKey(java.lang.String decoratedKey)
Specified by:
undecorateKey in interface IPartitioner<StringToken>

getDecoratedKeyComparator

public java.util.Comparator<java.lang.String> getDecoratedKeyComparator()
Specified by:
getDecoratedKeyComparator in interface IPartitioner<StringToken>

getReverseDecoratedKeyComparator

public java.util.Comparator<java.lang.String> getReverseDecoratedKeyComparator()
Specified by:
getReverseDecoratedKeyComparator in interface IPartitioner<StringToken>

midpoint

public StringToken midpoint(StringToken ltoken,
                            StringToken rtoken)
Description copied from interface: IPartitioner
Calculate a Token representing the approximate "middle" of the given range. The Tokens must have been generated by previous calls to midpoint, or be equal to this.getMinimumToken(). The range may not wrap unless it involves this.getMinimumToken().

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

getMinimumToken

public StringToken getMinimumToken()
Specified by:
getMinimumToken in interface IPartitioner<StringToken>
Returns:
The minimum possible Token in the range that is being partitioned.

getDefaultToken

public StringToken getDefaultToken()
Specified by:
getDefaultToken in interface IPartitioner<StringToken>
Returns:
the default Token to represent this node if none was saved. Uses the one given in the InitialToken configuration directive, or picks one automatically if that was not given.

getTokenFactory

public Token.TokenFactory<java.lang.String> getTokenFactory()
Specified by:
getTokenFactory in interface IPartitioner<StringToken>

preservesOrder

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

getToken

public StringToken getToken(java.lang.String key)
Specified by:
getToken in interface IPartitioner<StringToken>
Returns:
a Token that can be used to route a given key


Copyright © 2009 The Apache Software Foundation