use of com.apple.foundationdb.record.query.plan.temp.matchers.PrimitiveMatchers in project fdb-record-layer by FoundationDB.
the class FDBInQueryTest method cnfAsInQuery.
/**
* Verify that an IN predicate that, when converted to an OR of equality predicates, would lead to a very large DNF
* gets planned as a normal IN query rather than throwing an exception.
*/
@Test
void cnfAsInQuery() throws Exception {
RecordMetaDataHook hook = metaData -> metaData.addIndex("MySimpleRecord", "compoundIndex", concat(field("num_value_3_indexed"), field("str_value_indexed")));
complexQuerySetup(hook);
// A CNF whose DNF size doesn't fit in an int, expressed with IN predicates.
List<QueryComponent> conjuncts = new ArrayList<>();
for (int i = 0; i < 32; i++) {
conjuncts.add(Query.field("num_value_3_indexed").in(ImmutableList.of(i * 100, i * 100 + 1)));
}
final QueryComponent filter = Query.and(conjuncts);
RecordQuery query = RecordQuery.newBuilder().setRecordType("MySimpleRecord").setFilter(filter).setSort(field("str_value_indexed")).build();
RecordQueryPlan plan = planner.plan(query);
// Did not throw an exception
assertMatchesExactly(plan, filterPlan(indexPlan().where(indexName("MySimpleRecord$str_value_indexed")).and(scanComparisons(unbounded()))).where(queryComponents(exactly(conjuncts.stream().map(PrimitiveMatchers::equalsObject).collect(ImmutableList.toImmutableList())))));
}
Aggregations