use of com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest in project fdb-record-layer by FoundationDB.
the class FDBSelectorPlanTest method testTwoInnerPlansWithContinuation.
@DualPlannerTest
void testTwoInnerPlansWithContinuation() throws Throwable {
complexQuerySetup(NO_HOOK);
RecordQuery query1 = RecordQuery.newBuilder().setRecordType("MySimpleRecord").build();
RecordQuery query2 = RecordQuery.newBuilder().setRecordType("MySimpleRecord").setFilter(Query.field("num_value_2").equalsValue(1)).build();
// This will select plan 1 for the first execution and later some illegal value. The idea is that after the
// first iteration, the continuation should determine the selected plan and not the relative priorities
RecordQueryPlan planUnderTest = RecordQuerySelectorPlan.from(plan(query1, query2), mockSelector());
// Iteration 1, start with empty continuation
RecordCursorResult<FDBQueriedRecord<Message>> result = querySimpleRecordStoreWithContinuation(NO_HOOK, planUnderTest, EvaluationContext::empty, null, ExecuteProperties.newBuilder().setReturnedRowLimit(15).build(), count -> assertThat(count, is(15)), record -> assertThat(record.getNumValue2(), is(1)), context -> assertDiscardedAtMost(30, context));
assertThat(result.getNoNextReason(), is(RecordCursor.NoNextReason.RETURN_LIMIT_REACHED));
// Iteration 2, start with previous continuation
byte[] continuation = result.getContinuation().toBytes();
result = querySimpleRecordStoreWithContinuation(NO_HOOK, planUnderTest, EvaluationContext::empty, continuation, ExecuteProperties.newBuilder().setReturnedRowLimit(15).build(), count -> assertThat(count, is(15)), record -> assertThat(record.getNumValue2(), is(1)), context -> assertDiscardedAtMost(30, context));
assertThat(result.getNoNextReason(), is(RecordCursor.NoNextReason.RETURN_LIMIT_REACHED));
// Iteration 3, start with previous continuation, reach end
continuation = result.getContinuation().toBytes();
result = querySimpleRecordStoreWithContinuation(NO_HOOK, planUnderTest, EvaluationContext::empty, continuation, ExecuteProperties.newBuilder().setReturnedRowLimit(15).build(), count -> assertThat(count, is(3)), record -> assertThat(record.getNumValue2(), is(1)), context -> assertDiscardedAtMost(8, context));
assertThat(result.hasNext(), is(false));
assertThat(result.getNoNextReason(), is(RecordCursor.NoNextReason.SOURCE_EXHAUSTED));
}
use of com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest in project fdb-record-layer by FoundationDB.
the class FDBComparatorPlanTest method testTwoSameInnerPlans.
@DualPlannerTest
void testTwoSameInnerPlans() 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(1)).build();
RecordQueryPlan planUnderTest = RecordQueryComparatorPlan.from(plan(query1, query2), primaryKey(), 0, abortOnComparisonFailure);
assertSamePlans(planUnderTest, 1, 134, 33);
}
use of com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest in project fdb-record-layer by FoundationDB.
the class FDBComparatorPlanTest method testTwoDifferentInnerPlansIndex1.
@DualPlannerTest
void testTwoDifferentInnerPlansIndex1() 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();
// Note the reference index is now 1
RecordQueryPlan planUnderTest = RecordQueryComparatorPlan.from(plan(query1, query2), primaryKey(), 1, abortOnComparisonFailure);
assertDifferentPlans(planUnderTest, 2, 134, 33);
}
use of com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest in project fdb-record-layer by FoundationDB.
the class FDBComparatorPlanTest method testTwoSameInnerPlansWithContinuation.
@DualPlannerTest
void testTwoSameInnerPlansWithContinuation() throws Throwable {
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(1)).build();
// This will select plan 1 for the first execution and later some illegal value. The idea is that after the
// first iteration, the continuation should determine the selected plan and not the relative priorities
RecordQueryPlan planUnderTest = RecordQueryComparatorPlan.from(plan(query1, query2), primaryKey(), 0, abortOnComparisonFailure);
// Iteration 1, start with empty continuation
RecordCursorResult<FDBQueriedRecord<Message>> result = assertSamePlansWithContinuation(planUnderTest, null, 15, 0, 15, 1, 60, false, RecordCursor.NoNextReason.RETURN_LIMIT_REACHED);
// Iteration 2, start with previous continuation
byte[] continuation = result.getContinuation().toBytes();
result = assertSamePlansWithContinuation(planUnderTest, continuation, 15, 0, 15, 1, 60, false, RecordCursor.NoNextReason.RETURN_LIMIT_REACHED);
// Iteration 3, start with previous continuation, reach end
continuation = result.getContinuation().toBytes();
assertSamePlansWithContinuation(planUnderTest, continuation, 15, 0, 3, 1, 16, false, RecordCursor.NoNextReason.SOURCE_EXHAUSTED);
}
use of com.apple.foundationdb.record.provider.foundationdb.query.DualPlannerTest in project fdb-record-layer by FoundationDB.
the class FDBComparatorPlanTest method testTwoDifferentInnerPlansWithContinuation.
@DualPlannerTest
void testTwoDifferentInnerPlansWithContinuation() throws Throwable {
// This test has the non-reference plan ends but the cursor continues until the end of the reference plan
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 end sooner
RecordQuery query2 = RecordQuery.newBuilder().setRecordType("MySimpleRecord").setFilter(Query.and(Query.field("num_value_2").equalsValue(1), Query.field("rec_no").lessThan(50L))).build();
// This will select plan 1 for the first execution and later some illegal value. The idea is that after the
// first iteration, the continuation should determine the selected plan and not the relative priorities
RecordQueryPlan planUnderTest = RecordQueryComparatorPlan.from(plan(query1, query2), primaryKey(), 0, abortOnComparisonFailure);
// Iteration 1, start with empty continuation.
// The plans are the "same" here since we haven't reached the point at which the second scan ends (yet)
RecordCursorResult<FDBQueriedRecord<Message>> result = assertSamePlansWithContinuation(planUnderTest, null, 15, 0, 15, 1, 60, false, RecordCursor.NoNextReason.RETURN_LIMIT_REACHED);
// Iteration 2, start with previous continuation
// For this iteration, the second plan ends sooner, so the comparison fails
byte[] continuation = result.getContinuation().toBytes();
result = assertDifferentPlansWithContinuation(planUnderTest, continuation, 15, 0, 15, 1, 60, false, RecordCursor.NoNextReason.RETURN_LIMIT_REACHED);
if (result != null) {
// Iteration 3, start with previous continuation, reach end
// (in case we have a result from the first iteration)
continuation = result.getContinuation().toBytes();
assertDifferentPlansWithContinuation(planUnderTest, continuation, 15, 0, 3, 1, 16, false, RecordCursor.NoNextReason.SOURCE_EXHAUSTED);
}
}
Aggregations