Search in sources :

Example 1 with TraitMatchingRule

use of org.apache.calcite.rel.convert.TraitMatchingRule in project calcite by apache.

the class HepPlanner method executeInstruction.

void executeInstruction(HepInstruction.ConverterRules instruction) {
    assert currentProgram.group == null;
    if (instruction.ruleSet == null) {
        instruction.ruleSet = new LinkedHashSet<>();
        for (RelOptRule rule : allRules) {
            if (!(rule instanceof ConverterRule)) {
                continue;
            }
            ConverterRule converter = (ConverterRule) rule;
            if (converter.isGuaranteed() != instruction.guaranteed) {
                continue;
            }
            // Add the rule itself to work top-down
            instruction.ruleSet.add(converter);
            if (!instruction.guaranteed) {
                // Add a TraitMatchingRule to work bottom-up
                instruction.ruleSet.add(new TraitMatchingRule(converter, RelFactories.LOGICAL_BUILDER));
            }
        }
    }
    applyRules(instruction.ruleSet, instruction.guaranteed);
}
Also used : ConverterRule(org.apache.calcite.rel.convert.ConverterRule) TraitMatchingRule(org.apache.calcite.rel.convert.TraitMatchingRule) RelOptRule(org.apache.calcite.plan.RelOptRule)

Aggregations

RelOptRule (org.apache.calcite.plan.RelOptRule)1 ConverterRule (org.apache.calcite.rel.convert.ConverterRule)1 TraitMatchingRule (org.apache.calcite.rel.convert.TraitMatchingRule)1