PartitionStrategy strategy = key.getPartitionStrategy();
Set<String> timeFields = Sets.newHashSet();
int i = 0;
for (FieldPartitioner fp : strategy.getFieldPartitioners()) {
String partition = fp.getName();
Predicate partitionPredicate = unsatisfied.get(partition);
if (partitionPredicate != null && partitionPredicate.apply(key.get(i))) {
unsatisfied.remove(partition);
LOG.debug("removing " + partition + " satisfied by " + key.get(i));
}
String source = fp.getSourceName();
if (fp instanceof CalendarFieldPartitioner) {
// keep track of time fields to consider
timeFields.add(source);
}
// remove the field if it is satisfied by the StorageKey
Predicate original = unsatisfied.get(source);
if (original != null) {
Predicate isSatisfiedBy = fp.projectStrict(original);
LOG.debug("original: " + original + ", strict: " + isSatisfiedBy);
if ((isSatisfiedBy != null) && isSatisfiedBy.apply(key.get(i))) {
LOG.debug("removing " + source + " satisfied by " + key.get(i));
unsatisfied.remove(source);
}
}
i += 1;
}
// remove fields satisfied by the time predicates
for (String timeField : timeFields) {
Predicate<Long> original = unsatisfied.get(timeField);
if (original != null) {
Predicate<Marker> isSatisfiedBy = TimeDomain.get(strategy, timeField)
.projectStrict(original);
LOG.debug("original: " + original + ", strict: " + isSatisfiedBy);
if ((isSatisfiedBy != null) && isSatisfiedBy.apply(key)) {
LOG.debug("removing " + timeField + " satisfied by " + key);
unsatisfied.remove(timeField);
}
}
}