@Test @SuppressWarnings("unchecked") public void testCombined() { Long[] timestamps = new Long[] { 1379020547042L, 1384204547042L }; String[] ids = new String[]{ UUID.randomUUID().toString(), UUID.randomUUID().toString()}; FieldPartitioner hashFunc = Accessor.getDefault().getFieldPartitioners(hash).get(0); Constraints c = emptyConstraints.partitionedBy(strategy) .from("timestamp", timestamps[0]).to("timestamp", timestamps[1]) .with("id", (Object[]) ids); Marker sep0 = new Marker.Builder() .add("year", 2013).add("month", 9).add("day", 12) .add("id_hash", hashFunc.apply(ids[0])).add("id_copy", ids[0]) .build(); Marker nov0 = new Marker.Builder() .add("year", 2013).add("month", 11).add("day", 11) .add("id_hash", hashFunc.apply(ids[0])).add("id_copy", ids[0]) .build(); Marker sep1 = new Marker.Builder() .add("year", 2013).add("month", 9).add("day", 12) .add("id_hash", hashFunc.apply(ids[1])).add("id_copy", ids[1]) .build(); Marker nov1 = new Marker.Builder() .add("year", 2013).add("month", 11).add("day", 11) .add("id_hash", hashFunc.apply(ids[1])).add("id_copy", ids[1]) .build(); assertIterableEquals(Sets.newHashSet( new MarkerRange(cmp).from(sep0).to(nov0), new MarkerRange(cmp).from(sep1).to(nov1)), c.toKeyRanges()); Marker sep2 = new Marker.Builder() .add("year", 2013).add("month", 9).add("day", 12) .add("id_hash", hashFunc.apply(ids[0])).add("id_copy", ids[0]) .add("id_component", "com.company.Main") .build(); Marker nov2 = new Marker.Builder() .add("year", 2013).add("month", 11).add("day", 11) .add("id_hash", hashFunc.apply(ids[0])).add("id_copy", ids[0]) .add("id_component", "com.company.Main") .build(); Marker sep3 = new Marker.Builder() .add("year", 2013).add("month", 9).add("day", 12) .add("id_hash", hashFunc.apply(ids[1])).add("id_copy", ids[1]) .add("id_component", "com.company.Main") .build(); Marker nov3 = new Marker.Builder() .add("year", 2013).add("month", 11).add("day", 11) .add("id_hash", hashFunc.apply(ids[1])).add("id_copy", ids[1]) .add("id_component", "com.company.Main") .build(); Marker sep4 = new Marker.Builder() .add("year", 2013).add("month", 9).add("day", 12) .add("id_hash", hashFunc.apply(ids[0])).add("id_copy", ids[0]) .add("id_component", "com.company.SomeClass") .build(); Marker nov4 = new Marker.Builder() .add("year", 2013).add("month", 11).add("day", 11) .add("id_hash", hashFunc.apply(ids[0])).add("id_copy", ids[0]) .add("id_component", "com.company.SomeClass") .build(); Marker sep5 = new Marker.Builder() .add("year", 2013).add("month", 9).add("day", 12) .add("id_hash", hashFunc.apply(ids[1])).add("id_copy", ids[1]) .add("id_component", "com.company.SomeClass") .build(); Marker nov5 = new Marker.Builder() .add("year", 2013).add("month", 11).add("day", 11) .add("id_hash", hashFunc.apply(ids[1])).add("id_copy", ids[1]) .add("id_component", "com.company.SomeClass") .build(); assertIterableEquals(Sets.newHashSet( new MarkerRange(cmp).from(sep2).to(nov2), new MarkerRange(cmp).from(sep3).to(nov3), new MarkerRange(cmp).from(sep4).to(nov4), new MarkerRange(cmp).from(sep5).to(nov5)), c.with("component", "com.company.Main", "com.company.SomeClass") .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();  }