[ 
https://issues.apache.org/jira/browse/CALCITE-1166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16755816#comment-16755816
 ] 

Vladimir Sitnikov commented on CALCITE-1166:
--------------------------------------------

[~julianhyde], I wonder if you did consider adding builder-like API instead of 
current operand(...) and operandJ(...) methods. Was it intentionally 

For instance, something around lines
{code:java}  public RelOptRuleOperand testAPI() {
    return operand(Project.class)
        .has(Convention.NONE)
        .satisfies(x -> x.getInputs().size()==1)
        .input(operand(Filter.class))
        .build();
  }

  static <T extends RelNode> OperandBuilder<T> operand(Class<T> klazz) {
    return new OperandBuilder<T>(klazz);
  }

  static class OperandBuilder<T extends RelNode> {
    private final Class<T> rel;

    public OperandBuilder(Class<T> rel) {
      this.rel = rel;
    }

    native OperandBuilder<T> to(Convention convention);
    native OperandBuilder<T> from(Convention convention);
    native OperandBuilder<T> satisfies(Predicate<? extends T> predicate);
    native OperandBuilder<T> has(RelTrait traitSet);
    native OperandBuilder<T> satisfies(RelTrait traitSet);
    native OperandBuilder<T> satisfies(RelTraitSet traitSet);
    native<V extends RelNode> OperandBuilder<T> input(OperandBuilder<V> 
children);
    native RelOptRuleOperand build();
  }
{code}


> Disallow sub-classes of RelOptRuleOperand
> -----------------------------------------
>
>                 Key: CALCITE-1166
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1166
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>            Priority: Major
>             Fix For: 1.8.0
>
>
> Disallow sub-classes of {{RelOptRuleOperand}}. The only reason that people 
> have sub-classed {{RelOptRuleOperand}} is to override the {{boolean 
> matches(RelNode)}} method, and you can now achieve that by supplying a 
> {{Predicate}} to the constructor.
> Next release, we will deprecate {{RelOptRuleOperand}}'s protected constructor 
> and create a new private or package-protected one. Later we will remove that 
> constructor.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to