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


Java RelDataTypeField类代码示例

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


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

示例1: getField

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
public RelDataTypeField getField(RelDataTypeFactory typeFactory, String fieldName) {

    /* First check if this field name exists in our field list */
    for (RelDataTypeField f : fields) {
      if (fieldName.equalsIgnoreCase(f.getName())) {
        return f;
      }
    }

    /* This field does not exist in our field list add it */
    RelDataTypeField newField = new RelDataTypeFieldImpl(fieldName, fields.size(), typeFactory.createTypeWithNullability(typeFactory.createSqlType(SqlTypeName.ANY), true));

    /* Add the name to our list of field names */
    fields.add(newField);

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

示例2: convert

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
public static DrillJoinRel convert(Join join, ConversionContext context) throws InvalidRelException{
  RelNode left = context.toRel(join.getLeft());
  RelNode right = context.toRel(join.getRight());

  List<RexNode> joinConditions = new ArrayList<RexNode>();
  // right fields appear after the LHS fields.
  final int rightInputOffset = left.getRowType().getFieldCount();
  for (JoinCondition condition : join.getConditions()) {
    RelDataTypeField leftField = left.getRowType().getField(ExprHelper.getFieldName(condition.getLeft()), true, false);
    RelDataTypeField rightField = right.getRowType().getField(ExprHelper.getFieldName(condition.getRight()), true, false);
      joinConditions.add(
          context.getRexBuilder().makeCall(
              SqlStdOperatorTable.EQUALS,
              context.getRexBuilder().makeInputRef(leftField.getType(), leftField.getIndex()),
              context.getRexBuilder().makeInputRef(rightField.getType(), rightInputOffset + rightField.getIndex())
              )
              );
  }
  RexNode rexCondition = RexUtil.composeConjunction(context.getRexBuilder(), joinConditions, false);
  DrillJoinRel joinRel = new DrillJoinRel(context.getCluster(), context.getLogicalTraits(), left, right, rexCondition, join.getJoinType());

  return joinRel;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:DrillJoinRel.java

示例3: apply

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
public boolean apply(Join join, JoinRelType joinType, RexNode exp) {
  if (joinType != JoinRelType.INNER) {
    return true;  // In OUTER join, we could not pull-up the filter.
                  // All we can do is keep the filter with JOIN, and
                  // then decide whether the filter could be pushed down
                  // into LEFT/RIGHT.
  }

  List<RexNode> tmpLeftKeys = Lists.newArrayList();
  List<RexNode> tmpRightKeys = Lists.newArrayList();
  List<RelDataTypeField> sysFields = Lists.newArrayList();

  RexNode remaining = RelOptUtil.splitJoinCondition(sysFields, join.getLeft(), join.getRight(), exp, tmpLeftKeys, tmpRightKeys, null, null);

  if (remaining.isAlwaysTrue()) {
    return true;
  }

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

示例4: verifyRowType

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
private static void verifyRowType(final ImmutableList<ImmutableList<RexLiteral>> tuples, RelDataType rowType){
    for (List<RexLiteral> tuple : tuples) {
      assert (tuple.size() == rowType.getFieldCount());

      for (Pair<RexLiteral, RelDataTypeField> pair : Pair.zip(tuple, rowType.getFieldList())) {
        RexLiteral literal = (RexLiteral) pair.left;
        RelDataType fieldType = ((RelDataTypeField) pair.right).getType();

        if ((!(RexLiteral.isNullLiteral(literal)))
            && (!(SqlTypeUtil.canAssignFrom(fieldType, literal.getType())))) {
          throw new AssertionError("to " + fieldType + " from " + literal);
        }
      }
    }

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

示例5: deriveCopiedRowTypeFromInput

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
/**
 * Derive rowType for the copied WindowPrel based on input.
 * When copy() is called, the input might be different from the current one's input.
 * We have to use the new input's field in the copied WindowPrel.
 */
private RelDataType deriveCopiedRowTypeFromInput(final RelNode input) {
  final RelDataType inputRowType = input.getRowType();
  final RelDataType windowRowType = this.getRowType();

  final List<RelDataTypeField> fieldList = new ArrayList<>(inputRowType.getFieldList());
  final int inputFieldCount = inputRowType.getFieldCount();
  final int windowFieldCount = windowRowType.getFieldCount();

  for (int i = inputFieldCount; i < windowFieldCount; i++) {
    fieldList.add(windowRowType.getFieldList().get(i));
  }

  final RelDataType rowType = this.getCluster().getRexBuilder().getTypeFactory().createStructType(fieldList);

  return rowType;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:22,代码来源:WindowPrel.java

示例6: createColumnFormatConversion

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

示例7: visit

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
@Override
public RelNode visit(LogicalJoin join) {
  // to the best of my knowledge join.systemFieldList is always empty
  Preconditions.checkState(join.getSystemFieldList().isEmpty(), "join.systemFieldList is not empty!");

  final RelNode left = join.getLeft().accept(this);
  final RelNode right = join.getRight().accept(this);

  return new LogicalJoin(
    cluster,
    copyOf(join.getTraitSet()),
    left,
    right,
    copyOf(join.getCondition()),
    join.getVariablesSet(),
    join.getJoinType(),
    join.isSemiJoinDone(),
    ImmutableList.<RelDataTypeField>of()
  );
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:CopyWithCluster.java

示例8: projectInvisibleColumn

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
@Override
public TableScan projectInvisibleColumn(String name) {
  RelDataTypeField addedField = getRowType().getField(name, false, false);
  if(addedField != null){
    return this;
  }

  final FieldInfoBuilder infoBuilder = new FieldInfoBuilder(getCluster().getTypeFactory());
  infoBuilder.addAll(getRowType().getFieldList());

  // hardcoded since our only invisible column is bigint. This hack will go away once we remove OldScanCrel
  final RelDataType type = CompleteType.BIGINT.toCalciteType(getCluster().getTypeFactory());
  infoBuilder.add(name, type);

  return new OldScanCrel(
    getCluster(),
    getTable(),
    getTraitSet(),
    infoBuilder.build(),
    getGroupScan(),
    layoutInfo,
    getRowCountDiscount());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:24,代码来源:OldScanCrel.java

示例9: visit

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
@Override
public RelNode visit(LogicalProject project) {
  RelNode input = project.getInput().accept(this);
  RelDataType incomingRowType = input.getRowType();
  List<RexNode> newProjects;
  RelDataTypeField modField = incomingRowType.getField(UPDATE_COLUMN, false, false);
  if (modField == null) {
    return project;
  }
  newProjects = FluentIterable.from(project.getProjects())
    .append(new RexInputRef(modField.getIndex(), modField.getType()))
    .toList();
  FieldInfoBuilder fieldInfoBuilder = new FieldInfoBuilder(project.getCluster().getTypeFactory());
  for (RelDataTypeField field : project.getRowType().getFieldList()) {
    fieldInfoBuilder.add(field);
  }
  fieldInfoBuilder.add(UPDATE_COLUMN, modField.getType());
  return new LogicalProject(
    project.getCluster(),
    project.getTraitSet(),
    input,
    newProjects,
    fieldInfoBuilder.build()
  );
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:26,代码来源:IncrementalUpdateUtils.java

示例10: buildJoinCondition

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
private RexNode buildJoinCondition(RelNode convertedLeft, RelNode convertedRight, List<Integer> leftKeys,
    List<Integer> rightKeys, List<Boolean> filterNulls, RexBuilder builder) {
  List<RexNode> equijoinList = Lists.newArrayList();
  final int numLeftFields = convertedLeft.getRowType().getFieldCount();
  List<RelDataTypeField> leftTypes = convertedLeft.getRowType().getFieldList();
  List<RelDataTypeField> rightTypes = convertedRight.getRowType().getFieldList();

  for (int i=0; i < leftKeys.size(); i++) {
    int leftKeyOrdinal = leftKeys.get(i).intValue();
    int rightKeyOrdinal = rightKeys.get(i).intValue();

    equijoinList.add(builder.makeCall(
        filterNulls.get(i) ? SqlStdOperatorTable.EQUALS : SqlStdOperatorTable.IS_NOT_DISTINCT_FROM,
        builder.makeInputRef(leftTypes.get(leftKeyOrdinal).getType(), leftKeyOrdinal),
        builder.makeInputRef(rightTypes.get(rightKeyOrdinal).getType(), rightKeyOrdinal + numLeftFields)
    ));
  }
  return RexUtil.composeConjunction(builder, equijoinList, false);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:JoinRule.java

示例11: apply

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
public boolean apply(Join join, JoinRelType joinType, RexNode exp) {
  if (joinType != JoinRelType.INNER) {
    return true;  // In OUTER join, we could not pull-up the filter.
                  // All we can do is keep the filter with JOIN, and
                  // then decide whether the filter could be pushed down
                  // into LEFT/RIGHT.
  }

  List<RexNode> tmpLeftKeys = Lists.newArrayList();
  List<RexNode> tmpRightKeys = Lists.newArrayList();
  List<RelDataTypeField> sysFields = Lists.newArrayList();
  List<Integer> filterNulls = Lists.newArrayList();

  RexNode remaining = RelOptUtil.splitJoinCondition(sysFields, join.getLeft(), join.getRight(),
      exp, tmpLeftKeys, tmpRightKeys, filterNulls, null);

  return remaining.isAlwaysTrue();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:FilterJoinRulesUtil.java

示例12: verifyRowType

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
private static void verifyRowType(final ImmutableList<ImmutableList<RexLiteral>> tuples, RelDataType rowType){
    for (List<RexLiteral> tuple : tuples) {
      assert (tuple.size() == rowType.getFieldCount());

      for (Pair<RexLiteral, RelDataTypeField> pair : Pair.zip(tuple, rowType.getFieldList())) {
        RexLiteral literal = pair.left;
        RelDataType fieldType = pair.right.getType();

        if ((!(RexLiteral.isNullLiteral(literal)))
            && (!(SqlTypeUtil.canAssignFrom(fieldType, literal.getType())))) {
          throw new AssertionError("to " + fieldType + " from " + literal);
        }
      }
    }

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

示例13: convert

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
public static JoinRel convert(Join join, ConversionContext context) throws InvalidRelException{
  RelNode left = context.toRel(join.getLeft());
  RelNode right = context.toRel(join.getRight());

  List<RexNode> joinConditions = new ArrayList<RexNode>();
  // right fields appear after the LHS fields.
  final int rightInputOffset = left.getRowType().getFieldCount();
  for (JoinCondition condition : join.getConditions()) {
    RelDataTypeField leftField = left.getRowType().getField(ExprHelper.getFieldName(condition.getLeft()), true, false);
    RelDataTypeField rightField = right.getRowType().getField(ExprHelper.getFieldName(condition.getRight()), true, false);
      joinConditions.add(
          context.getRexBuilder().makeCall(
              SqlStdOperatorTable.EQUALS,
              context.getRexBuilder().makeInputRef(leftField.getType(), leftField.getIndex()),
              context.getRexBuilder().makeInputRef(rightField.getType(), rightInputOffset + rightField.getIndex())
              )
              );
  }
  RexNode rexCondition = RexUtil.composeConjunction(context.getRexBuilder(), joinConditions, false);
  JoinRel joinRel = new JoinRel(context.getCluster(), context.getLogicalTraits(), left, right, rexCondition, join.getJoinType());

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

示例14: decodeAllFields

import org.apache.calcite.rel.type.RelDataTypeField; //导入依赖的package包/类
/**
 * Decode all fields that are global dictionary encoded.
 * It adds a dictionary lookup operations on top of current operation.
 * @return dictionary lookup operator who input is current prel.
 */
DictionaryLookupPrel decodeAllFields() {
  final List<RelDataTypeField> newFieldList = Lists.newArrayList();
  final List<RelDataTypeField> oldFieldList = prel.getRowType().getFieldList();
  final List<GlobalDictionaryFieldInfo> fieldsToDecode = Lists.newArrayList();
  for (int i = 0; i < fields.length; ++i) {
    if (fields[i] != null) {
      final RelDataTypeField oldField = oldFieldList.get(i);
      fieldsToDecode.add(fields[i]);
      newFieldList.add(new RelDataTypeFieldImpl(oldField.getName(), oldField.getIndex(), fields[i].getRelDataTypeField().getType()));
    } else {
      newFieldList.add(oldFieldList.get(i));
    }
  }

  return new DictionaryLookupPrel(
    prel.getCluster(),
    prel.getTraitSet(),
    prel,
    toRowDataType(newFieldList, prel.getCluster().getTypeFactory()),
    fieldsToDecode);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:27,代码来源:PrelWithDictionaryInfo.java

示例15: visit

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


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