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


Java AggregateCall类代码示例

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


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

示例1: implement

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
@Override
public LogicalOperator implement(DrillImplementor implementor) {

  GroupingAggregate.Builder builder = GroupingAggregate.builder();
  builder.setInput(implementor.visitChild(this, 0, getInput()));
  final List<String> childFields = getInput().getRowType().getFieldNames();
  final List<String> fields = getRowType().getFieldNames();

  for (int group : BitSets.toIter(groupSet)) {
    FieldReference fr = new FieldReference(childFields.get(group), ExpressionPosition.UNKNOWN);
    builder.addKey(fr, fr);
  }

  for (Ord<AggregateCall> aggCall : Ord.zip(aggCalls)) {
    FieldReference ref = new FieldReference(fields.get(groupSet.cardinality() + aggCall.i));
    LogicalExpression expr = toDrill(aggCall.e, childFields, implementor);
    builder.addExpr(ref, expr);
  }

  return builder.build();
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:22,代码来源:DrillAggregateRel.java

示例2: create2PhasePlan

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
protected boolean create2PhasePlan(RelOptRuleCall call, DrillAggregateRel aggregate) {
  PlannerSettings settings = PrelUtil.getPlannerSettings(call.getPlanner());
  RelNode child = call.rel(0).getInputs().get(0);
  boolean smallInput = child.getRows() < settings.getSliceTarget();
  if (! settings.isMultiPhaseAggEnabled() || settings.isSingleMode() || smallInput) {
    return false;
  }

  for (AggregateCall aggCall : aggregate.getAggCallList()) {
    String name = aggCall.getAggregation().getName();
    if ( ! (name.equals("SUM") || name.equals("MIN") || name.equals("MAX") || name.equals("COUNT")
            || name.equals("$SUM0") 
            || (name.toLowerCase().contains("qdm") && name.toLowerCase().contains("train")))) {
      return false;
    }
  }
  return true;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:19,代码来源:AggPruleBase.java

示例3: toDrill

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
protected LogicalExpression toDrill(AggregateCall call, List<String> fn) {
  DrillParseContext context = new DrillParseContext(PrelUtil.getSettings(getCluster()));

  List<LogicalExpression> args = Lists.newArrayList();
  for (Integer i : call.getArgList()) {
    final int indexInConstants = i - fn.size();
    if (i < fn.size()) {
      args.add(new FieldReference(fn.get(i)));
    } else {
      final RexLiteral constant = constants.get(indexInConstants);
      LogicalExpression expr = DrillOptiq.toDrill(context, getInput(), constant);
      args.add(expr);
    }
  }

  // for count(1).
  if (args.isEmpty()) {
    args.add(new ValueExpressions.LongExpression(1l));
  }

  return new FunctionCall(call.getAggregation().getName().toLowerCase(), args, ExpressionPosition.UNKNOWN);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:23,代码来源:WindowPrel.java

示例4: visit

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
@Override
public RelNode visit(LogicalAggregate aggregate) {
  RelNode input = aggregate.getInput().accept(this);
  RelDataType incomingRowType = input.getRowType();
  RelDataTypeField modField = incomingRowType.getField(UPDATE_COLUMN, false, false);
  if (modField == null) {
    return aggregate;
  }

  final AggregateCall aggCall = AggregateCall.create(SqlStdOperatorTable.MAX, false, ImmutableList.of(modField.getIndex()), -1, modField.getType(), UPDATE_COLUMN);
  final List<AggregateCall> aggCalls = FluentIterable.from(aggregate.getAggCallList())
    .append(aggCall)
    .toList();
  return aggregate.copy(
    aggregate.getTraitSet(),
    input,
    aggregate.indicator,
    aggregate.getGroupSet(),
    null,
    aggCalls
  );
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:IncrementalUpdateUtils.java

示例5: implement

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
@Override
public LogicalOperator implement(LogicalPlanImplementor implementor) {

  GroupingAggregate.Builder builder = GroupingAggregate.builder();
  builder.setInput(implementor.visitChild(this, 0, getInput()));
  final List<String> childFields = getInput().getRowType().getFieldNames();
  final List<String> fields = getRowType().getFieldNames();

  for (int group : BitSets.toIter(groupSet)) {
    FieldReference fr = new FieldReference(childFields.get(group));
    builder.addKey(fr, fr);
  }

  for (Ord<AggregateCall> aggCall : Ord.zip(aggCalls)) {
    FieldReference ref = new FieldReference(fields.get(groupSet.cardinality() + aggCall.i));
    LogicalExpression expr = toExpr(aggCall.e, childFields, implementor);
    builder.addExpr(ref, expr);
  }

  return builder.build();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:AggregateRel.java

示例6: computeSelfCost

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
@Override
public RelOptCost computeSelfCost(RelOptPlanner planner, RelMetadataQuery relMetadataQuery) {
  for (AggregateCall aggCall : getAggCallList()) {
    // For avg, stddev_pop, stddev_samp, var_pop and var_samp, the ReduceAggregatesRule is supposed
    // to convert them to use sum and count. Here, we make the cost of the original functions high
    // enough such that the planner does not choose them and instead chooses the rewritten functions.
    if (aggCall.getAggregation().getKind() == SqlKind.AVG
        || aggCall.getAggregation().getKind() == SqlKind.STDDEV_SAMP
        || aggCall.getAggregation().getKind() == SqlKind.STDDEV_POP
        || aggCall.getAggregation().getKind() == SqlKind.VAR_POP
        || aggCall.getAggregation().getKind() == SqlKind.VAR_SAMP) {
      return planner.getCostFactory().makeHugeCost();
    }
  }

  final double rowCount = relMetadataQuery.getRowCount(this);
  final double childRowCount = relMetadataQuery.getRowCount(this.getInput());
  // Aggregates with more aggregate functions cost a bit more
  float multiplier = 1f + (float) aggCalls.size() * 0.125f;
  return ((Factory) planner.getCostFactory()).makeCost(rowCount,childRowCount * multiplier * DremioCost.FUNC_CPU_COST, 0, 0);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:AggregateRel.java

示例7: create2PhasePlan

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
protected boolean create2PhasePlan(RelOptRuleCall call, AggregateRel aggregate) {
  PlannerSettings settings = PrelUtil.getPlannerSettings(call.getPlanner());
  RelNode child = call.rel(0).getInputs().get(0);
  boolean smallInput = child.estimateRowCount(DefaultRelMetadataProvider.INSTANCE.getRelMetadataQuery()) < settings.getSliceTarget();
  if (! settings.isMultiPhaseAggEnabled() || settings.isSingleMode() || smallInput) {
    return false;
  }

  for (AggregateCall aggCall : aggregate.getAggCallList()) {
    String name = aggCall.getAggregation().getName();
    if (!twoPhaseFunctions.contains(name)) {
      return false;
    }
  }
  return true;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:AggPruleBase.java

示例8: convertAggCallList

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
protected List<AggregateCall> convertAggCallList(AggregateRel aggregate, List<AggregateCall> aggCalls) {
  List<AggregateCall> convertedCalls = new ArrayList<>();
  for (Ord<AggregateCall> aggCall : Ord.zip(aggCalls)) {
    AggregateCall newCall;
    if ("NDV".equals(aggCall.e.getAggregation().getName())) {
      newCall = AggregateCall.create(
        new SqlHllAggFunction(),
        aggCall.e.isDistinct(),
        aggCall.e.getArgList(),
        -1,
        aggregate.getCluster().getTypeFactory().createSqlType(SqlTypeName.BINARY),
        aggCall.e.getName());
    } else {
      newCall = aggCall.e;
    }
    convertedCalls.add(newCall);
  }
  return convertedCalls;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:AggPruleBase.java

示例9: toExpr

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
protected LogicalExpression toExpr(AggregateCall call, List<String> fn) {
  ParseContext context = new ParseContext(PrelUtil.getSettings(getCluster()));

  List<LogicalExpression> args = Lists.newArrayList();
  for (Integer i : call.getArgList()) {
    final int indexInConstants = i - fn.size();
    if (i < fn.size()) {
      args.add(new FieldReference(fn.get(i)));
    } else {
      final RexLiteral constant = constants.get(indexInConstants);
      LogicalExpression expr = RexToExpr.toExpr(context, getInput(), constant);
      args.add(expr);
    }
  }

  // for count(1).
  if (args.isEmpty()) {
    args.add(new ValueExpressions.LongExpression(1l));
  }

  return new FunctionCall(call.getAggregation().getName().toLowerCase(), args);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:WindowPrel.java

示例10: createMeasuresFor

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
private Iterable<AggregateCall> createMeasuresFor(final RelNode view, final LayoutField field) {
  final Optional<SqlTypeFamily> family = TypeUtils.getSqlTypeFamily(field);
  if (!family.isPresent()) {
    return ImmutableList.of();
  }

  return FluentIterable
      .from(AccelerationUtils.selfOrEmptyCollection(calls.get(family.get())))
      .transform(new Function<SqlAggFunction, AggregateCall>() {
        private int index = 0;

        @Nullable
        @Override
        public AggregateCall apply(@Nullable final SqlAggFunction func) {
          // no distinct measures for now
          final int inputRef = getField(field.getName()).getIndex();
          return AggregateCall.create(func, false, ImmutableList.of(inputRef), -1, 1, view, null,
              String.format("agg-%s-%s", inputRef, index++));
        }
      });
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:22,代码来源:LayoutExpander.java

示例11: explainTerms

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
public RelWriter explainTerms(RelWriter pw) {
  // We skip the "groups" element if it is a singleton of "group".
  pw.item("group", groupSet)
      .itemIf("window", windowFn, windowFn != null)
      .itemIf("trigger", trigger, trigger != null)
      .itemIf("event_time", windowFieldIdx, windowFieldIdx != -1)
      .itemIf("groups", groupSets, getGroupType() != Group.SIMPLE)
      .itemIf("indicator", indicator, indicator)
      .itemIf("aggs", aggCalls, pw.nest());
  if (!pw.nest()) {
    for (Ord<AggregateCall> ord : Ord.zip(aggCalls)) {
      pw.item(Util.first(ord.e.name, "agg#" + ord.i), ord.e);
    }
  }
  return pw;
}
 
开发者ID:apache,项目名称:beam,代码行数:17,代码来源:BeamAggregationRel.java

示例12: create2PhasePlan

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
protected boolean create2PhasePlan(RelOptRuleCall call, DrillAggregateRel aggregate) {
  PlannerSettings settings = PrelUtil.getPlannerSettings(call.getPlanner());
  RelNode child = call.rel(0).getInputs().get(0);
  boolean smallInput = child.getRows() < settings.getSliceTarget();
  if (! settings.isMultiPhaseAggEnabled() || settings.isSingleMode() ||
      // Can override a small child - e.g., for testing with a small table
      ( smallInput && ! settings.isForce2phaseAggr() ) ) {
    return false;
  }

  for (AggregateCall aggCall : aggregate.getAggCallList()) {
    String name = aggCall.getAggregation().getName();
    if ( ! (name.equals("SUM") || name.equals("MIN") || name.equals("MAX") || name.equals("COUNT")
            || name.equals("$SUM0"))) {
      return false;
    }
  }
  return true;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:20,代码来源:AggPruleBase.java

示例13: JdbcAggregate

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
public JdbcAggregate(
        RelOptCluster cluster,
        RelTraitSet traitSet,
        RelNode input,
        boolean indicator,
        ImmutableBitSet groupSet,
        List<ImmutableBitSet> groupSets,
        List<AggregateCall> aggCalls)
        throws InvalidRelException {
    super(cluster, traitSet, input, indicator, groupSet, groupSets, aggCalls);
    assert getConvention() instanceof JdbcConvention;
    assert this.groupSets.size() == 1 : "Grouping sets not supported";
    assert !this.indicator;
    final SqlDialect dialect = ((JdbcConvention) getConvention()).getDialect();
    for (AggregateCall aggCall : aggCalls) {
        if (!canImplement(aggCall.getAggregation(), dialect)) {
            throw new InvalidRelException("cannot implement aggregate function "
                    + aggCall.getAggregation());
        }
    }
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:22,代码来源:JdbcRules.java

示例14: visitAggregate

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
@Override
public Void visitAggregate(Aggregate aggregate, List<Void> inputStreams) throws Exception {
  beginAggregateStage(aggregate);
  pw.println("        if (_data != null) {");
  pw.println("        List<Object> curGroupValues = getGroupValues(_data);");
  pw.println("        if (!correlatedGroupedValues.containsKey(curGroupValues)) {");
  pw.println("          correlatedGroupedValues.put(curGroupValues, new ArrayList<CorrelatedValues>());");
  pw.println("        }");
  pw.println("        correlatedGroupedValues.get(curGroupValues).add(_data);");
  pw.println("        if (!state.containsKey(curGroupValues)) {");
  pw.println("          state.put(curGroupValues, new HashMap<String, Object>());");
  pw.println("        }");
  pw.println("        Map<String, Object> accumulators = state.get(curGroupValues);");
  for (AggregateCall call : aggregate.getAggCallList()) {
    aggregate(call);
  }
  pw.println("        }");
  endStage();
  return null;
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:21,代码来源:RelNodeCompiler.java

示例15: aggregateResult

import org.apache.calcite.rel.core.AggregateCall; //导入依赖的package包/类
private String aggregateResult(AggregateCall call, PrintWriter pw) {
  SqlAggFunction aggFunction = call.getAggregation();
  String aggregationName = call.getAggregation().getName();
  Type ty = typeFactory.getJavaClass(call.getType());
  String result;
  if (aggFunction instanceof SqlUserDefinedAggFunction) {
    AggregateFunction aggregateFunction = ((SqlUserDefinedAggFunction) aggFunction).function;
    result = doAggregateResult((AggregateFunctionImpl) aggregateFunction, reserveAggVarName(call), ty, pw);
  } else {
    List<BuiltinAggregateFunctions.TypeClass> typeClasses = BuiltinAggregateFunctions.TABLE.get(aggregationName);
    if (typeClasses == null) {
      throw new UnsupportedOperationException(aggregationName + " Not implemented");
    }
    result = doAggregateResult(AggregateFunctionImpl.create(findMatchingClass(aggregationName, typeClasses, ty)),
                               reserveAggVarName(call), ty, pw);
  }
  return result;
}
 
开发者ID:hortonworks,项目名称:streamline,代码行数:19,代码来源:RelNodeCompiler.java


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