use of com.apple.foundationdb.record.query.plan.plans.RecordQueryIndexPlan in project fdb-record-layer by FoundationDB.
the class FDBRecordStoreScanLimitTest method testExecuteStateReset.
@ParameterizedTest
// for this test, the scan limit must divide 100
@ValueSource(ints = { 2, 5, 10, 20 })
public void testExecuteStateReset(int scanLimit) throws Exception {
final IndexScanParameters fullValueScan = IndexScanComparisons.byValue();
final RecordQueryPlan plan = new RecordQueryIndexPlan("MySimpleRecord$str_value_indexed", fullValueScan, false);
ExecuteProperties properties = ExecuteProperties.newBuilder().setScannedRecordsLimit(scanLimit).build();
try (FDBRecordContext context = openContext()) {
openSimpleRecordStore(context);
byte[] continuation = null;
do {
try (RecordCursorIterator<FDBQueriedRecord<Message>> cursor = recordStore.executeQuery(plan, continuation, properties).asIterator()) {
int retrieved = 0;
while (cursor.hasNext()) {
cursor.next();
retrieved++;
}
continuation = cursor.getContinuation();
if (continuation != null) {
// if this is our last call, we might retrieve 0 results
assertEquals(scanLimit, retrieved);
}
properties = properties.resetState();
}
} while (continuation != null);
}
}
use of com.apple.foundationdb.record.query.plan.plans.RecordQueryIndexPlan in project fdb-record-layer by FoundationDB.
the class FDBAndQueryToIntersectionTest method intersectionVisitorOnComplexComparisonKey.
/**
* Verify that an intersection visitor won't defer a record fetch if the comparison key has fields that the index
* entry doesn't.
* This sort of plan is never produced by the {@link com.apple.foundationdb.record.query.plan.RecordQueryPlanner},
* so we have to test the visitor directly.
*/
@Test
public void intersectionVisitorOnComplexComparisonKey() throws Exception {
complexQuerySetup(null);
IndexScanParameters fullValueScan = IndexScanComparisons.byValue();
RecordQueryPlan originalPlan1 = RecordQueryIntersectionPlan.from(new RecordQueryIndexPlan("MySimpleRecord$str_value_indexed", fullValueScan, false), new RecordQueryIndexPlan("MySimpleRecord$num_value_3_indexed", fullValueScan, false), primaryKey("MySimpleRecord"));
RecordQueryPlan modifiedPlan1 = RecordQueryPlannerSubstitutionVisitor.applyVisitors(originalPlan1, recordStore.getRecordMetaData(), PlannableIndexTypes.DEFAULT, primaryKey("MySimpleRecord"));
assertThat(modifiedPlan1, fetch(intersection(coveringIndexScan(indexScan("MySimpleRecord$str_value_indexed")), coveringIndexScan(indexScan("MySimpleRecord$num_value_3_indexed")))));
RecordQueryPlan originalPlan2 = RecordQueryIntersectionPlan.from(new RecordQueryIndexPlan("MySimpleRecord$str_value_indexed", fullValueScan, false), new RecordQueryIndexPlan("MySimpleRecord$num_value_3_indexed", fullValueScan, false), concat(field("num_value_2"), primaryKey("MySimpleRecord")));
RecordQueryPlan modifiedPlan2 = RecordQueryPlannerSubstitutionVisitor.applyVisitors(originalPlan2, recordStore.getRecordMetaData(), PlannableIndexTypes.DEFAULT, primaryKey("MySimpleRecord"));
// Visitor should not perform transformation because of comparison key on num_value_unique
assertEquals(originalPlan2, modifiedPlan2);
}
use of com.apple.foundationdb.record.query.plan.plans.RecordQueryIndexPlan in project fdb-record-layer by FoundationDB.
the class QueryPlanStructuralInstrumentationTest method in.
@Test
public void in() {
final String indexName = "a_field";
final IndexScanParameters scan = IndexScanComparisons.byValue(new ScanComparisons(Arrays.asList(new Comparisons.ParameterComparison(Comparisons.Type.EQUALS, "another_field")), Collections.emptySet()));
final RecordQueryPlan plan = new RecordQueryInValuesJoinPlan(new RecordQueryIndexPlan(indexName, scan, false), "another_field", Bindings.Internal.IN, Arrays.asList(2, 4), false, false);
assertUsesIndexes(plan, Lists.newArrayList(indexName));
final StoreTimer timer = new FDBStoreTimer();
plan.logPlanStructure(timer);
assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_IN_VALUES), 1);
assertEquals(timer.getCount(FDBStoreTimer.Counts.PLAN_INDEX), 1);
}
use of com.apple.foundationdb.record.query.plan.plans.RecordQueryIndexPlan in project fdb-record-layer by FoundationDB.
the class QueryPlanCursorTest method reverse.
@Test
public void reverse() throws Exception {
final IndexScanParameters scan = IndexScanComparisons.byValue(new ScanComparisons(Collections.emptyList(), ImmutableSet.of(new Comparisons.SimpleComparison(Comparisons.Type.GREATER_THAN, 2), new Comparisons.SimpleComparison(Comparisons.Type.LESS_THAN, 4))));
final RecordQueryPlan plan = new RecordQueryIndexPlan("MySimpleRecord$num_value_3_indexed", scan, true);
compareSkipsAndCursors(plan);
}
use of com.apple.foundationdb.record.query.plan.plans.RecordQueryIndexPlan in project fdb-record-layer by FoundationDB.
the class QueryPlanCursorTest method in.
@Test
public void in() throws Exception {
final IndexScanParameters scan = IndexScanComparisons.byValue(new ScanComparisons(Arrays.asList(new Comparisons.ParameterComparison(Comparisons.Type.EQUALS, "in_num")), Collections.emptySet()));
final RecordQueryPlan plan = new RecordQueryInValuesJoinPlan(new RecordQueryIndexPlan("MySimpleRecord$num_value_3_indexed", scan, false), "in_num", Bindings.Internal.IN, Arrays.asList(2, 4), false, false);
compareSkipsAndCursors(plan);
}
Aggregations