src/java/org/apache/cassandra/dht/Range.java
/**
     * 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
     *
     * @param rhs range to calculate difference
     * @return set of difference ranges
     */
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

@param rhs range to calculate difference
@return set of difference ranges
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 @param rhs range to calculate difference @return set of difference ranges
public Set<Range<T>> differenceToFetch(Range<T> rhs)
    {
        Set<Range<T>> result;
        Set<Range<T>> intersectionSet = this.intersectionWith(rhs);
        if (intersectionSet.isEmpty())
        {
            result = new HashSet<Range<T>>();
            result.add(rhs);
        }
        else
        {
            Range[] intersections = new Range[intersectionSet.size()];
            intersectionSet.toArray(intersections);
            if (intersections.length == 1)
            {
                result = new HashSet<Range<T>>(rhs.subtractContained(intersections[0]));
            }
            else
            {
                Range<T> first = intersections[0];
                Range<T> second = intersections[1];
                ArrayList<Range<T>> temp = rhs.subtractContained(first);
                Range<T> single = temp.get(0);
                result = new HashSet<Range<T>>(single.subtractContained(second));
            }
        }
        return result;
    }
public Set < Range < T > > differenceToFetch ( Range < T > rhs ) { Set < Range < T > > result ; Set < Range < T > > intersectionSet = this . intersectionWith ( rhs ) ; if ( intersectionSet . isEmpty ( ) ) { result = new HashSet < Range < T > > ( ) ; result . add ( rhs ) ; } else { Range [ ] intersections = new Range [ intersectionSet . size ( ) ] ; intersectionSet . toArray ( intersections ) ; if ( intersections . length == 1 ) { result = new HashSet < Range < T > > ( rhs . subtractContained ( intersections [ 0 ] ) ) ; } else { Range < T > first = intersections [ 0 ] ; Range < T > second = intersections [ 1 ] ; ArrayList < Range < T > > temp = rhs . subtractContained ( first ) ; Range < T > single = temp . get ( 0 ) ; result = new HashSet < Range < T > > ( single . subtractContained ( second ) ) ; } } return result ; }
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
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
// intersections.length must be 2 // Because there are two intersections, subtracting only one of them // will yield a single Range.