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


Java RexInputRef类代码示例

本文整理汇总了Java中org.apache.calcite.rex.RexInputRef的典型用法代码示例。如果您正苦于以下问题:Java RexInputRef类的具体用法?Java RexInputRef怎么用?Java RexInputRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getDistributionMap

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
private Map<Integer, Integer> getDistributionMap(DrillProjectRel project) {
  Map<Integer, Integer> m = new HashMap<Integer, Integer>();

  for (Ord<RexNode> node : Ord.zip(project.getProjects())) {
    // For distribution, either $0 or cast($0 as ...) would keep the distribution after projection.
    if (node.e instanceof RexInputRef) {
      m.put( ((RexInputRef) node.e).getIndex(), node.i);
    } else if (node.e.isA(SqlKind.CAST)) {
      RexNode operand = ((RexCall) node.e).getOperands().get(0);
      if (operand instanceof RexInputRef) {
        m.put(((RexInputRef) operand).getIndex(), node.i);
      }
    }
  }
  return m;

}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:ProjectPrule.java

示例2: containsStarColumnInProject

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
public static boolean containsStarColumnInProject(RelDataType inputRowType, List<RexNode> projExprs) {
  if (! inputRowType.isStruct()) {
    return false;
  }

  for (RexNode expr : projExprs) {
    if (expr instanceof RexInputRef) {
      String name = inputRowType.getFieldNames().get(((RexInputRef) expr).getIndex());

      if (name.startsWith(STAR_COLUMN)) {
        return true;
      }
    }
  }

  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:StarColumnHelper.java

示例3: getSimpleFieldCount

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
private int getSimpleFieldCount() {
  int cnt = 0;

  final ComplexFieldWithNamedSegmentIdentifier complexFieldIdentifer = new ComplexFieldWithNamedSegmentIdentifier();
  // SimpleField, either column name, or complex field reference with only named segment ==> no array segment
  // a, a.b.c are simple fields.
  // a[1].b.c, a.b[1], a.b.c[1] are not simple fields, since they all contain array segment.
  //  a + b, a * 10 + b, etc are not simple fields, since they are expressions.
  for (RexNode expr : this.getProjects()) {
    if (expr instanceof RexInputRef) {
      // Simple Field reference.
      cnt ++;
    } else if (expr instanceof RexCall && expr.accept(complexFieldIdentifer)) {
      // Complex field with named segments only.
      cnt ++;
    }
  }
  return cnt;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:20,代码来源:DrillProjectRelBase.java

示例4: visitCall

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
@Override
public Boolean visitCall(RexCall call) {
  if (call.getOperator() == SqlStdOperatorTable.ITEM) {
    final RexNode op0 = call.getOperands().get(0);
    final RexNode op1 = call.getOperands().get(1);

    if (op0 instanceof RexInputRef &&
        op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
      return true;
    } else if (op0 instanceof RexCall &&
        op1 instanceof RexLiteral && ((RexLiteral) op1).getTypeName() == SqlTypeName.CHAR) {
      return op0.accept(this);
    }
  }

  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:18,代码来源:DrillProjectRelBase.java

示例5: createColumnFormatConversion

import org.apache.calcite.rex.RexInputRef; //导入依赖的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

示例6: visit

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
@Override
public RelNode visit(final LogicalFilter filter) {
  final RelBuilder relBuilder = newCalciteRelBuilderWithoutContext(filter.getCluster());
  RelNode input = filter.getInput().accept(this);
  relBuilder.push(input);

  RexNode newCondition = filter.getCondition().accept(new RexShuttle() {
    @Override
    public RexNode visitInputRef(RexInputRef inputRef) {
      return relBuilder.field(filter.getRowType().getFieldNames().get(inputRef.getIndex()));
    }
  });

  relBuilder.filter(newCondition);
  return relBuilder.build();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:IncrementalUpdateUtils.java

示例7: findItemInputRefIndex

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
private static int findItemInputRefIndex(RexNode rexNode) {
  if (rexNode == null) {
    return -1;
  }

  if (rexNode instanceof RexInputRef) {
    return ((RexInputRef) rexNode).getIndex();
  }

  if (rexNode instanceof RexCall) {
    String functionName = ((RexCall) rexNode).getOperator().getName();
    if (functionName.equalsIgnoreCase("item")) {
      return findItemInputRefIndex(((RexCall) rexNode).getOperands().get(0));
    }
  }

  return -1;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:PushProjectPastFlattenRule.java

示例8: visitInputRef

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
@Override
public RexNode visitInputRef(RexInputRef inputRef) {

  // see if we have a reference to our child.
  if(inputRef instanceof MutableRexInputRef && refs.contains(inputRef)){
    return inputRef;
  }

  if( !(inputRef instanceof MutableRexInputRef) ){
    MutableRexInputRef previousPointer = refMap.get(inputRef.getIndex());
    if(previousPointer != null){
      return previousPointer;
    }
  }

  // create a new holder to add to the child of this.
  final MutableRexInputRef inputPointer = new MutableRexInputRef(inputRef.getType());
  holders.add(new ProjectSlotHolder(inputRef, inputPointer));

  if( !(inputRef instanceof MutableRexInputRef) ){
    refMap.put(inputRef.getIndex(), inputPointer);
  }
  return inputPointer;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:25,代码来源:RewriteProjectToFlattenRule.java

示例9: getDistributionMap

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
private Map<Integer, Integer> getDistributionMap(ProjectRel project) {
  Map<Integer, Integer> m = new HashMap<Integer, Integer>();

  for (Ord<RexNode> node : Ord.zip(project.getProjects())) {
    // For distribution, either $0 or cast($0 as ...) would keep the distribution after projection.
    if (node.e instanceof RexInputRef) {
      m.put( ((RexInputRef) node.e).getIndex(), node.i);
    } else if (node.e.isA(SqlKind.CAST)) {
      RexNode operand = ((RexCall) node.e).getOperands().get(0);
      if (operand instanceof RexInputRef) {
        m.put(((RexInputRef) operand).getIndex(), node.i);
      }
    }
  }
  return m;

}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:18,代码来源:ProjectPrule.java

示例10: isSimpleColumnSelection

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
public static boolean isSimpleColumnSelection(Project project) {
  HashSet<Integer> inputRefReferenced = new HashSet<>();
  for (Pair<RexNode, String> proj : project.getNamedProjects()) {
    if (proj.getKey().getKind() != SqlKind.INPUT_REF) {
      return false;
    }
    RexInputRef inputRef = (RexInputRef) proj.getKey();
    // If the input reference is again referenced, then it is not a simple column selection (since it is not a permutation).
    if (inputRefReferenced.contains(inputRef.getIndex())) {
      return false;
    }
    final String nameOfProjectField = proj.getValue();
    final String nameOfInput = project.getInput().getRowType().getFieldNames().get(inputRef.getIndex());
    // Renaming a column is not a simple column selection
    if (nameOfProjectField == null || !nameOfProjectField.equals(nameOfInput)) {
      return false;
    }
    inputRefReferenced.add(inputRef.getIndex());
  }
  return true;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:MoreRelOptUtil.java

示例11: getRootField

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
RelDataTypeField getRootField(RexInputRef inputRef) {
	int fieldOffset = inputRef.getIndex();
	for (RelNode input : inputs) {
		RelDataType rowType = input.getRowType();
		if (rowType == null) {
			// TODO:  remove this once leastRestrictive
			// is correctly implemented
			return null;
		}
		if (fieldOffset < rowType.getFieldCount()) {
			return rowType.getFieldList().get(fieldOffset);
		}
		fieldOffset -= rowType.getFieldCount();
	}
	throw new AssertionError();
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:17,代码来源:SqlToRelConverter.java

示例12: createCaseExpression

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
private RexNode createCaseExpression(RexInputRef nullInputRef, RexLiteral lit, RexNode rexNode) {
	RexNode[] caseOperands = new RexNode[3];

	// Construct a CASE expression to handle the null indicator.
	//
	// This also covers the case where a left correlated subquery
	// projects fields from outer relation. Since LOJ cannot produce
	// nulls on the LHS, the projection now need to make a nullable LHS
	// reference using a nullability indicator. If this this indicator
	// is null, it means the subquery does not produce any value. As a
	// result, any RHS ref by this usbquery needs to produce null value.

	// WHEN indicator IS NULL
	caseOperands[0] = rexBuilder.makeCall(SqlStdOperatorTable.IS_NULL, new RexInputRef(nullInputRef.getIndex(), typeFactory.createTypeWithNullability(nullInputRef.getType(), true)));

	// THEN CAST(NULL AS newInputTypeNullable)
	caseOperands[1] = rexBuilder.makeCast(typeFactory.createTypeWithNullability(rexNode.getType(), true), lit);

	// ELSE cast (newInput AS newInputTypeNullable) END
	caseOperands[2] = rexBuilder.makeCast(typeFactory.createTypeWithNullability(rexNode.getType(), true), rexNode);

	return rexBuilder.makeCall(SqlStdOperatorTable.CASE, caseOperands);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:24,代码来源:FlinkRelDecorrelator.java

示例13: visitFieldAccess

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
@Override
public RexNode visitFieldAccess(RexFieldAccess fieldAccess) {
	if (cm.mapFieldAccessToCorVar.containsKey(fieldAccess)) {
		// if it is a corVar, change it to be input ref.
		Correlation corVar = cm.mapFieldAccessToCorVar.get(fieldAccess);

		// corVar offset should point to the leftInput of currentRel,
		// which is the Correlator.
		RexNode newRexNode = new RexInputRef(corVar.field, fieldAccess.getType());

		if (projectPulledAboveLeftCorrelator && (nullIndicator != null)) {
			// need to enforce nullability by applying an additional
			// cast operator over the transformed expression.
			newRexNode = createCaseExpression(nullIndicator, rexBuilder.constantNull(), newRexNode);
		}
		return newRexNode;
	}
	return fieldAccess;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:20,代码来源:FlinkRelDecorrelator.java

示例14: visitInputRef

import org.apache.calcite.rex.RexInputRef; //导入依赖的package包/类
@Override
public RexNode visitInputRef(RexInputRef inputRef) {
	if (currentRel instanceof LogicalCorrelate) {
		// if this rel references corVar
		// and now it needs to be rewritten
		// it must have been pulled above the Correlator
		// replace the input ref to account for the LHS of the
		// Correlator
		final int leftInputFieldCount = ((LogicalCorrelate) currentRel).getLeft().getRowType().getFieldCount();
		RelDataType newType = inputRef.getType();

		if (projectPulledAboveLeftCorrelator) {
			newType = typeFactory.createTypeWithNullability(newType, true);
		}

		int pos = inputRef.getIndex();
		RexInputRef newInputRef = new RexInputRef(leftInputFieldCount + pos, newType);

		if ((isCount != null) && isCount.contains(pos)) {
			return createCaseExpression(newInputRef, rexBuilder.makeExactLiteral(BigDecimal.ZERO), newInputRef);
		} else {
			return newInputRef;
		}
	}
	return inputRef;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:27,代码来源:FlinkRelDecorrelator.java

示例15: createColumnFormatConversion

import org.apache.calcite.rex.RexInputRef; //导入依赖的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


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