org.apache.cassandra.dht
Class Range
java.lang.Object
org.apache.cassandra.dht.AbstractBounds
org.apache.cassandra.dht.Range
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable<Range>
- Direct Known Subclasses:
- MerkleTree.TreeRange
public class Range
- extends AbstractBounds
- implements java.lang.Comparable<Range>, java.io.Serializable
A representation of the range that a node is responsible for on the DHT ring.
A Range is responsible for the tokens between (left, right].
- See Also:
- Serialized Form
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
serialVersionUID
public static final long serialVersionUID
- See Also:
- Constant Field Values
Range
public Range(Token left,
Token right)
Range
public Range(Token left,
Token right,
IPartitioner partitioner)
contains
public static boolean contains(Token left,
Token right,
Token bi)
contains
public boolean contains(Range that)
contains
public boolean contains(Token bi)
- Helps determine if a given point on the DHT ring is contained
in the range in question.
- Specified by:
contains
in class AbstractBounds
- Parameters:
bi
- point in question
- Returns:
- true if the point contains within the range else false.
intersects
public boolean intersects(Range that)
- Parameters:
that
- range to check for intersection
- Returns:
- true if the given range intersects with this range.
rangeSet
public static java.util.Set<Range> rangeSet(Range... ranges)
intersectionWith
public java.util.Set<Range> intersectionWith(Range that)
- Parameters:
that
-
- Returns:
- the intersection of the two Ranges. this can be two disjoint Ranges if one is wrapping and one is not.
say you have nodes G and M, with query range (D,T]; the intersection is (M-T] and (D-G].
If there is no intersection, an empty list is returned.
createFrom
public AbstractBounds createFrom(Token token)
- Specified by:
createFrom
in class AbstractBounds
- Returns:
- A clone of this AbstractBounds with a new right Token, or null if an identical range would be created.
unwrap
public java.util.List<AbstractBounds> unwrap()
- Specified by:
unwrap
in class AbstractBounds
isWrapAround
public static boolean isWrapAround(Token left,
Token right)
- Tells if the given range is a wrap around.
compare
public static int compare(Token left,
Token right)
compareTo
public int compareTo(Range rhs)
- Specified by:
compareTo
in interface java.lang.Comparable<Range>
differenceToFetch
public java.util.Set<Range> differenceToFetch(Range rhs)
- Calculate set of the difference ranges of given two ranges
(as current (A, B] and rhs is (C, D])
which node will need to fetch when moving to a given new token
- Parameters:
rhs
- range to calculate difference
- Returns:
- set of difference ranges
isTokenInRanges
public static boolean isTokenInRanges(Token token,
java.lang.Iterable<Range> ranges)
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in class AbstractBounds
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
isWrapAround
public boolean isWrapAround()
Copyright © 2011 The Apache Software Foundation