Search in sources :

Example 1 with DNF

use of com.apple.foundationdb.record.query.plan.planning.BooleanPredicateNormalizer.Mode.DNF in project fdb-record-layer by FoundationDB.

the class BooleanPredicateNormalizerTest method bigNonCnf.

@Test
void bigNonCnf() {
    final QueryPredicate cnf = and(IntStream.rangeClosed(1, 9).boxed().map(i -> or(IntStream.rangeClosed(1, 9).boxed().map(j -> and(new ValuePredicate(new FieldValue(QuantifiedColumnValue.of(CorrelationIdentifier.UNGROUNDED, 0), ImmutableList.of("num_value_3_indexed")), new Comparisons.SimpleComparison(Comparisons.Type.EQUALS, i * 9 + j)), new ValuePredicate(new FieldValue(QuantifiedColumnValue.of(CorrelationIdentifier.UNGROUNDED, 0), ImmutableList.of("str_value_indexed")), new Comparisons.SimpleComparison(Comparisons.Type.EQUALS, "foo")))).collect(Collectors.toList()))).collect(Collectors.toList()));
    final BooleanPredicateNormalizer plannerNormalizer = BooleanPredicateNormalizer.forConfiguration(DNF, RecordQueryPlannerConfiguration.builder().build());
    assertThrows(BooleanPredicateNormalizer.NormalFormTooLargeException.class, () -> plannerNormalizer.normalize(cnf));
    assertEquals(cnf, plannerNormalizer.normalizeIfPossible(cnf).orElse(cnf));
}
Also used : IntStream(java.util.stream.IntStream) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) DNF(com.apple.foundationdb.record.query.plan.planning.BooleanPredicateNormalizer.Mode.DNF) ValuePredicate(com.apple.foundationdb.record.query.predicates.ValuePredicate) RecordQueryPlannerConfiguration(com.apple.foundationdb.record.query.plan.RecordQueryPlannerConfiguration) Assertions.assertNotEquals(org.junit.jupiter.api.Assertions.assertNotEquals) QueryPredicate(com.apple.foundationdb.record.query.predicates.QueryPredicate) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test) Objects(java.util.Objects) Comparisons(com.apple.foundationdb.record.query.expressions.Comparisons) List(java.util.List) OrPredicate.or(com.apple.foundationdb.record.query.predicates.OrPredicate.or) ImmutableList(com.google.common.collect.ImmutableList) CorrelationIdentifier(com.apple.foundationdb.record.query.plan.temp.CorrelationIdentifier) OrPredicate(com.apple.foundationdb.record.query.predicates.OrPredicate) AndPredicate.and(com.apple.foundationdb.record.query.predicates.AndPredicate.and) NotPredicate.not(com.apple.foundationdb.record.query.predicates.NotPredicate.not) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) FieldValue(com.apple.foundationdb.record.query.predicates.FieldValue) QuantifiedColumnValue(com.apple.foundationdb.record.query.predicates.QuantifiedColumnValue) Nonnull(javax.annotation.Nonnull) QueryPredicate(com.apple.foundationdb.record.query.predicates.QueryPredicate) ValuePredicate(com.apple.foundationdb.record.query.predicates.ValuePredicate) FieldValue(com.apple.foundationdb.record.query.predicates.FieldValue) Test(org.junit.jupiter.api.Test)

Aggregations

Comparisons (com.apple.foundationdb.record.query.expressions.Comparisons)1 RecordQueryPlannerConfiguration (com.apple.foundationdb.record.query.plan.RecordQueryPlannerConfiguration)1 DNF (com.apple.foundationdb.record.query.plan.planning.BooleanPredicateNormalizer.Mode.DNF)1 CorrelationIdentifier (com.apple.foundationdb.record.query.plan.temp.CorrelationIdentifier)1 AndPredicate.and (com.apple.foundationdb.record.query.predicates.AndPredicate.and)1 FieldValue (com.apple.foundationdb.record.query.predicates.FieldValue)1 NotPredicate.not (com.apple.foundationdb.record.query.predicates.NotPredicate.not)1 OrPredicate (com.apple.foundationdb.record.query.predicates.OrPredicate)1 OrPredicate.or (com.apple.foundationdb.record.query.predicates.OrPredicate.or)1 QuantifiedColumnValue (com.apple.foundationdb.record.query.predicates.QuantifiedColumnValue)1 QueryPredicate (com.apple.foundationdb.record.query.predicates.QueryPredicate)1 ValuePredicate (com.apple.foundationdb.record.query.predicates.ValuePredicate)1 ImmutableList (com.google.common.collect.ImmutableList)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 Nonnull (javax.annotation.Nonnull)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1