@Override protected Predicate<StorageKey> getKeyPredicate() { if (relativeLocation == null) { return Predicates.alwaysTrue(); } return new PartitionKeyPredicate(root, location); }
@SuppressWarnings("unchecked") static Predicate combine(Predicate left, Predicate right) { if (left == right) { return left; } else if (left == null) { return right; // must be non-null } else if (right == null || right instanceof Exists) { return left; // must be non-null, which satisfies exists } else if (left instanceof Exists) { return right; // must be non-null, which satisfies exists } else if (left instanceof In) { return ((In) left).filter(right); } else if (right instanceof In) { return ((In) right).filter(left); } else if (left instanceof Range && right instanceof Range) { return ((Range) left).intersection((Range) right); } else { return com.google.common.base.Predicates.and(left, right); } }
private static <E> Predicate<E> entityPredicate( Map<String, Predicate> predicates, Schema schema, EntityAccessor<E> accessor, PartitionStrategy strategy) { if (Schema.Type.RECORD != schema.getType()) { return alwaysTrue(); } return new EntityPredicate<E>(predicates, schema, accessor, strategy); }
/** * Get a {@link Predicate} for testing entity objects that match the given * {@link StorageKey}. * * @param <E> The type of entities to be matched * @param key a StorageKey for entities tested with the Predicate * @return a Predicate to test if entity objects satisfy this constraint set */ public <E> Predicate<E> toEntityPredicate(StorageKey key, EntityAccessor<E> accessor) { if (key != null) { Map<String, Predicate> predicates = minimizeFor(key); if (predicates.isEmpty()) { return alwaysTrue(); } return entityPredicate(predicates, schema, accessor, strategy); } return toEntityPredicate(accessor); }
preds[i] = partitionPredicate; } else { preds[i] = alwaysTrue();