@Test public void testSingleRange() { Constraints c = emptyConstraints.partitionedBy(num2) .from("number", 5).toBefore("number", 18) .to("number2", 9); Marker start = new Marker.Builder("id_number", 5).build(); Marker stop = new Marker.Builder().add("id_number", 18).add("id_number2", 9).build(); Assert.assertEquals( new MarkerRange(num2Cmp).from(start).to(stop), Iterables.getOnlyElement(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();  }