本文整理汇总了Java中org.apache.calcite.util.CompositeList类的典型用法代码示例。如果您正苦于以下问题:Java CompositeList类的具体用法?Java CompositeList怎么用?Java CompositeList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompositeList类属于org.apache.calcite.util包,在下文中一共展示了CompositeList类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTimeUnits
import org.apache.calcite.util.CompositeList; //导入依赖的package包/类
/** Returns a list of the time units covered by an interval type such
* as HOUR TO SECOND. Adds MILLISECOND if the end is SECOND, to deal with
* fractional seconds. */
private static List<TimeUnit> getTimeUnits(SqlTypeName typeName) {
final TimeUnit start = typeName.getStartUnit();
final TimeUnit end = typeName.getEndUnit();
final ImmutableList<TimeUnit> list =
TIME_UNITS.subList(start.ordinal(), end.ordinal() + 1);
if (end == TimeUnit.SECOND) {
return CompositeList.of(list, ImmutableList.of(TimeUnit.MILLISECOND));
}
return list;
}
示例2: reduceAggs
import org.apache.calcite.util.CompositeList; //导入依赖的package包/类
/**
* Reduces all calls to AVG, STDDEV_POP, STDDEV_SAMP, VAR_POP, VAR_SAMP in
* the aggregates list to.
*
* <p>It handles newly generated common subexpressions since this was done
* at the sql2rel stage.
*/
private void reduceAggs(
RelOptRuleCall ruleCall,
Aggregate oldAggRel) {
RexBuilder rexBuilder = oldAggRel.getCluster().getRexBuilder();
List<AggregateCall> oldCalls = oldAggRel.getAggCallList();
final int nGroups = oldAggRel.getGroupCount();
List<AggregateCall> newCalls = new ArrayList<AggregateCall>();
Map<AggregateCall, RexNode> aggCallMapping =
new HashMap<AggregateCall, RexNode>();
List<RexNode> projList = new ArrayList<RexNode>();
// pass through group key
for (int i = 0; i < nGroups; ++i) {
projList.add(
rexBuilder.makeInputRef(
getFieldType(oldAggRel, i),
i));
}
// List of input expressions. If a particular aggregate needs more, it
// will add an expression to the end, and we will create an extra
// project.
RelNode input = oldAggRel.getInput();
List<RexNode> inputExprs = new ArrayList<RexNode>();
for (RelDataTypeField field : input.getRowType().getFieldList()) {
inputExprs.add(
rexBuilder.makeInputRef(
field.getType(), inputExprs.size()));
}
// create new agg function calls and rest of project list together
for (AggregateCall oldCall : oldCalls) {
projList.add(
reduceAgg(
oldAggRel, oldCall, newCalls, aggCallMapping, inputExprs));
}
final int extraArgCount =
inputExprs.size() - input.getRowType().getFieldCount();
if (extraArgCount > 0) {
input =
RelOptUtil.createProject(
input,
inputExprs,
CompositeList.of(
input.getRowType().getFieldNames(),
Collections.<String>nCopies(
extraArgCount,
null)));
}
Aggregate newAggRel =
newAggregateRel(
oldAggRel, input, newCalls);
RelNode projectRel =
RelOptUtil.createProject(
newAggRel,
projList,
oldAggRel.getRowType().getFieldNames());
ruleCall.transformTo(projectRel);
}
示例3: reduceAggs
import org.apache.calcite.util.CompositeList; //导入依赖的package包/类
/**
* Reduces all calls to AVG, STDDEV_POP, STDDEV_SAMP, VAR_POP, VAR_SAMP in
* the aggregates list to.
*
* <p>It handles newly generated common subexpressions since this was done
* at the sql2rel stage.
*/
private void reduceAggs(
RelOptRuleCall ruleCall,
Aggregate oldAggRel) {
RexBuilder rexBuilder = oldAggRel.getCluster().getRexBuilder();
List<AggregateCall> oldCalls = oldAggRel.getAggCallList();
final int nGroups = oldAggRel.getGroupCount();
List<AggregateCall> newCalls = new ArrayList<>();
Map<AggregateCall, RexNode> aggCallMapping =
new HashMap<>();
List<RexNode> projList = new ArrayList<>();
// pass through group key
for (int i = 0; i < nGroups; ++i) {
projList.add(
rexBuilder.makeInputRef(
getFieldType(oldAggRel, i),
i));
}
// List of input expressions. If a particular aggregate needs more, it
// will add an expression to the end, and we will create an extra
// project.
RelNode input = oldAggRel.getInput();
List<RexNode> inputExprs = new ArrayList<>();
for (RelDataTypeField field : input.getRowType().getFieldList()) {
inputExprs.add(
rexBuilder.makeInputRef(
field.getType(), inputExprs.size()));
}
// create new agg function calls and rest of project list together
for (AggregateCall oldCall : oldCalls) {
projList.add(
reduceAgg(
oldAggRel, oldCall, newCalls, aggCallMapping, inputExprs));
}
final int extraArgCount =
inputExprs.size() - input.getRowType().getFieldCount();
if (extraArgCount > 0) {
input =
RelOptUtil.createProject(
input,
inputExprs,
CompositeList.of(
input.getRowType().getFieldNames(),
Collections.<String>nCopies(
extraArgCount,
null)));
}
Aggregate newAggRel =
newAggregateRel(
oldAggRel, input, newCalls);
RelNode projectRel =
RelOptUtil.createProject(
newAggRel,
projList,
oldAggRel.getRowType().getFieldNames());
ruleCall.transformTo(projectRel);
}
示例4: reduceAggs
import org.apache.calcite.util.CompositeList; //导入依赖的package包/类
/**
* Reduces all calls to AVG, STDDEV_POP, STDDEV_SAMP, VAR_POP, VAR_SAMP in
* the aggregates list to.
*
* <p>It handles newly generated common subexpressions since this was done
* at the sql2rel stage.
*/
private void reduceAggs(
RelOptRuleCall ruleCall,
Aggregate oldAggRel) {
RexBuilder rexBuilder = oldAggRel.getCluster().getRexBuilder();
List<AggregateCall> oldCalls = oldAggRel.getAggCallList();
final int groupCount = oldAggRel.getGroupCount();
final int indicatorCount = oldAggRel.getIndicatorCount();
final List<AggregateCall> newCalls = Lists.newArrayList();
final Map<AggregateCall, RexNode> aggCallMapping = Maps.newHashMap();
final List<RexNode> projList = Lists.newArrayList();
// pass through group key (+ indicators if present)
for (int i = 0; i < groupCount + indicatorCount; ++i) {
projList.add(
rexBuilder.makeInputRef(
getFieldType(oldAggRel, i),
i));
}
// List of input expressions. If a particular aggregate needs more, it
// will add an expression to the end, and we will create an extra
// project.
final RelBuilder relBuilder = ruleCall.builder();
relBuilder.push(oldAggRel.getInput());
final List<RexNode> inputExprs = new ArrayList<>(relBuilder.fields());
// create new agg function calls and rest of project list together
for (AggregateCall oldCall : oldCalls) {
projList.add(
reduceAgg(
oldAggRel, oldCall, newCalls, aggCallMapping, inputExprs));
}
final int extraArgCount =
inputExprs.size() - relBuilder.peek().getRowType().getFieldCount();
if (extraArgCount > 0) {
relBuilder.project(inputExprs,
CompositeList.of(
relBuilder.peek().getRowType().getFieldNames(),
Collections.<String>nCopies(extraArgCount, null)));
}
newAggregateRel(relBuilder, oldAggRel, newCalls);
relBuilder.project(projList, oldAggRel.getRowType().getFieldNames());
ruleCall.transformTo(relBuilder.build());
}