Details
-
New Feature
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Problem Description:
For example, ExpandDisjunctionForJoinInputsRule contains two Configs, FILTER and JOIN.
@Value.Immutable(singleton = false) public interface Config extends RelRule.Config { Config FILTER = ImmutableExpandDisjunctionForJoinInputsRule.Config.builder() .withDescription("ExpandDisjunctionForJoinInputsRule(Filter)") .withMatchHandler(ExpandDisjunctionForJoinInputsRule::matchFilter) .build() .withOperandSupplier(b0 -> b0.operand(Filter.class).oneInput(b1 -> b1.operand(Join.class).anyInputs())); Config JOIN = ImmutableExpandDisjunctionForJoinInputsRule.Config.builder() .withDescription("ExpandDisjunctionForJoinInputsRule(Join)") .withMatchHandler(ExpandDisjunctionForJoinInputsRule::matchJoin) .build() .withOperandSupplier(b -> b.operand(Join.class).anyInputs()); ...... }
When using reflection to load rules in CoreRules, the following rules cannot be instantiated correctly.
public static final ExpandDisjunctionForJoinInputsRule EXPAND_FILTER_DISJUNCTION_LOCAL = ExpandDisjunctionForJoinInputsRule.Config.FILTER.toRule(); public static final ExpandDisjunctionForJoinInputsRule EXPAND_JOIN_DISJUNCTION_LOCAL = ExpandDisjunctionForJoinInputsRule.Config.JOIN.toRule();
If both rules are loaded simultaneously, they both end up using ExpandDisjunctionForJoinInputsRule.Config.FILTER.toRule().
Solution:
Add an annotation @RuleConfig(value="XXX") to each rule in CoreRules, where the value identifies the name of the Config used by the rule. For example:
@RuleConfig(value = "JOIN") public static final ExpandDisjunctionForJoinInputsRule EXPAND_JOIN_DISJUNCTION_LOCAL = ExpandDisjunctionForJoinInputsRule.Config.JOIN.toRule();
This indicates that the rule uses the JOIN Config.
If a rule has only one Config named DEFAULT, the annotation is not required.
This way, during reflection, the correct rule instance can be obtained based on the @RuleConfig annotation.
Attachments
Issue Links
- links to