List<Future<List<Shard>>> futures = new ArrayList<>(); TokenFactory tokenFactory = this.partitioner.getTokenFactory(); TokenRange tokenRange = rangeToTokenRange(new Range<>( tokenFactory.fromString(start), tokenFactory.fromString(end)));
private static <T extends RingPosition<T>> Set<Range<T>> intersectionBothWrapping(Range<T> first, Range<T> that) { Set<Range<T>> intersection = new HashSet<Range<T>>(2); if (that.right.compareTo(first.left) > 0) intersection.add(new Range<T>(first.left, that.right)); intersection.add(new Range<T>(that.left, first.right)); return Collections.unmodifiableSet(intersection); }
public List<Range<T>> unwrap() { T minValue = right.minValue(); if (!isWrapAround() || right.equals(minValue)) return Arrays.asList(this); List<Range<T>> unwrapped = new ArrayList<Range<T>>(2); unwrapped.add(new Range<T>(left, minValue)); unwrapped.add(new Range<T>(minValue, right)); return unwrapped; }
public Collection<Range<Token>> getPrimaryRangesFor(Collection<Token> tokens) { Collection<Range<Token>> ranges = new ArrayList<>(tokens.size()); for (Token right : tokens) ranges.add(new Range<>(getPredecessor(right), right)); return ranges; }
public List<Range<T>> unwrap() { T minValue = right.minValue(); if (!isWrapAround() || right.equals(minValue)) return Arrays.asList(this); List<Range<T>> unwrapped = new ArrayList<Range<T>>(2); unwrapped.add(new Range<T>(left, minValue)); unwrapped.add(new Range<T>(minValue, right)); return unwrapped; }
public Collection<Range<Token>> getPrimaryRangesFor(Collection<Token> tokens) { Collection<Range<Token>> ranges = new ArrayList<>(tokens.size()); for (Token right : tokens) ranges.add(new Range<>(getPredecessor(right), right)); return ranges; }
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); }
/** * @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))); }
/** * Compute a range of keys corresponding to a given range of token. */ public static Range<PartitionPosition> makeRowRange(Token left, Token right) { return new Range<PartitionPosition>(left.maxKeyBound(), right.maxKeyBound()); }
public Pair<AbstractBounds<T>, AbstractBounds<T>> split(T position) { assert contains(position) || left.equals(position); if (left.equals(position)) return null; AbstractBounds<T> lb = new Range<T>(left, position); AbstractBounds<T> rb = new ExcludingBounds<T>(position, right); return Pair.create(lb, rb); }
/** * Compute a range of keys corresponding to a given range of token. */ public static Range<PartitionPosition> makeRowRange(Token left, Token right) { return new Range<PartitionPosition>(left.maxKeyBound(), right.maxKeyBound()); }
public Pair<AbstractBounds<T>, AbstractBounds<T>> split(T position) { assert contains(position) || left.equals(position); if (left.equals(position)) return null; AbstractBounds<T> lb = new Range<T>(left, position); AbstractBounds<T> rb = new ExcludingBounds<T>(position, right); return Pair.create(lb, rb); }
public Pair<AbstractBounds<T>, AbstractBounds<T>> split(T position) { assert contains(position); // Check if the split would have no effect on the range if (position.equals(right)) return null; AbstractBounds<T> lb = new Bounds<T>(left, position); AbstractBounds<T> rb = new Range<T>(position, right); return Pair.create(lb, rb); }
public Pair<AbstractBounds<T>, AbstractBounds<T>> split(T position) { assert contains(position); // Check if the split would have no effect on the range if (position.equals(right)) return null; AbstractBounds<T> lb = new Bounds<T>(left, position); AbstractBounds<T> rb = new Range<T>(position, right); return Pair.create(lb, rb); }
public static <T extends RingPosition<T>> AbstractBounds<T> bounds(T min, boolean inclusiveMin, T max, boolean inclusiveMax) { if (inclusiveMin && inclusiveMax) return new Bounds<T>(min, max); else if (inclusiveMax) return new Range<T>(min, max); else if (inclusiveMin) return new IncludingExcludingBounds<T>(min, max); else return new ExcludingBounds<T>(min, max); }
/** * Creates a {@code DataRange} to query all data (over the whole ring). * * @param partitioner the partitioner in use for the table. * * @return the newly create {@code DataRange}. */ public static DataRange allData(IPartitioner partitioner) { return forTokenRange(new Range<Token>(partitioner.getMinimumToken(), partitioner.getMinimumToken())); }
/** * Creates a {@code DataRange} to query all data (over the whole ring). * * @param partitioner the partitioner in use for the table. * * @return the newly create {@code DataRange}. */ public static DataRange allData(IPartitioner partitioner) { return forTokenRange(new Range<Token>(partitioner.getMinimumToken(), partitioner.getMinimumToken())); }
/** * Creates a {@code DataRange} to query all data (over the whole ring). * * @param partitioner the partitioner in use for the table. * * @return the newly create {@code DataRange}. */ public static DataRange allData(IPartitioner partitioner) { return forTokenRange(new Range<Token>(partitioner.getMinimumToken(), partitioner.getMinimumToken())); }
public static <T extends RingPosition<T>> AbstractBounds<T> bounds(T min, boolean inclusiveMin, T max, boolean inclusiveMax) { if (inclusiveMin && inclusiveMax) return new Bounds<T>(min, max); else if (inclusiveMax) return new Range<T>(min, max); else if (inclusiveMin) return new IncludingExcludingBounds<T>(min, max); else return new ExcludingBounds<T>(min, max); }