1. /**
    2. * A collection of expressions which read inputs, compute output expressions,
    3. * and optionally use a condition to filter rows.
    4. *
    5. * <p>Programs are immutable. It may help to use a {@link RexProgramBuilder},
    6. * which has the same relationship to {@link RexProgram} as {@link StringBuilder}
    7. * has to {@link String}.
    8. *
    9. * <p>A program can contain aggregate functions. If it does, the arguments to
    10. * each aggregate function must be an {@link RexInputRef}.
    11. *
    12. * @see RexProgramBuilder
    13. */
    14. public class RexProgram {
    15. //~ Instance fields --------------------------------------------------------
    16. /**
    17. * First stage of expression evaluation. The expressions in this array can
    18. * refer to inputs (using input ordinal #0) or previous expressions in the
    19. * array (using input ordinal #1).
    20. */
    21. // 最开始的表达式信息,一般是RexInputRef, RexCall, RexLocalRef 等node
    22. private final List<RexNode> exprs;
    23. /**
    24. * With {@link #condition}, the second stage of expression evaluation.
    25. */
    26. // 经过 Condition 条件过滤之后的表达式信息
    27. private final List<RexLocalRef> projects;
    28. /**
    29. * The optional condition. If null, the calculator does not filter rows.
    30. */
    31. private final RexLocalRef condition;
    32. private final RelDataType inputRowType;
    33. private final RelDataType outputRowType;
    34. /**
    35. * Reference counts for each expression, computed on demand.
    36. */
    37. private int[] refCounts;
    38. }