org.apache.calcite.rel.core.Aggregate.getGroupCount()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.apache.calcite.rel.core.Aggregate.getGroupCount()方法的一些代码示例,展示了Aggregate.getGroupCount()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Aggregate.getGroupCount()方法的具体详情如下:
包路径:org.apache.calcite.rel.core.Aggregate
类名称:Aggregate
方法名:getGroupCount

Aggregate.getGroupCount介绍

[英]Returns the number of grouping fields. These grouping fields are the leading fields in both the input and output records.

NOTE: The #getGroupSet() data structure allows for the grouping fields to not be on the leading edge. New code should, if possible, assume that grouping fields are in arbitrary positions in the input relational expression.
[中]返回分组字段的数目。这些分组字段是输入和输出记录中的前导字段。
注意:#getGroupSet()数据结构允许分组字段不在前沿。如果可能的话,新代码应该假设分组字段在输入关系表达式中的任意位置。

代码示例

代码示例来源:origin: apache/hive

private boolean isAggregateWithoutGbyKeys(final Aggregate agg) {
 return agg.getGroupCount() == 0 ? true : false;
}

代码示例来源:origin: apache/hive

private boolean isAggWithConstantGbyKeys(final Aggregate aggregate, RelOptRuleCall call) {
 final RexBuilder rexBuilder = aggregate.getCluster().getRexBuilder();
 final RelMetadataQuery mq = call.getMetadataQuery();
 final RelOptPredicateList predicates =
   mq.getPulledUpPredicates(aggregate.getInput());
 if (predicates == null) {
  return false;
 }
 final NavigableMap<Integer, RexNode> map = new TreeMap<>();
 for (int key : aggregate.getGroupSet()) {
  final RexInputRef ref =
    rexBuilder.makeInputRef(aggregate.getInput(), key);
  if (predicates.constantMap.containsKey(ref)) {
   map.put(key, predicates.constantMap.get(ref));
  }
 }
 // None of the group expressions are constant. Nothing to do.
 if (map.isEmpty()) {
  return false;
 }
 final int groupCount = aggregate.getGroupCount();
 if (groupCount == map.size()) {
  return true;
 }
 return false;
}

代码示例来源:origin: apache/hive

public RelNode align(Aggregate rel, List<RelFieldCollation> collations) {
 // 1) We extract the group by positions that are part of the collations and
 // sort them so they respect it
 LinkedHashSet<Integer> aggregateColumnsOrder = new LinkedHashSet<>();
 ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
 if (rel.getGroupType() == Group.SIMPLE && !collations.isEmpty()) {
  for (RelFieldCollation c : collations) {
   if (c.getFieldIndex() < rel.getGroupCount()) {
    // Group column found
    if (aggregateColumnsOrder.add(c.getFieldIndex())) {
     propagateCollations.add(c.copy(rel.getGroupSet().nth(c.getFieldIndex())));
    }
   }
  }
 }
 for (int i = 0; i < rel.getGroupCount(); i++) {
  if (!aggregateColumnsOrder.contains(i)) {
   // Not included in the input collations, but can be propagated as this Aggregate
   // will enforce it
   propagateCollations.add(new RelFieldCollation(rel.getGroupSet().nth(i)));
  }
 }
 // 2) We propagate
 final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
 // 3) We annotate the Aggregate operator with this info
 final HiveAggregate newAggregate = (HiveAggregate) rel.copy(rel.getTraitSet(),
     ImmutableList.of(child));
 newAggregate.setAggregateColumnsOrder(aggregateColumnsOrder);
 return newAggregate;
}

代码示例来源:origin: apache/hive

private AggregateCall createAggregateCallWithBinding(
  RelDataTypeFactory typeFactory,
  SqlAggFunction aggFunction,
  RelDataType operandType,
  Aggregate oldAggRel,
  AggregateCall oldCall,
  int argOrdinal) {
 final Aggregate.AggCallBinding binding =
   new Aggregate.AggCallBinding(typeFactory, aggFunction,
     ImmutableList.of(operandType), oldAggRel.getGroupCount(),
     oldCall.filterArg >= 0);
 return AggregateCall.create(aggFunction,
   oldCall.isDistinct(),
   oldCall.isApproximate(),
   ImmutableIntList.of(argOrdinal),
   oldCall.filterArg,
   aggFunction.inferReturnType(binding),
   null);
}

代码示例来源:origin: apache/hive

RexNode condition = rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, originalInputRefs
  .get(originalInputRefs.size() - 1), rexBuilder.makeExactLiteral(new BigDecimal(
  getGroupingIdValue(list, sourceOfForCountDistinct, aggr.getGroupCount()))));
