use of com.apple.foundationdb.record.query.plan.plans.RecordQueryLoadByKeysPlan in project fdb-record-layer by FoundationDB.
the class FDBSimpleJoinQueryTest method joinParentToChild.
/**
* Verify that simple binding joins in parent/child relationships work.
*/
@Test
public void joinParentToChild() throws Exception {
createJoinRecords(true);
RecordQuery parentQuery = RecordQuery.newBuilder().setRecordType("MyParentRecord").setFilter(Query.field("str_value_indexed").equalsValue("even")).build();
RecordQueryPlan parentPlan = planner.plan(parentQuery);
RecordQueryPlan childPlan = new RecordQueryLoadByKeysPlan("children");
try (FDBRecordContext context = openContext()) {
openJoinRecordStore(context);
RecordCursor<FDBQueriedRecord<Message>> parentCursor = recordStore.executeQuery(parentPlan);
RecordCursor<FDBQueriedRecord<Message>> childCursor = RecordCursor.flatMapPipelined(ignore -> recordStore.executeQuery(parentPlan), (rec, ignore) -> {
TestRecordsParentChildRelationshipProto.MyParentRecord.Builder parentRec = TestRecordsParentChildRelationshipProto.MyParentRecord.newBuilder();
parentRec.mergeFrom(rec.getRecord());
EvaluationContext childContext = EvaluationContext.forBinding("children", parentRec.getChildRecNosList().stream().map(Tuple::from).collect(Collectors.toList()));
return childPlan.execute(recordStore, childContext);
}, null, 10);
RecordCursor<String> resultsCursor = childCursor.map(rec -> {
TestRecordsParentChildRelationshipProto.MyChildRecord.Builder childRec = TestRecordsParentChildRelationshipProto.MyChildRecord.newBuilder();
childRec.mergeFrom(rec.getRecord());
return childRec.getStrValue();
});
assertEquals(Arrays.asList("2.1", "2.2", "2.3", "4.1", "4.2", "4.3"), resultsCursor.asList().join());
assertDiscardedNone(context);
}
}
use of com.apple.foundationdb.record.query.plan.plans.RecordQueryLoadByKeysPlan in project fdb-record-layer by FoundationDB.
the class QueryPlanStructuralInstrumentationTest method noIndexes.
@Test
public void noIndexes() {
final RecordQueryPlan plan = new RecordQueryLoadByKeysPlan("test");
assertNoIndexes(plan);
}
Aggregations