MultiSortMergeJoinImpl multiSortMergeJoin = new MultiSortMergeJoinImpl(sortMergeJoin, NODE_COMPARATOR);
TupleEngine optJoinTupleEngine = new SortMergeNaturalJoinEngine(RELATION_HELPER, joinTupleEngine,
multiSortMergeJoin);
TupleEngine unionTupleEngine = new OuterUnionEngine(RELATION_HELPER);
NadicJoin join = new NadicJoinImpl(RELATION_PROCESSOR, optJoinTupleEngine);
BooleanEvaluator evaluator = new BooleanEvaluatorImpl(NODE_COMPARATOR);
Restrict restrict = new RestrictImpl(RELATION_FACTORY, TUPLE_COMPARATOR, evaluator);
Union union = new OuterUnionImpl(RELATION_PROCESSOR, unionTupleEngine);
DyadicJoin leftOuterJoin = getLeftOuterJoin(unionTupleEngine, join);
return new OptimizingQueryEngineImpl(project, join, restrict, union, leftOuterJoin);
}