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


Java AggregateCall.getName方法代码示例

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


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

示例1: getPhysicalOperator

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
  Prel child = (Prel) this.getInput();

  PhysicalOperator childPOP = child.getPhysicalOperator(creator);

  final List<String> childFields = getInput().getRowType().getFieldNames();

  // We don't support distinct partitions
  checkState(groups.size() == 1, "Only one window is expected in WindowPrel");

  Group window = groups.get(0);
  List<NamedExpression> withins = Lists.newArrayList();
  List<NamedExpression> aggs = Lists.newArrayList();
  List<Order.Ordering> orderings = Lists.newArrayList();

  for (int group : BitSets.toIter(window.keys)) {
    FieldReference fr = new FieldReference(childFields.get(group), ExpressionPosition.UNKNOWN);
    withins.add(new NamedExpression(fr, fr));
  }

  for (AggregateCall aggCall : window.getAggregateCalls(this)) {
    FieldReference ref = new FieldReference(aggCall.getName());
    LogicalExpression expr = toDrill(aggCall, childFields);
    aggs.add(new NamedExpression(expr, ref));
  }

  for (RelFieldCollation fieldCollation : window.orderKeys.getFieldCollations()) {
    orderings.add(new Order.Ordering(fieldCollation.getDirection(), new FieldReference(childFields.get(fieldCollation.getFieldIndex())), fieldCollation.nullDirection));
  }

  WindowPOP windowPOP = new WindowPOP(
      childPOP,
      withins.toArray(new NamedExpression[withins.size()]),
      aggs.toArray(new NamedExpression[aggs.size()]),
      orderings.toArray(new Order.Ordering[orderings.size()]),
      Long.MIN_VALUE, //TODO: Get first/last to work
      Long.MIN_VALUE);

  creator.addMetadata(this, windowPOP);
  return windowPOP;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:43,代码来源:WindowPrel.java

示例2: getPhysicalOperator

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
  Prel child = (Prel) this.getInput();

  PhysicalOperator childPOP = child.getPhysicalOperator(creator);

  final List<String> childFields = getInput().getRowType().getFieldNames();

  // We don't support distinct partitions
  checkState(groups.size() == 1, "Only one window is expected in WindowPrel");

  Group window = groups.get(0);
  List<NamedExpression> withins = Lists.newArrayList();
  List<NamedExpression> aggs = Lists.newArrayList();
  List<Order.Ordering> orderings = Lists.newArrayList();

  for (int group : BitSets.toIter(window.keys)) {
    FieldReference fr = new FieldReference(childFields.get(group));
    withins.add(new NamedExpression(fr, fr));
  }

  for (AggregateCall aggCall : window.getAggregateCalls(this)) {
    FieldReference ref = new FieldReference(aggCall.getName());
    LogicalExpression expr = toExpr(aggCall, childFields);
    aggs.add(new NamedExpression(expr, ref));
  }

  for (RelFieldCollation fieldCollation : window.orderKeys.getFieldCollations()) {
    orderings.add(new Order.Ordering(fieldCollation.getDirection(), new FieldReference(childFields.get(fieldCollation.getFieldIndex())), fieldCollation.nullDirection));
  }

  WindowPOP windowPOP = new WindowPOP(
      childPOP,
      withins,
      aggs,
      orderings,
      window.isRows,
      WindowPOP.newBound(window.lowerBound),
      WindowPOP.newBound(window.upperBound));

  creator.addMetadata(this, windowPOP);
  return windowPOP;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:44,代码来源:WindowPrel.java

示例3: getPhysicalOperator

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
  Prel child = (Prel) this.getInput();

  PhysicalOperator childPOP = child.getPhysicalOperator(creator);

  final List<String> childFields = getInput().getRowType().getFieldNames();

  // We don't support distinct partitions
  checkState(groups.size() == 1, "Only one window is expected in WindowPrel");

  Group window = groups.get(0);
  List<NamedExpression> withins = Lists.newArrayList();
  List<NamedExpression> aggs = Lists.newArrayList();
  List<Order.Ordering> orderings = Lists.newArrayList();

  for (int group : BitSets.toIter(window.keys)) {
    FieldReference fr = new FieldReference(childFields.get(group), ExpressionPosition.UNKNOWN);
    withins.add(new NamedExpression(fr, fr));
  }

  for (AggregateCall aggCall : window.getAggregateCalls(this)) {
    FieldReference ref = new FieldReference(aggCall.getName());
    LogicalExpression expr = toDrill(aggCall, childFields);
    aggs.add(new NamedExpression(expr, ref));
  }

  for (RelFieldCollation fieldCollation : window.orderKeys.getFieldCollations()) {
    orderings.add(new Order.Ordering(fieldCollation.getDirection(), new FieldReference(childFields.get(fieldCollation.getFieldIndex())), fieldCollation.nullDirection));
  }

  WindowPOP windowPOP = new WindowPOP(
      childPOP,
      withins,
      aggs,
      orderings,
      window.isRows,
      WindowPOP.newBound(window.lowerBound),
      WindowPOP.newBound(window.upperBound));

  creator.addMetadata(this, windowPOP);
  return windowPOP;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:44,代码来源:WindowPrel.java

