## 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

Nested Class Summary

Nested classes/interfaces inherited from class org.apache.cassandra.dht.AbstractBounds
`AbstractBounds.AbstractBoundsSerializer`

Field Summary
`static long` `serialVersionUID`

Fields inherited from class org.apache.cassandra.dht.AbstractBounds
`left, partitioner, right`

Constructor Summary
`Range(Token left, Token right)`
`Range(Token left, Token right, IPartitioner partitioner)`

Method Summary
`static int` `compare(Token left, Token right)`
`int` `compareTo(Range rhs)`
`boolean` `contains(Range that)`
`boolean` `contains(Token bi)` Helps determine if a given point on the DHT ring is contained in the range in question.
`static boolean` `contains(Token left, Token right, Token bi)`
`AbstractBounds` `createFrom(Token token)`
`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
`boolean` `equals(java.lang.Object o)`
`java.util.Set<Range>` `intersectionWith(Range that)`
`boolean` `intersects(Range that)`
`static boolean` `isTokenInRanges(Token token, java.lang.Iterable<Range> ranges)`
`boolean` `isWrapAround()`
`static boolean` `isWrapAround(Token left, Token right)` Tells if the given range is a wrap around.
`static java.util.Set<Range>` `rangeSet(Range... ranges)`
`java.lang.String` `toString()`
`java.util.List<AbstractBounds>` `unwrap()`

Methods inherited from class org.apache.cassandra.dht.AbstractBounds
`hashCode, normalize, serializer, split`

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

Field Detail

### serialVersionUID

    public static final long serialVersionUID

See Also:
  Constant Field Values

Constructor Detail

### Range

    public Range(Token left,
                 Token right)

### Range

    public Range(Token left,
                 Token right,
                 IPartitioner partitioner)

Method Detail

### 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 © 2012 The Apache Software Foundation