core/src/main/java/org/apache/calcite/sql2rel/RelFieldTrimmer.java
/**
   * Invokes {@link #trimFields}, or the appropriate method for the type
   * of the rel parameter, using multi-method dispatch.
   *
   * @param rel        Relational expression
   * @param fieldsUsed Bitmap of fields needed by the consumer
   * @return New relational expression and its field mapping
   */
Invokes  #trimFields, or the appropriate method for the type
of the rel parameter, using multi-method dispatch.

@param rel        Relational expression
@param fieldsUsed Bitmap of fields needed by the consumer
@return New relational expression and its field mapping
Invokes #trimFields or the appropriate method for the type of the rel parameter using multi - method dispatch . @param rel Relational expression @param fieldsUsed Bitmap of fields needed by the consumer @return New relational expression and its field mapping
protected final TrimResult dispatchTrimFields(
      RelNode rel,
      ImmutableBitSet fieldsUsed,
      Set<RelDataTypeField> extraFields) {
    final TrimResult trimResult =
        trimFieldsDispatcher.invoke(rel, fieldsUsed, extraFields);
    final RelNode newRel = trimResult.left;
    final Mapping mapping = trimResult.right;
    final int fieldCount = rel.getRowType().getFieldCount();
    assert mapping.getSourceCount() == fieldCount
        : "source: " + mapping.getSourceCount() + " != " + fieldCount;
    final int newFieldCount = newRel.getRowType().getFieldCount();
    assert mapping.getTargetCount() + extraFields.size() == newFieldCount
        || Bug.TODO_FIXED
        : "target: " + mapping.getTargetCount()
        + " + " + extraFields.size()
        + " != " + newFieldCount;
    if (Bug.TODO_FIXED) {
      assert newFieldCount > 0 : "rel has no fields after trim: " + rel;
    }
    if (newRel.equals(rel)) {
      return new TrimResult(rel, mapping);
    }
    return trimResult;
  }
protected final TrimResult dispatchTrimFields ( RelNode rel , ImmutableBitSet fieldsUsed , Set < RelDataTypeField > extraFields ) { final TrimResult trimResult = trimFieldsDispatcher . invoke ( rel , fieldsUsed , extraFields ) ; final RelNode newRel = trimResult . left ; final Mapping mapping = trimResult . right ; final int fieldCount = rel . getRowType ( ) . getFieldCount ( ) ; assert mapping . getSourceCount ( ) == fieldCount : "source: " + mapping . getSourceCount ( ) + " != " + fieldCount ; final int newFieldCount = newRel . getRowType ( ) . getFieldCount ( ) ; assert mapping . getTargetCount ( ) + extraFields . size ( ) == newFieldCount || Bug . TODO_FIXED : "target: " + mapping . getTargetCount ( ) + " + " + extraFields . size ( ) + " != " + newFieldCount ; if ( Bug . TODO_FIXED ) { assert newFieldCount > 0 : "rel has no fields after trim: " + rel ; } if ( newRel . equals ( rel ) ) { return new TrimResult ( rel , mapping ) ; } return trimResult ; }
Invokes {@link #trimFields}, or the appropriate method for the type
 of the rel parameter, using multi-method dispatch.
Invokes { @link #trimFields } or the appropriate method for the type of the rel parameter using multi - method dispatch .