示例4: collectCounts

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
/**
 * Collects counts for each aggregation call.
 * Will return empty result map if was not able to determine count for at least one aggregation call,
 *
 * For each aggregate call will determine if count can be calculated. Collects counts only for COUNT function.
 * For star, not null expressions and implicit columns sets count to total record number.
 * For other cases obtains counts from group scan operator. Also count can not be calculated for parition columns.
 *
 * @param agg aggregate relational expression
 * @param scan scan relational expression
 * @param project project relational expression
 * @return result map where key is count column name, value is count value
 */
private Map<String, Long> collectCounts(PlannerSettings settings, DrillAggregateRel agg, DrillScanRel scan, DrillProjectRel project) {
  final Set<String> implicitColumnsNames = ColumnExplorer.initImplicitFileColumns(settings.getOptions()).keySet();
  final GroupScan oldGrpScan = scan.getGroupScan();
  final long totalRecordCount = oldGrpScan.getScanStats(settings).getRecordCount();
  final LinkedHashMap<String, Long> result = new LinkedHashMap<>();

  for (int i = 0; i < agg.getAggCallList().size(); i++) {
    AggregateCall aggCall = agg.getAggCallList().get(i);
  //for (AggregateCall aggCall : agg.getAggCallList()) {
    long cnt;

    // rule can be applied only for count function, return empty counts
    if (!"count".equalsIgnoreCase(aggCall.getAggregation().getName()) ) {
      return ImmutableMap.of();
    }

    if (containsStarOrNotNullInput(aggCall, agg)) {
      cnt = totalRecordCount;

    } else if (aggCall.getArgList().size() == 1) {
      // count(columnName) ==> Agg ( Scan )) ==> columnValueCount
      int index = aggCall.getArgList().get(0);

      if (project != null) {
        // project in the middle of Agg and Scan : Only when input of AggCall is a RexInputRef in Project, we find the index of Scan's field.
        // For instance,
        // Agg - count($0)
        //  \
        //  Proj - Exp={$1}
        //    \
        //   Scan (col1, col2).
        // return count of "col2" in Scan's metadata, if found.
        if (!(project.getProjects().get(index) instanceof RexInputRef)) {
          return ImmutableMap.of(); // do not apply for all other cases.
        }

        index = ((RexInputRef) project.getProjects().get(index)).getIndex();
      }

      String columnName = scan.getRowType().getFieldNames().get(index).toLowerCase();

      // for implicit column count will the same as total record count
      if (implicitColumnsNames.contains(columnName)) {
        cnt = totalRecordCount;
      } else {
        SchemaPath simplePath = SchemaPath.getSimplePath(columnName);

        if (ColumnExplorer.isPartitionColumn(settings.getOptions(), simplePath)) {
          return ImmutableMap.of();
        }

        cnt = oldGrpScan.getColumnValueCount(simplePath);
        if (cnt == GroupScan.NO_COLUMN_STATS) {
          // if column stats is not available don't apply this rule, return empty counts
          return ImmutableMap.of();
        }
      }
    } else {
      return ImmutableMap.of();
    }

    String name = "count" + i + "$" + (aggCall.getName() == null ? aggCall.toString() : aggCall.getName());
    result.put(name, cnt);
  }

  return ImmutableMap.copyOf(result);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:81,代码来源:ConvertCountToDirectScan.java

示例5: getPigAggregateCall

import org.apache.calcite.rel.core.AggregateCall; //导入方法依赖的package包/类
private String getPigAggregateCall(String relAlias, AggregateCall aggCall) {
  final PigAggFunction aggFunc = toPigAggFunc(aggCall);
  final String alias = aggCall.getName();
  final String fields = Joiner.on(", ").join(getArgNames(relAlias, aggCall));
  return aggFunc.name() + "(" + fields + ") AS " + alias;
}
 
开发者ID:apache,项目名称:calcite,代码行数:7,代码来源:PigAggregate.java


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