public List<Range<T>> unwrap() { @SuppressWarnings("unchecked") T minValue = (T) partitioner.minValue(right.getClass()); 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, partitioner)); unwrapped.add(new Range<T>(minValue, right, partitioner)); return unwrapped; }
/** * Merges the list of tokens for each cluster machine to a single list of token ranges. * * @param tokens the map of tokens for each cluster machine. * @param session the connection to the cluster. * @param p the partitioner used in the cluster. * @return the merged lists of tokens transformed to DeepTokenRange(s). The returned collection is shuffled. */ static List<DeepTokenRange> mergeTokenRanges(Map<String, Iterable<Comparable>> tokens, final Session session, final IPartitioner p) { final Iterable<Comparable> allRanges = Ordering.natural().sortedCopy(concat(tokens.values())); final Comparable maxValue = Ordering.natural().max(allRanges); final Comparable minValue = (Comparable) p.minValue(maxValue.getClass()).getToken().token; Function<Comparable, Set<DeepTokenRange>> map = new MergeTokenRangesFunction(maxValue, minValue, session, p, allRanges); Iterable<DeepTokenRange> concatenated = concat(transform(allRanges, map)); Set<DeepTokenRange> dedup = Sets.newHashSet(concatenated); return Ordering.natural().sortedCopy(dedup); }
T min = (T) current.partitioner.minValue(current.left.getClass()); while (iter.hasNext())