当前位置: 首页>>代码示例>>Java>>正文


Java RexBuilder.makeInputRef方法代码示例

本文整理汇总了Java中org.apache.calcite.rex.RexBuilder.makeInputRef方法的典型用法代码示例。如果您正苦于以下问题:Java RexBuilder.makeInputRef方法的具体用法?Java RexBuilder.makeInputRef怎么用?Java RexBuilder.makeInputRef使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.rex.RexBuilder的用法示例。


在下文中一共展示了RexBuilder.makeInputRef方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitCall

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
public RexNode visitCall(RexCall call) {

    String functionName = call.getOperator().getName();

    List<RexNode> newOps = new ArrayList();
    for (RexNode operand : call.operands) {
      newOps.add(operand.accept(this));
    }
    if (funcReg.isFunctionComplexOutput(functionName) ) {
      RexBuilder builder = new RexBuilder(factory);
      RexNode ret = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), lastUsedIndex);
      lastUsedIndex++;
      complexExprs.add(call.clone(new RelDataTypeDrillImpl(new RelDataTypeHolder(),factory), newOps));
      return ret;
    }
    return call.clone(call.getType(), newOps);
  }
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:RexVisitorComplexExprSplitter.java

示例2: createColumnFormatConversion

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
/**
 * Apply any data format conversion expressions.
 */
