@Test public void testTimeRange() { Long[] timestamps = new Long[] { 1379020547042L, 1381612547042L, 1384204547042L }; Constraints c = emptyConstraints.partitionedBy(time) .from("timestamp", timestamps[0]).to("timestamp", timestamps[2]); Marker sep = new Marker.Builder().add("year", 2013).add("month", 9).add("day", 12).build(); Marker nov = new Marker.Builder().add("year", 2013).add("month", 11).add("day", 11).build(); Assert.assertEquals( new MarkerRange(timeCmp).from(sep).to(nov), 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();  }