if (list.size() == 1) {
 int pos = list.get(0);

代码示例来源:origin: apache/incubator-druid

final int fieldCount = aggregate.getGroupCount() + aggregate.getAggCallList().size();
if (fieldCount != aggregate.getRowType().getFieldCount()) {
 throw new ISE(
  ImmutableBitSet.range(aggregate.getGroupCount(), fieldCount)
);
  newAggregateCalls.add(aggregate.getAggCallList().get(i - aggregate.getGroupCount()));
 for (int i = 0; i < aggregate.getGroupCount(); i++) {
  fixUpProjects.add(rexBuilder.makeInputRef(newAggregate, i));
 int j = aggregate.getGroupCount();
 for (int i = aggregate.getGroupCount(); i < fieldCount; i++) {
  if (callsToKeep.get(i)) {
   fixUpProjects.add(rexBuilder.makeInputRef(newAggregate, j++));

代码示例来源:origin: apache/hive

final int groupingFields = aggregate.getGroupCount() + aggregate.getIndicatorCount();
Set<String> projectExprsDigest = new HashSet<String>();
Map<String, RexNode> windowingExprsDigestToNodes = new HashMap<String,RexNode>();

代码示例来源:origin: apache/hive

final List<AggregateCall> aggCalls = aggRel.getAggCallList();
final List<AggregateCall> newAggCalls = new ArrayList<>(aggCalls.size());
int nextIdx = aggRel.getGroupCount() + aggRel.getIndicatorCount();
for (int i = 0; i < aggCalls.size(); i++) {
 AggregateCall aggCall = aggCalls.get(i);
  call.transformTo(newAggregate);
 } else {
  final int offset = aggRel.getGroupCount() + aggRel.getIndicatorCount();
  final List<RexNode> projList = Lists.newArrayList();
  for (int i = 0; i < offset; ++i) {

代码示例来源:origin: apache/hive

List<RexNode> joinConjs = new ArrayList<>();
List<RexNode> filterConjs = new ArrayList<>();
int groupCount = agg.getGroupCount();
int totalCount = agg.getGroupCount() + agg.getAggCallList().size();
for (int leftPos = 0, rightPos = totalCount;
   leftPos < groupCount; leftPos++, rightPos++) {

代码示例来源:origin: apache/drill

public RelNode align(Aggregate rel, List<RelFieldCollation> collations) {
 // 1) We extract the group by positions that are part of the collations and
 // sort them so they respect it
 LinkedHashSet<Integer> aggregateColumnsOrder = new LinkedHashSet<>();
 ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
 if (!rel.indicator && !collations.isEmpty()) {
  for (RelFieldCollation c : collations) {
   if (c.getFieldIndex() < rel.getGroupCount()) {
    // Group column found
    if (aggregateColumnsOrder.add(c.getFieldIndex())) {
     propagateCollations.add(c.copy(rel.getGroupSet().nth(c.getFieldIndex())));
    }
   }
  }
 }
 for (int i = 0; i < rel.getGroupCount(); i++) {
  if (!aggregateColumnsOrder.contains(i)) {
   // Not included in the input collations, but can be propagated as this Aggregate
   // will enforce it
   propagateCollations.add(new RelFieldCollation(rel.getGroupSet().nth(i)));
  }
 }
 // 2) We propagate
 final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
 // 3) We annotate the Aggregate operator with this info
 final HiveAggregate newAggregate = (HiveAggregate) rel.copy(rel.getTraitSet(),
     ImmutableList.of(child));
 newAggregate.setAggregateColumnsOrder(aggregateColumnsOrder);
 return newAggregate;
}

代码示例来源:origin: apache/incubator-druid

final List<AggregateCall> newCalls = new ArrayList<>(aggregate.getAggCallList().size());
final List<RexNode> newProjects = new ArrayList<>(project.getChildExps());
final List<RexNode> newCasts = new ArrayList<>(aggregate.getGroupCount() + aggregate.getAggCallList().size());
final RelDataTypeFactory typeFactory = aggregate.getCluster().getTypeFactory();

代码示例来源:origin: apache/hive

final int groupCount = oldAggRel.getGroupCount();
final int indicatorCount = oldAggRel.getIndicatorCount();

代码示例来源:origin: apache/hive

ImmutableBitSet.range(aggregate.getGroupCount()))) {

代码示例来源:origin: apache/hive

Map<AggregateCall, RexNode> aggCallMapping,
 List<RexNode> inputExprs) {
final int nGroups = oldAggRel.getGroupCount();
final RexBuilder rexBuilder = oldAggRel.getCluster().getRexBuilder();
final RelDataTypeFactory typeFactory = oldAggRel.getCluster().getTypeFactory();
    oldCall.getArgList(),
    oldCall.filterArg,
    oldAggRel.getGroupCount(),
    oldAggRel.getInput(),
    null,

代码示例来源:origin: apache/hive

Map<AggregateCall, RexNode> aggCallMapping,
 List<RexNode> inputExprs) {
final int nGroups = oldAggRel.getGroupCount();
final RexBuilder rexBuilder = oldAggRel.getCluster().getRexBuilder();
final RelDataTypeFactory typeFactory = oldAggRel.getCluster().getTypeFactory();
    oldCall.getArgList(),
    oldCall.filterArg,
    oldAggRel.getGroupCount(),
    oldAggRel.getInput(),
    null,
    oldCall.getArgList(),
    oldCall.filterArg,
    oldAggRel.getGroupCount(),
    oldAggRel.getInput(),
    countRetType,

代码示例来源:origin: apache/hive

ImmutableBitSet.range(rightAggregate.getGroupCount()));
if(shouldTransform) {
 final RelBuilder relBuilder = call.builder();

代码示例来源:origin: apache/hive

final int nGroups = oldAggRel.getGroupCount();
List<RelDataType> oldArgTypes =
  SqlTypeUtil.projectTypes(

代码示例来源:origin: apache/hive

ImmutableBitSet.range(aggregate.getGroupCount()))) {

代码示例来源:origin: apache/drill

ImmutableBitSet.range(aggregate.getGroupCount()))) {

代码示例来源:origin: apache/incubator-druid

joinInfo.rightSet().cardinality() != right.getPartialDruidQuery().getAggregate().getGroupCount()) {
return;

相关文章