private RexNode createColumnFormatConversion(final DrillScanRel hiveScanRel, final DrillScanRel nativeScanRel,
    final String colName, final RexBuilder rb) {

  final RelDataType outputType = hiveScanRel.getRowType().getField(colName, false, false).getType();
  final RelDataTypeField inputField = nativeScanRel.getRowType().getField(colName, false, false);
  final RexInputRef inputRef = rb.makeInputRef(inputField.getType(), inputField.getIndex());

  if (outputType.getSqlTypeName() == SqlTypeName.TIMESTAMP) {
    // TIMESTAMP is stored as INT96 by Hive in ParquetFormat. Use convert_fromTIMESTAMP_IMPALA UDF to convert
    // INT96 format data to TIMESTAMP
    return rb.makeCall(INT96_TO_TIMESTAMP, inputRef);
  }

  return inputRef;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:19,代码来源:ConvertHiveParquetScanToDrillParquetScan.java

示例3: visit

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
@Override
public RelNode visit(TableScan tableScan) {
  if (tableScan instanceof ConvertibleScan) {
    return ((ConvertibleScan) tableScan).convert().accept(this);
  }
  if (!(tableScan instanceof IncrementallyUpdateable)) {
    return tableScan;
  }

  final RelNode newScan = updateScan((IncrementallyUpdateable) tableScan);

  // build new filter to apply refresh condition.
  final RexBuilder rexBuilder = tableScan.getCluster().getRexBuilder();
  final RexNode inputRef = rexBuilder.makeInputRef(newScan, newScan.getRowType().getField(UPDATE_COLUMN, false, false).getIndex());
  final RexNode literal = generateLiteral(rexBuilder, tableScan.getCluster().getTypeFactory());
  final RexNode condition = tableScan.getCluster().getRexBuilder().makeCall(SqlStdOperatorTable.GREATER_THAN, ImmutableList.of(inputRef, literal));
  return LogicalFilter.create(newScan, condition);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:IncrementalUpdateUtils.java

示例4: visit

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
private Prel visit(ExchangePrel hashPrel, List<DistributionTrait.DistributionField> fields, Prel child) {
  final List<String> childFields = child.getRowType().getFieldNames();


  // Insert Project SqlOperatorImpl with new column that will be a hash for HashToRandomExchange fields
  final ProjectPrel addColumnprojectPrel = HashPrelUtil.addHashProject(fields, child, null);
  final Prel newPrel = (Prel) hashPrel.copy(addColumnprojectPrel.getTraitSet(), Collections.<RelNode>singletonList(addColumnprojectPrel));

  int validRows = newPrel.getRowType().getFieldCount() - 1;
  final List<RelDataTypeField> all = newPrel.getRowType().getFieldList();
  final List<RexNode> keptExprs = new ArrayList<>(validRows);

  final RexBuilder rexBuilder = newPrel.getCluster().getRexBuilder();
  for(int i = 0; i < validRows; i++){
    RexNode rex = rexBuilder.makeInputRef(all.get(i).getType(), i);
    keptExprs.add(rex);
  }

  // remove earlier inserted Project SqlOperatorImpl - since it creates issues down the road in HashJoin
  RelDataType removeRowType = RexUtil.createStructType(newPrel.getCluster().getTypeFactory(), keptExprs, childFields);
  return new ProjectPrel(newPrel.getCluster(), newPrel.getTraitSet(), newPrel, keptExprs, removeRowType);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:InsertHashProjectVisitor.java

示例5: visitCall

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
@Override
public RexNode visitCall(RexCall call) {

  String functionName = call.getOperator().getName();

  List<RexNode> newOps = new ArrayList<>();
  for (RexNode operand : call.operands) {
    newOps.add(operand.accept(this));
  }
  if (funcReg.isFunctionComplexOutput(functionName) ) {
    RexBuilder builder = new RexBuilder(factory);
    RexNode ret = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), lastUsedIndex);
    lastUsedIndex++;
    complexExprs.add(call.clone(new RelDataTypeDrillImpl(new RelDataTypeHolder(),factory), newOps));
    return ret;
  }
  return call.clone(call.getType(), newOps);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:19,代码来源:RexVisitorComplexExprSplitter.java

示例6: createColumnFormatConversion

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
/**
 * Apply any data format conversion expressions.
 */
private RexNode createColumnFormatConversion(final DrillScanRel hiveScanRel, final DrillScanRel nativeScanRel,
    final String colName, final RexBuilder rb) {

  final RelDataType outputType = hiveScanRel.getRowType().getField(colName, false, false).getType();
  final RelDataTypeField inputField = nativeScanRel.getRowType().getField(colName, false, false);
  final RexInputRef inputRef = rb.makeInputRef(inputField.getType(), inputField.getIndex());

  if (outputType.getSqlTypeName() == SqlTypeName.TIMESTAMP) {
    // TIMESTAMP is stored as INT96 by Hive in ParquetFormat. Use convert_fromTIMESTAMP_IMPALA UDF to convert
    // INT96 format data to TIMESTAMP
    // TODO: Remove this conversion once "store.parquet.reader.int96_as_timestamp" will be true by default
    return rb.makeCall(INT96_TO_TIMESTAMP, inputRef);
  }

  return inputRef;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:20,代码来源:ConvertHiveParquetScanToDrillParquetScan.java

示例7: shuttleReferences

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
/**
 * Replaces all the input references by the position in the
 * input column set. If a reference index cannot be found in
 * the input set, then we return null.
 */
private static RexNode shuttleReferences(final RexBuilder rexBuilder,
    final RexNode node, final Mapping mapping) {
  try {
    RexShuttle visitor =
        new RexShuttle() {
          @Override public RexNode visitInputRef(RexInputRef inputRef) {
            int pos = mapping.getTargetOpt(inputRef.getIndex());
            if (pos != -1) {
              // Found it
              return rexBuilder.makeInputRef(inputRef.getType(), pos);
            }
            throw Util.FoundOne.NULL;
          }
        };
    return visitor.apply(node);
  } catch (Util.FoundOne ex) {
    Util.swallow(ex, null);
    return null;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:AbstractMaterializedViewRule.java

示例8: createPartitionColumnCast

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
/**
 * Create a cast for partition column. Partition column is output as "VARCHAR" in native parquet reader. Cast it
 * appropriate type according the partition type in HiveScan.
 */
private RexNode createPartitionColumnCast(final DrillScanRel hiveScanRel, final DrillScanRel nativeScanRel,
    final String outputColName, final String dirColName, final RexBuilder rb) {

  final RelDataType outputType = hiveScanRel.getRowType().getField(outputColName, false, false).getType();
  final RelDataTypeField inputField = nativeScanRel.getRowType().getField(dirColName, false, false);
  final RexInputRef inputRef =
      rb.makeInputRef(rb.getTypeFactory().createSqlType(SqlTypeName.VARCHAR), inputField.getIndex());

  return rb.makeCast(outputType, inputRef);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:15,代码来源:ConvertHiveParquetScanToDrillParquetScan.java

示例9: addHashProject

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
public static ProjectPrel addHashProject(List<DistributionField> distFields, Prel input, Integer ringCount){

    // Insert Project SqlOperatorImpl with new column that will be a hash for HashToRandomExchange fields

    final List<String> outputFieldNames = Lists.newArrayList(input.getRowType().getFieldNames());
    final String fieldName = ringCount == null ? HashPrelUtil.HASH_EXPR_NAME : WriterPrel.BUCKET_NUMBER_FIELD;
    outputFieldNames.add(fieldName);

    final RexBuilder rexBuilder = input.getCluster().getRexBuilder();
    final List<RelDataTypeField> childRowTypeFields = input.getRowType().getFieldList();

    // create new hashed field.
    final HashExpressionCreatorHelper<RexNode> hashHelper = new RexNodeBasedHashExpressionCreatorHelper(rexBuilder);
    final List<RexNode> distFieldRefs = Lists.newArrayListWithExpectedSize(distFields.size());
    for(int i = 0; i < distFields.size(); i++) {
      final int fieldId = distFields.get(i).getFieldId();
      distFieldRefs.add(rexBuilder.makeInputRef(childRowTypeFields.get(fieldId).getType(), fieldId));
    }

    final List <RexNode> updatedExpr = Lists.newArrayListWithExpectedSize(childRowTypeFields.size() + 1);
    for ( RelDataTypeField field : childRowTypeFields) {
      RexNode rex = rexBuilder.makeInputRef(field.getType(), field.getIndex());
      updatedExpr.add(rex);
    }
    RexNode hashExpression = HashPrelUtil.createHashBasedPartitionExpression(distFieldRefs, hashHelper);

    if(ringCount != null){
      RelDataType intType = input.getCluster().getTypeFactory().createSqlType(SqlTypeName.INTEGER);
      hashExpression = rexBuilder.makeCall(SqlStdOperatorTable.MOD, ImmutableList.of(hashExpression, rexBuilder.makeExactLiteral(BigDecimal.valueOf(ringCount), intType)));
      hashExpression = rexBuilder.makeCall(SqlStdOperatorTable.ABS, Collections.singletonList(hashExpression));
    }
    updatedExpr.add(hashExpression);

    RelDataType rowType = RexUtil.createStructType(input.getCluster().getTypeFactory(), updatedExpr, outputFieldNames);

    ProjectPrel addColumnprojectPrel = new ProjectPrel(input.getCluster(), input.getTraitSet(), input, updatedExpr, rowType);
    return addColumnprojectPrel;
  }
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:39,代码来源:HashPrelUtil.java

示例10: visitProject

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
@Override
public Prel visitProject(ProjectPrel node, Object unused) throws RelConversionException {
  ProjectPrel project = node;
  List<RexNode> exprList = new ArrayList<>();
  boolean rewrite = false;

  List<RelDataTypeField> relDataTypes = new ArrayList<>();
  int i = 0;
  RexNode flatttenExpr = null;
  for (RexNode rex : project.getChildExps()) {
    RexNode newExpr = rex;
    if (rex instanceof RexCall) {
      RexCall function = (RexCall) rex;
      String functionName = function.getOperator().getName();

      if (functionName.equalsIgnoreCase("flatten") ) {
        rewrite = true;
        if (function.getOperands().size() != 1) {
          throw new RelConversionException("Flatten expression expects a single input.");
        }
        newExpr = function.getOperands().get(0);
        RexBuilder builder = new RexBuilder(factory);
        flatttenExpr = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), i);
      }
    }
    relDataTypes.add(project.getRowType().getFieldList().get(i));
    i++;
    exprList.add(newExpr);
  }
  if (rewrite == true) {
    // TODO - figure out what is the right setting for the traits
    Prel newChild = ((Prel)project.getInput(0)).accept(this, null);
    ProjectPrel newProject = new ProjectPrel(node.getCluster(), project.getTraitSet(), newChild, exprList, new RelRecordType(relDataTypes));
    FlattenPrel flatten = new FlattenPrel(project.getCluster(), project.getTraitSet(), newProject, flatttenExpr);
    return flatten;
  }

  Prel child = ((Prel)project.getInput()).accept(this, null);
  return (Prel) project.copy(project.getTraitSet(), child, exprList, new RelRecordType(relDataTypes));
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:41,代码来源:RewriteProjectToFlatten.java

示例11: createPartitionColumnCast

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
/**
 * Create a cast for partition column. Partition column is output as "VARCHAR" in native parquet reader. Cast it
 * appropriate type according the partition type in HiveScan.
 */
private RexNode createPartitionColumnCast(final DrillScanRel hiveScanRel, final DrillScanRel nativeScanRel,
    final String outputColName, final String dirColName, final RexBuilder rb) {

  final RelDataType outputType = hiveScanRel.getRowType().getField(outputColName, false, false).getType();
  final RelDataTypeField inputField = nativeScanRel.getRowType().getField(dirColName, false, false);
  final RexInputRef inputRef =
      rb.makeInputRef(rb.getTypeFactory().createSqlType(SqlTypeName.VARCHAR), inputField.getIndex());
  if (outputType.getSqlTypeName() == SqlTypeName.CHAR) {
    return rb.makeCall(RTRIM, inputRef);
  }

  return rb.makeCast(outputType, inputRef);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:18,代码来源:ConvertHiveParquetScanToDrillParquetScan.java

示例12: visitInputRef

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
public RexNode visitInputRef(RexInputRef inputRef) {
  final RelDataType leftRowType = left.getRowType();
  final RexBuilder rexBuilder = getRexBuilder();
  final int leftCount = leftRowType.getFieldCount();
  if (inputRef.getIndex() < leftCount) {
    final RexNode v = rexBuilder.makeCorrel(leftRowType, id);
    return rexBuilder.makeFieldAccess(v, inputRef.getIndex());
  } else {
    return rexBuilder.makeInputRef(right, inputRef.getIndex() - leftCount);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:RelBuilder.java

示例13: visitProject

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
@Override
public Prel visitProject(ProjectPrel node, Object unused) throws RelConversionException {
  ProjectPrel project = node;
  List<RexNode> exprList = new ArrayList<>();
  boolean rewrite = false;

  List<RelDataTypeField> relDataTypes = new ArrayList();
  int i = 0;
  RexNode flatttenExpr = null;
  for (RexNode rex : project.getChildExps()) {
    RexNode newExpr = rex;
    if (rex instanceof RexCall) {
      RexCall function = (RexCall) rex;
      String functionName = function.getOperator().getName();
      int nArgs = function.getOperands().size();

      if (functionName.equalsIgnoreCase("flatten") ) {
        rewrite = true;
        if (function.getOperands().size() != 1) {
          throw new RelConversionException("Flatten expression expects a single input.");
        }
        newExpr = function.getOperands().get(0);
        RexBuilder builder = new RexBuilder(factory);
        flatttenExpr = builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), i);
      }
    }
    relDataTypes.add(project.getRowType().getFieldList().get(i));
    i++;
    exprList.add(newExpr);
  }
  if (rewrite == true) {
    // TODO - figure out what is the right setting for the traits
    Prel newChild = ((Prel)project.getInput(0)).accept(this, null);
    ProjectPrel newProject = new ProjectPrel(node.getCluster(), project.getTraitSet(), newChild, exprList, new RelRecordType(relDataTypes));
    FlattenPrel flatten = new FlattenPrel(project.getCluster(), project.getTraitSet(), newProject, flatttenExpr);
    return flatten;
  }

  Prel child = ((Prel)project.getInput()).accept(this, null);
  return (Prel) project.copy(project.getTraitSet(), child, exprList, new RelRecordType(relDataTypes));
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:42,代码来源:RewriteProjectToFlatten.java

示例14: visitExchange

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
@Override
public Prel visitExchange(ExchangePrel prel, Void value) throws RuntimeException {
  Prel child = ((Prel)prel.getInput()).accept(this, null);
  // Whenever we encounter a HashToRandomExchangePrel
  //   If MuxExchange is enabled, insert a UnorderedMuxExchangePrel before HashToRandomExchangePrel.
  //   If DeMuxExchange is enabled, insert a UnorderedDeMuxExchangePrel after HashToRandomExchangePrel.
  if (!(prel instanceof HashToRandomExchangePrel)) {
    return (Prel)prel.copy(prel.getTraitSet(), Collections.singletonList(((RelNode)child)));
  }

  Prel newPrel = child;

  final HashToRandomExchangePrel hashPrel = (HashToRandomExchangePrel) prel;
  final List<String> childFields = child.getRowType().getFieldNames();

  List <RexNode> removeUpdatedExpr = null;

  if (isMuxEnabled) {
    // Insert Project Operator with new column that will be a hash for HashToRandomExchange fields
    final List<DistributionField> distFields = hashPrel.getFields();
    final List<String> outputFieldNames = Lists.newArrayList(childFields);
    final RexBuilder rexBuilder = prel.getCluster().getRexBuilder();
    final List<RelDataTypeField> childRowTypeFields = child.getRowType().getFieldList();

    final HashExpressionCreatorHelper<RexNode> hashHelper = new RexNodeBasedHashExpressionCreatorHelper(rexBuilder);
    final List<RexNode> distFieldRefs = Lists.newArrayListWithExpectedSize(distFields.size());
    for(int i=0; i<distFields.size(); i++) {
      final int fieldId = distFields.get(i).getFieldId();
      distFieldRefs.add(rexBuilder.makeInputRef(childRowTypeFields.get(fieldId).getType(), fieldId));
    }

    final List <RexNode> updatedExpr = Lists.newArrayListWithExpectedSize(childRowTypeFields.size());
    removeUpdatedExpr = Lists.newArrayListWithExpectedSize(childRowTypeFields.size());
    for ( RelDataTypeField field : childRowTypeFields) {
      RexNode rex = rexBuilder.makeInputRef(field.getType(), field.getIndex());
      updatedExpr.add(rex);
      removeUpdatedExpr.add(rex);
    }

    outputFieldNames.add(HashPrelUtil.HASH_EXPR_NAME);
    updatedExpr.add(HashPrelUtil.createHashBasedPartitionExpression(distFieldRefs, hashHelper));

    RelDataType rowType = RexUtil.createStructType(prel.getCluster().getTypeFactory(), updatedExpr, outputFieldNames);

    ProjectPrel addColumnprojectPrel = new ProjectPrel(child.getCluster(), child.getTraitSet(), child, updatedExpr, rowType);

    newPrel = new UnorderedMuxExchangePrel(addColumnprojectPrel.getCluster(), addColumnprojectPrel.getTraitSet(),
        addColumnprojectPrel);
  }

  newPrel = new HashToRandomExchangePrel(prel.getCluster(),
      prel.getTraitSet(), newPrel, ((HashToRandomExchangePrel) prel).getFields());

  if (isDeMuxEnabled) {
    HashToRandomExchangePrel hashExchangePrel = (HashToRandomExchangePrel) newPrel;
    // Insert a DeMuxExchange to narrow down the number of receivers
    newPrel = new UnorderedDeMuxExchangePrel(prel.getCluster(), prel.getTraitSet(), hashExchangePrel,
        hashExchangePrel.getFields());
  }

  if ( isMuxEnabled ) {
    // remove earlier inserted Project Operator - since it creates issues down the road in HashJoin
    RelDataType removeRowType = RexUtil.createStructType(newPrel.getCluster().getTypeFactory(), removeUpdatedExpr, childFields);

    ProjectPrel removeColumnProjectPrel = new ProjectPrel(newPrel.getCluster(), newPrel.getTraitSet(), newPrel, removeUpdatedExpr, removeRowType);
    return removeColumnProjectPrel;
  }
  return newPrel;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:70,代码来源:InsertLocalExchangeVisitor.java

示例15: visitExchange

import org.apache.calcite.rex.RexBuilder; //导入方法依赖的package包/类
@Override
public Prel visitExchange(ExchangePrel prel, Void value) throws RuntimeException {
  Prel child = ((Prel)prel.getInput()).accept(this, null);
  // Whenever we encounter a HashToRandomExchangePrel
  //   If MuxExchange is enabled, insert a UnorderedMuxExchangePrel before HashToRandomExchangePrel.
  //   If DeMuxExchange is enabled, insert a UnorderedDeMuxExchangePrel after HashToRandomExchangePrel.
  if (!(prel instanceof HashToRandomExchangePrel)) {
    return (Prel)prel.copy(prel.getTraitSet(), Collections.singletonList(((RelNode)child)));
  }

  Prel newPrel = child;

  final HashToRandomExchangePrel hashPrel = (HashToRandomExchangePrel) prel;
  final List<String> childFields = child.getRowType().getFieldNames();

  List <RexNode> removeUpdatedExpr = null;

  if (isMuxEnabled) {
    // Insert Project Operator with new column that will be a hash for HashToRandomExchange fields
    final List<DistributionField> distFields = hashPrel.getFields();
    final List<String> outputFieldNames = Lists.newArrayList(childFields);
    final RexBuilder rexBuilder = prel.getCluster().getRexBuilder();
    final List<RelDataTypeField> childRowTypeFields = child.getRowType().getFieldList();

    final HashExpressionCreatorHelper<RexNode> hashHelper = new RexNodeBasedHashExpressionCreatorHelper(rexBuilder);
    final List<RexNode> distFieldRefs = Lists.newArrayListWithExpectedSize(distFields.size());
    for(int i=0; i<distFields.size(); i++) {
      final int fieldId = distFields.get(i).getFieldId();
      distFieldRefs.add(rexBuilder.makeInputRef(childRowTypeFields.get(fieldId).getType(), fieldId));
    }

    final List <RexNode> updatedExpr = Lists.newArrayListWithExpectedSize(childRowTypeFields.size());
    removeUpdatedExpr = Lists.newArrayListWithExpectedSize(childRowTypeFields.size());
    for ( RelDataTypeField field : childRowTypeFields) {
      RexNode rex = rexBuilder.makeInputRef(field.getType(), field.getIndex());
      updatedExpr.add(rex);
      removeUpdatedExpr.add(rex);
    }

    outputFieldNames.add(HashPrelUtil.HASH_EXPR_NAME);
    final RexNode distSeed = rexBuilder.makeBigintLiteral(BigDecimal.valueOf(HashPrelUtil.DIST_SEED)); // distribution seed
    updatedExpr.add(HashPrelUtil.createHashBasedPartitionExpression(distFieldRefs, distSeed, hashHelper));

    RelDataType rowType = RexUtil.createStructType(prel.getCluster().getTypeFactory(), updatedExpr, outputFieldNames);

    ProjectPrel addColumnprojectPrel = new ProjectPrel(child.getCluster(), child.getTraitSet(), child, updatedExpr, rowType);

    newPrel = new UnorderedMuxExchangePrel(addColumnprojectPrel.getCluster(), addColumnprojectPrel.getTraitSet(),
        addColumnprojectPrel);
  }

  newPrel = new HashToRandomExchangePrel(prel.getCluster(),
      prel.getTraitSet(), newPrel, ((HashToRandomExchangePrel) prel).getFields());

  if (isDeMuxEnabled) {
    HashToRandomExchangePrel hashExchangePrel = (HashToRandomExchangePrel) newPrel;
    // Insert a DeMuxExchange to narrow down the number of receivers
    newPrel = new UnorderedDeMuxExchangePrel(prel.getCluster(), prel.getTraitSet(), hashExchangePrel,
        hashExchangePrel.getFields());
  }

  if ( isMuxEnabled ) {
    // remove earlier inserted Project Operator - since it creates issues down the road in HashJoin
    RelDataType removeRowType = RexUtil.createStructType(newPrel.getCluster().getTypeFactory(), removeUpdatedExpr, childFields);

    ProjectPrel removeColumnProjectPrel = new ProjectPrel(newPrel.getCluster(), newPrel.getTraitSet(), newPrel, removeUpdatedExpr, removeRowType);
    return removeColumnProjectPrel;
  }
  return newPrel;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:71,代码来源:InsertLocalExchangeVisitor.java


注:本文中的org.apache.calcite.rex.RexBuilder.makeInputRef方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。