/** * Helps determine if a given point on the DHT ring is contained * in the range in question. * @param point point in question * @return true if the point contains within the range else false. */ public boolean contains(T point) { return contains(left, right, point); }
public static <T extends RingPosition<T>> boolean isInRanges(T token, Iterable<Range<T>> ranges) { assert ranges != null; for (Range<T> range : ranges) { if (range.contains(token)) { return true; } } return false; }
public static <T extends RingPosition<T>> boolean isInRanges(T token, Iterable<Range<T>> ranges) { assert ranges != null; for (Range<T> range : ranges) { if (range.contains(token)) { return true; } } return false; }
/** * Helps determine if a given point on the DHT ring is contained * in the range in question. * @param point point in question * @return true if the point contains within the range else false. */ public boolean contains(T point) { return contains(left, right, point); }
public boolean tokenRangesContains(Collection<Range<Token>> shardTokenRanges, Token token) { for(Range<Token> shardRange : shardTokenRanges) { if (shardRange.contains(token)) return true; } return false; }
/** * Helps determine if a given point on the DHT ring is contained * in the range in question. * @param point point in question * @return true if the point contains within the range else false. */ public boolean contains(T point) { return contains(left, right, point); }
public static <T extends RingPosition<T>> boolean isInRanges(T token, Iterable<Range<T>> ranges) { assert ranges != null; for (Range<T> range : ranges) { if (range.contains(token)) { return true; } } return false; }
/** * Helps determine if a given point on the DHT ring is contained * in the range in question. * @param point point in question * @return true if the point contains within the range else false. */ public boolean contains(T point) { return contains(left, right, point); }
public boolean contains(T position) { // Range.contains doesnt work correctly if left == right (unless both // are minimum) because for Range that means a wrapping range that select // the whole ring. So we must explicitely handle this case return left.equals(position) || ((right.isMinimum() || !left.equals(right)) && Range.contains(left, right, position)); }
public Range<Token> getRange(ByteBuffer key) { // TODO: naive linear search of the token map Token t = partitioner.getToken(key); for (Range<Token> range : rangeMap.keySet()) if (range.contains(t)) return range; throw new RuntimeException("Invalid token information returned by describe_ring: " + rangeMap); } }
public boolean contains(T position) { // Range.contains doesnt work correctly if left == right (unless both // are minimum) because for Range that means a wrapping range that select // the whole ring. So we must explicitely handle this case return left.equals(position) || ((right.isMinimum() || !left.equals(right)) && Range.contains(left, right, position)); }
public boolean contains(T position) { // Range.contains doesnt work correctly if left == right (unless both // are minimum) because for Range that means a wrapping range that select // the whole ring. So we must explicitely handle this case return left.equals(position) || ((right.isMinimum() || !left.equals(right)) && Range.contains(left, right, position)); }
public boolean contains(T position) { // Range.contains doesnt work correctly if left == right (unless both // are minimum) because for Range that means a wrapping range that select // the whole ring. So we must explicitely handle this case return left.equals(position) || ((right.isMinimum() || !left.equals(right)) && Range.contains(left, right, position)); }
private static <T extends RingPosition<T>> Set<Range<T>> intersectionOneWrapping(Range<T> wrapping, Range<T> other) { Set<Range<T>> intersection = new HashSet<Range<T>>(2); if (other.contains(wrapping.right)) intersection.add(new Range<T>(other.left, wrapping.right)); // need the extra compareto here because ranges are asymmetrical; wrapping.left _is not_ contained by the wrapping range if (other.contains(wrapping.left) && wrapping.left.compareTo(other.right) < 0) intersection.add(new Range<T>(wrapping.left, other.right)); return Collections.unmodifiableSet(intersection); }
private static <T extends RingPosition<T>> Set<Range<T>> intersectionOneWrapping(Range<T> wrapping, Range<T> other) { Set<Range<T>> intersection = new HashSet<Range<T>>(2); if (other.contains(wrapping.right)) intersection.add(new Range<T>(other.left, wrapping.right)); // need the extra compareto here because ranges are asymmetrical; wrapping.left _is not_ contained by the wrapping range if (other.contains(wrapping.left) && wrapping.left.compareTo(other.right) < 0) intersection.add(new Range<T>(wrapping.left, other.right)); return Collections.unmodifiableSet(intersection); }
public Range<Token> getRange(ByteBuffer key) { // TODO: naive linear search of the token map Token t = partitioner.getToken(key); for (Range<Token> range : rangeMap.keySet()) if (range.contains(t)) return range; throw new RuntimeException("Invalid token information returned by describe_ring: " + rangeMap); } }
/** * @param that range to check for intersection * @return true if the given range intersects with this range. */ public boolean intersects(Bounds<T> that) { // Same punishment than in Bounds.contains(), we must be carefull if that.left == that.right as // as new Range<T>(that.left, that.right) will then cover the full ring which is not what we // want. return contains(that.left) || (!that.left.equals(that.right) && intersects(new Range<T>(that.left, that.right))); }
/** * @param that range to check for intersection * @return true if the given range intersects with this range. */ public boolean intersects(Bounds<T> that) { // Same punishment than in Bounds.contains(), we must be carefull if that.left == that.right as // as new Range<T>(that.left, that.right) will then cover the full ring which is not what we // want. return contains(that.left) || (!that.left.equals(that.right) && intersects(new Range<T>(that.left, that.right))); }
/** * @param that range to check for intersection * @return true if the given range intersects with this range. */ public boolean intersects(Bounds<T> that) { // Same punishment than in Bounds.contains(), we must be carefull if that.left == that.right as // as new Range<T>(that.left, that.right) will then cover the full ring which is not what we // want. return contains(that.left) || (!that.left.equals(that.right) && intersects(new Range<T>(that.left, that.right))); }
public Pair<AbstractBounds<T>, AbstractBounds<T>> split(T position) { assert contains(position) || left.equals(position); // Check if the split would have no effect on the range if (position.equals(left) || position.equals(right)) return null; AbstractBounds<T> lb = new Range<T>(left, position); AbstractBounds<T> rb = new Range<T>(position, right); return Pair.create(lb, rb); }