Search in sources :

Example 6 with DualPlannerTest

use of com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest in project fdb-record-layer by FoundationDB.

the class FDBComparatorPlanTest method testOneInnerPlan.

@DualPlannerTest
void testOneInnerPlan() throws Exception {
    complexQuerySetup(NO_HOOK);
    RecordQuery query = RecordQuery.newBuilder().setRecordType("MySimpleRecord").setFilter(Query.field("num_value_2").equalsValue(1)).build();
    RecordQueryPlan planUnderTest = RecordQueryComparatorPlan.from(plan(query), primaryKey(), 0, abortOnComparisonFailure);
    assertSamePlans(planUnderTest, 1, 67, 33);
}
Also used : RecordQuery(com.apple.foundationdb.record.query.RecordQuery) DualPlannerTest(com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest)

Example 7 with DualPlannerTest

use of com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest in project fdb-record-layer by FoundationDB.

the class FDBComparatorPlanTest method testTwoDifferentInnerPlansOneEndsSooner.

@DualPlannerTest
void testTwoDifferentInnerPlansOneEndsSooner() throws Exception {
    complexQuerySetup(NO_HOOK);
    RecordQuery query1 = RecordQuery.newBuilder().setRecordType("MySimpleRecord").setFilter(Query.field("num_value_2").equalsValue(1)).build();
    // This plan has same records as the previous one, but ends sooner
    RecordQuery query2 = RecordQuery.newBuilder().setRecordType("MySimpleRecord").setFilter(Query.and(Query.field("num_value_2").equalsValue(1), Query.field("rec_no").lessThan(5L))).build();
    RecordQueryPlan planUnderTest = RecordQueryComparatorPlan.from(plan(query1, query2), primaryKey(), 0, abortOnComparisonFailure);
    assertDifferentPlans(planUnderTest, 1, 134, 33);
}
Also used : RecordQuery(com.apple.foundationdb.record.query.RecordQuery) DualPlannerTest(com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest)

Example 8 with DualPlannerTest

use of com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest in project fdb-record-layer by FoundationDB.

the class FDBComparatorPlanTest method testTwoDifferentInnerPlansIndex0.

@DualPlannerTest
void testTwoDifferentInnerPlansIndex0() throws Exception {
    complexQuerySetup(NO_HOOK);
    RecordQuery query1 = RecordQuery.newBuilder().setRecordType("MySimpleRecord").setFilter(Query.field("num_value_2").equalsValue(1)).build();
    RecordQuery query2 = RecordQuery.newBuilder().setRecordType("MySimpleRecord").setFilter(Query.field("num_value_2").equalsValue(2)).build();
    RecordQueryPlan planUnderTest = RecordQueryComparatorPlan.from(plan(query1, query2), primaryKey(), 0, abortOnComparisonFailure);
    assertDifferentPlans(planUnderTest, 1, 134, 33);
}
Also used : RecordQuery(com.apple.foundationdb.record.query.RecordQuery) DualPlannerTest(com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest)

Example 9 with DualPlannerTest

use of com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest in project fdb-record-layer by FoundationDB.

the class FDBSelectorPlanTest method testTwoInnerPlan.

@DualPlannerTest
void testTwoInnerPlan() throws Exception {
    complexQuerySetup(NO_HOOK);
    RecordQuery query1 = RecordQuery.newBuilder().setRecordType("MySimpleRecord").setFilter(Query.field("num_value_2").equalsValue(1)).build();
    RecordQuery query2 = RecordQuery.newBuilder().setRecordType("MySimpleRecord").build();
    // This will always select plan1 for execution
    RecordQueryPlan planUnderTest = RecordQuerySelectorPlan.from(plan(query1, query2), Arrays.asList(100, 0));
    int count = querySimpleRecordStore(NO_HOOK, planUnderTest, EvaluationContext::empty, record -> assertThat(record.getNumValue2(), is(1)), context -> assertDiscardedAtMost(67, context));
    assertEquals(33, count);
}
Also used : EvaluationContext(com.apple.foundationdb.record.EvaluationContext) RecordQuery(com.apple.foundationdb.record.query.RecordQuery) DualPlannerTest(com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest)

Example 10 with DualPlannerTest

use of com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest in project fdb-record-layer by FoundationDB.

the class FDBSelectorPlanTest method testOneInnerPlan.

@DualPlannerTest
void testOneInnerPlan() throws Exception {
    complexQuerySetup(NO_HOOK);
    RecordQuery query = RecordQuery.newBuilder().setRecordType("MySimpleRecord").setFilter(Query.field("num_value_2").equalsValue(1)).build();
    RecordQueryPlan planUnderTest = RecordQuerySelectorPlan.from(plan(query), Collections.singletonList(100));
    int count = querySimpleRecordStore(NO_HOOK, planUnderTest, EvaluationContext::empty, record -> assertThat(record.getNumValue2(), is(1)), context -> assertDiscardedAtMost(67, context));
    assertEquals(33, count);
}
Also used : EvaluationContext(com.apple.foundationdb.record.EvaluationContext) RecordQuery(com.apple.foundationdb.record.query.RecordQuery) DualPlannerTest(com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest)

Aggregations

DualPlannerTest (com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest)16 RecordQuery (com.apple.foundationdb.record.query.RecordQuery)16 FDBQueriedRecord (com.apple.foundationdb.record.provider.foundationdb.FDBQueriedRecord)5 EvaluationContext (com.apple.foundationdb.record.EvaluationContext)3 Value (com.apple.foundationdb.record.query.predicates.Value)2 ValuePickerValue (com.apple.foundationdb.record.query.predicates.ValuePickerValue)2 ExecuteProperties (com.apple.foundationdb.record.ExecuteProperties)1 RecordCoreArgumentException (com.apple.foundationdb.record.RecordCoreArgumentException)1 RecordCursor (com.apple.foundationdb.record.RecordCursor)1 RecordCursorResult (com.apple.foundationdb.record.RecordCursorResult)1 TestHelpers.assertDiscardedAtMost (com.apple.foundationdb.record.TestHelpers.assertDiscardedAtMost)1 KeyExpression (com.apple.foundationdb.record.metadata.expressions.KeyExpression)1 FDBRecordStoreQueryTestBase (com.apple.foundationdb.record.provider.foundationdb.query.FDBRecordStoreQueryTestBase)1 Query (com.apple.foundationdb.record.query.expressions.Query)1 Tags (com.apple.test.Tags)1 ImmutableList (com.google.common.collect.ImmutableList)1 Descriptors (com.google.protobuf.Descriptors)1 Message (com.google.protobuf.Message)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1