public Operator plan(long testId)
{
List<AkCollator> collators = Arrays.asList(ciCollator, ciCollator);
// loadFilter loads the filter with F rows containing the given testId.
Operator loadFilter = project_DefaultTest(
select_HKeyOrdered(
filter_Default(
groupScan_Default(group(f)),
Collections.singleton(fRowType)),
fRowType,
ExpressionGenerators.compare(
ExpressionGenerators.field(fRowType, 0),
Comparison.EQ,
ExpressionGenerators.literal(testId), castResolver())),
fRowType,
Arrays.asList(ExpressionGenerators.field(fRowType, 1),
ExpressionGenerators.field(fRowType, 2)));
// For the index scan retriving rows from the D(test_id) index
IndexBound testIdBound =
new IndexBound(row(dIndexRowType, testId), new SetColumnSelector(0));
IndexKeyRange dTestIdKeyRange =
IndexKeyRange.bounded(dIndexRowType, testIdBound, true, testIdBound, true);
// For the index scan retrieving rows from the F(a, b) index given a D index row
IndexBound abBound = new IndexBound(
new RowBasedUnboundExpressions(
loadFilter.rowType(),
Arrays.asList(
ExpressionGenerators.boundField(dIndexRowType, 0, 1),
ExpressionGenerators.boundField(dIndexRowType, 0, 2)), true),
new SetColumnSelector(0, 1));
IndexKeyRange fabKeyRange =
IndexKeyRange.bounded(fabIndexRowType, abBound, true, abBound, true);
// Use a bloom filter loaded by loadFilter. Then for each input row, check the filter (projecting
// D rows on (a, b)), and, for positives, check F using an index scan keyed by D.a and D.b.
Operator plan =
project_DefaultTest(
using_BloomFilter(
// filterInput
loadFilter,
// filterRowType
loadFilter.rowType(),
// estimatedRowCount
10,
// filterBindingPosition
0,
// streamInput
select_BloomFilter(
// input
indexScan_Default(dIndexRowType, dTestIdKeyRange, new Ordering()),
// onPositive
indexScan_Default(
fabIndexRowType,
fabKeyRange,
new Ordering()),
// filterFields
Arrays.asList(
ExpressionGenerators.field(dIndexRowType, 1),
ExpressionGenerators.field(dIndexRowType, 2)),
// collators
collators,
// filterBindingPosition
0, false, 1,
ExpressionGenerator.ErasureMaker.MARK),
// collators
collators
),
dIndexRowType,
Arrays.asList(
ExpressionGenerators.field(dIndexRowType, 3))); // test_id
outputRowType = plan.rowType();
return plan;
}