@Test @SuppressWarnings("unchecked") public void testGroupSet() { String[] ids = new String[]{ UUID.randomUUID().toString(), UUID.randomUUID().toString()}; FieldPartitioner hashFunc = Accessor.getDefault().getFieldPartitioners(hash).get(0); Constraints c = emptyConstraints.partitionedBy(hash).with("id", ids[0]); Marker marker0 = new Marker.Builder() .add("id_hash", hashFunc.apply(ids[0])).add("id_copy", ids[0]).build(); MarkerRange actual = Iterables.getOnlyElement(c.toKeyRanges()); Assert.assertEquals(marker0, actual.getStart().getBound()); Assert.assertEquals(marker0, actual.getEnd().getBound()); c = emptyConstraints.partitionedBy(hash).with("id", (Object[]) ids); Marker marker1 = new Marker.Builder() .add("id_hash", hashFunc.apply(ids[1])).add("id_copy", ids[1]).build(); assertIterableEquals( Sets.newHashSet( new MarkerRange(hashCmp).of(marker0), new MarkerRange(hashCmp).of(marker1)), c.toKeyRanges()); }
@SuppressWarnings("unchecked") static Iterator<MarkerRange.Builder> add( In constraint, List<FieldPartitioner> fps, Iterator<MarkerRange.Builder> inner) { Iterator<MarkerRange.Builder> current = inner; List<FieldPartitioner> compatible = Lists.newArrayList(); for (FieldPartitioner fp : fps) { Predicate<?> projected = fp.project(constraint); if (projected instanceof Range) { current = addProjected(projected, fp.getName(), current); } else if (projected instanceof In) { compatible.add(fp); } } if (compatible.size() < 1) { return current; } else if (compatible.size() == 1) { FieldPartitioner fp = compatible.get(0); return addProjected(fp.project(constraint), fp.getName(), current); } else { return new SetGroupIterator(constraint, compatible, current); } }
KeyRangeIterable implements Iterable<MarkerRange> { @SuppressWarnings("unchecked") static Iterator<MarkerRange.Builder> add( In constraint, List<FieldPartitioner> fps, Iterator<MarkerRange.Builder> inner) { Iterator<MarkerRange.Builder> current = inner; List<FieldPartitioner> compatible = Lists.newArrayList(); for (FieldPartitioner fp : fps) { Predicate<?> projected = fp.project(constraint); if (projected instanceof Range) { current = addProjected(projected, fp.getName(), current); } else if (projected instanceof In) { compatible.add(fp); } } if (compatible.size() < 1) { return current; } else if (compatible.size() == 1) { FieldPartitioner fp = compatible.get(0); return addProjected(fp.project(constraint), fp.getName(), current); } else { return new SetGroupIterator(constraint, compatible, current); } } }
KeyRangeIterable implements Iterable<MarkerRange> { @SuppressWarnings("unchecked") static Iterator<MarkerRange.Builder> add( In constraint, List<FieldPartitioner> fps, Iterator<MarkerRange.Builder> inner) { Iterator<MarkerRange.Builder> current = inner; List<FieldPartitioner> compatible = Lists.newArrayList(); for (FieldPartitioner fp : fps) { Predicate<?> projected = fp.project(constraint); if (projected instanceof Range) { current = addProjected(projected, fp.getName(), current); } else if (projected instanceof In) { compatible.add(fp); } } if (compatible.size() < 1) { return current; } else if (compatible.size() == 1) { FieldPartitioner fp = compatible.get(0); return addProjected(fp.project(constraint), fp.getName(), current); } else { return new SetGroupIterator(constraint, compatible, current); } } KeyRangeIterable(PartitionStrategy strategy, Map<String, Predicate> predicates); }
KeyRangeIterable implements Iterable<MarkerRange> { @SuppressWarnings("unchecked") static Iterator<MarkerRange.Builder> add( In constraint, List<FieldPartitioner> fps, Iterator<MarkerRange.Builder> inner) { Iterator<MarkerRange.Builder> current = inner; List<FieldPartitioner> compatible = Lists.newArrayList(); for (FieldPartitioner fp : fps) { Predicate<?> projected = fp.project(constraint); if (projected instanceof Range) { current = addProjected(projected, fp.getName(), current); } else if (projected instanceof In) { compatible.add(fp); } } if (compatible.size() < 1) { return current; } else if (compatible.size() == 1) { FieldPartitioner fp = compatible.get(0); return addProjected(fp.project(constraint), fp.getName(), current); } else { return new SetGroupIterator(constraint, compatible, current); } } KeyRangeIterable(PartitionStrategy strategy, Map<String, Predicate> predicates); @Override @SuppressWarnings("unchecked") Iterator<MarkerRange> iterator(); }
KeyRangeIterable implements Iterable<MarkerRange> { @SuppressWarnings("unchecked") static Iterator<MarkerRange.Builder> add( In constraint, List<FieldPartitioner> fps, Iterator<MarkerRange.Builder> inner) { Iterator<MarkerRange.Builder> current = inner; List<FieldPartitioner> compatible = Lists.newArrayList(); for (FieldPartitioner fp : fps) { Predicate<?> projected = fp.project(constraint); if (projected instanceof Range) { current = addProjected(projected, fp.getName(), current); } else if (projected instanceof In) { compatible.add(fp); } } if (compatible.size() < 1) { return current; } else if (compatible.size() == 1) { FieldPartitioner fp = compatible.get(0); return addProjected(fp.project(constraint), fp.getName(), current); } else { return new SetGroupIterator(constraint, compatible, current); } } KeyRangeIterable(PartitionStrategy strategy, Map<String, Predicate> predicates); @Override @SuppressWarnings("unchecked") Iterator<MarkerRange> iterator();  }