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


Java RelFieldCollation.getFieldIndex方法代码示例

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


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

示例1: planSort

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private PlannerOp planSort(EnumerableSort op, RelDataType rowType) {
    PlannerOp input = convertRelNode(op.getInput(), rowType, false);
    RelCollation collation = op.getCollation();
    List<RelFieldCollation> fieldCollations = collation.getFieldCollations();
    boolean[] directions = new boolean[fieldCollations.size()];
    int[] fields = new int[fieldCollations.size()];
    int i = 0;
    for (RelFieldCollation col : fieldCollations) {
        RelFieldCollation.Direction direction = col.getDirection();
        int index = col.getFieldIndex();
        directions[i] = direction == RelFieldCollation.Direction.ASCENDING
            || direction == RelFieldCollation.Direction.STRICTLY_ASCENDING;
        fields[i++] = index;
    }
    return new SortOp(input, directions, fields);

}
 
开发者ID:diennea,项目名称:herddb,代码行数:18,代码来源:CalcitePlanner.java

示例2: implementRewrite

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
@Override
public void implementRewrite(RewriteImplementor implementor) {
    implementor.visitChild(this, getInput());

    // No need to rewrite "order by" applied on non-olap context.
    // Occurs in sub-query like "select ... from (...) inner join (...) order by ..."
    if (this.context.realization == null)
        return;

    for (RelFieldCollation fieldCollation : this.collation.getFieldCollations()) {
        int index = fieldCollation.getFieldIndex();
        SQLDigest.OrderEnum order = getOrderEnum(fieldCollation.getDirection());
        OLAPRel olapChild = (OLAPRel) this.getInput();
        TblColRef orderCol = olapChild.getColumnRowType().getAllColumns().get(index);
        this.context.addSort(orderCol, order);
        this.context.storageContext.markSort();
    }

    this.rowType = this.deriveRowType();
    this.columnRowType = buildColumnRowType();
}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:OLAPSortRel.java

示例3: rewriteRel

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
public void rewriteRel(Sort rel) {
  RelCollation oldCollation = rel.getCollation();
  final RelNode oldChild = rel.getInput();
  final RelNode newChild = getNewForOldRel(oldChild);
  final Mappings.TargetMapping mapping =
      getNewForOldInputMapping(oldChild);

  // validate
  for (RelFieldCollation field : oldCollation.getFieldCollations()) {
    int oldInput = field.getFieldIndex();
    RelDataType sortFieldType =
        oldChild.getRowType().getFieldList().get(oldInput).getType();
    if (sortFieldType.isStruct()) {
      // TODO jvs 10-Feb-2005
      throw Util.needToImplement("sorting on structured types");
    }
  }
  RelCollation newCollation = RexUtil.apply(mapping, oldCollation);
  Sort newRel =
      LogicalSort.create(newChild, newCollation, rel.offset, rel.fetch);
  setNewForOldRel(rel, newRel);
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:RelStructuredTypeFlattener.java

示例4: getOperandMonotonicity

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
@Override public SqlMonotonicity getOperandMonotonicity(int ordinal) {
  RexNode operand = operands.get(ordinal);

  if (operand instanceof RexInputRef) {
    for (RelCollation ic : inputCollations) {
      if (ic.getFieldCollations().isEmpty()) {
        continue;
      }

      for (RelFieldCollation rfc : ic.getFieldCollations()) {
        if (rfc.getFieldIndex() == ((RexInputRef) operand).getIndex()) {
          return rfc.direction.monotonicity();
          // TODO: Is it possible to have more than one RelFieldCollation for a RexInputRef?
        }
      }
    }
  } else if (operand instanceof RexCall) {
    final RexCallBinding binding =
        RexCallBinding.create(typeFactory, (RexCall) operand, inputCollations);
    return ((RexCall) operand).getOperator().getMonotonicity(binding);
  }

  return SqlMonotonicity.NOT_MONOTONIC;
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:RexCallBinding.java

示例5: getDistributionField

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private List<DistributionField> getDistributionField(DrillSortRel rel) {
  List<DistributionField> distFields = Lists.newArrayList();

  for (RelFieldCollation relField : rel.getCollation().getFieldCollations()) {
    DistributionField field = new DistributionField(relField.getFieldIndex());
    distFields.add(field);
  }

  return distFields;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:SortPrule.java

示例6: getDistributionFieldsFromCollation

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private List<DistributionField> getDistributionFieldsFromCollation(Window.Group window) {
  List<DistributionField> distFields = Lists.newArrayList();

  for (RelFieldCollation relField : window.collation().getFieldCollations()) {
    DistributionField field = new DistributionField(relField.getFieldIndex());
    distFields.add(field);
  }

  return distFields;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:11,代码来源:WindowPrule.java

示例7: getDistributionField

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
private List<DistributionField> getDistributionField(SortRel rel) {
  List<DistributionField> distFields = Lists.newArrayList();

  for (RelFieldCollation relField : rel.getCollation().getFieldCollations()) {
    DistributionField field = new DistributionField(relField.getFieldIndex());
    distFields.add(field);
  }

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

示例8: collationsCompatible

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
/** Check if it is possible to exploit native CQL sorting for a given collation.
 *
 * @return True if it is possible to achieve this sort in Cassandra
 */
private boolean collationsCompatible(RelCollation sortCollation,
    RelCollation implicitCollation) {
  List<RelFieldCollation> sortFieldCollations = sortCollation.getFieldCollations();
  List<RelFieldCollation> implicitFieldCollations = implicitCollation.getFieldCollations();

  if (sortFieldCollations.size() > implicitFieldCollations.size()) {
    return false;
  }
  if (sortFieldCollations.size() == 0) {
    return true;
  }

  // Check if we need to reverse the order of the implicit collation
  boolean reversed = reverseDirection(sortFieldCollations.get(0).getDirection())
      == implicitFieldCollations.get(0).getDirection();

  for (int i = 0; i < sortFieldCollations.size(); i++) {
    RelFieldCollation sorted = sortFieldCollations.get(i);
    RelFieldCollation implied = implicitFieldCollations.get(i);

    // Check that the fields being sorted match
    if (sorted.getFieldIndex() != implied.getFieldIndex()) {
      return false;
    }

    // Either all fields must be sorted in the same direction
    // or the opposite direction based on whether we decided
    // if the sort direction should be reversed above
    RelFieldCollation.Direction sortDirection = sorted.getDirection();
    RelFieldCollation.Direction implicitDirection = implied.getDirection();
    if ((!reversed && sortDirection != implicitDirection)
        || (reversed && reverseDirection(sortDirection) != implicitDirection)) {
      return false;
    }
  }

  return true;
}
 
开发者ID:apache,项目名称:calcite,代码行数:43,代码来源:CassandraRules.java

示例9: getMonotonicity

import org.apache.calcite.rel.RelFieldCollation; //导入方法依赖的package包/类
public SqlMonotonicity getMonotonicity(String columnName) {
  final int i = rowType.getFieldNames().indexOf(columnName);
  if (i >= 0) {
    for (RelCollation collation : table.getStatistic().getCollations()) {
      final RelFieldCollation fieldCollation =
          collation.getFieldCollations().get(0);
      if (fieldCollation.getFieldIndex() == i) {
        return fieldCollation.direction.monotonicity();
      }
    }
  }
  return SqlMonotonicity.NOT_MONOTONIC;
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:RelOptTableImpl.java


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