本文整理汇总了Java中org.apache.calcite.rel.core.Sort.copy方法的典型用法代码示例。如果您正苦于以下问题:Java Sort.copy方法的具体用法?Java Sort.copy怎么用?Java Sort.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.rel.core.Sort
的用法示例。
在下文中一共展示了Sort.copy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMatch
import org.apache.calcite.rel.core.Sort; //导入方法依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final Sort sort = call.rel(0);
if (sort.offset == null && sort.fetch == null) {
return;
}
RelTraitSet origTraitSet = sort.getTraitSet();
RelTraitSet traitSet = origTraitSet.replace(OLAPRel.CONVENTION).simplify();
RelNode input = sort.getInput();
if (!sort.getCollation().getFieldCollations().isEmpty()) {
// Create a sort with the same sort key, but no offset or fetch.
input = sort.copy(sort.getTraitSet(), input, sort.getCollation(), null, null);
}
RelNode x = convert(input, input.getTraitSet().replace(OLAPRel.CONVENTION));
call.transformTo(new OLAPLimitRel(sort.getCluster(), traitSet, x, sort.offset, sort.fetch));
}
示例2: onMatch
import org.apache.calcite.rel.core.Sort; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
final Sort sort = call.rel(0);
final DruidQuery query = call.rel(1);
if (!DruidQuery.isValidSignature(query.signature() + 'l')) {
return;
}
// Either it is:
// - a sort and limit on a dimension/metric part of the druid group by query or
// - a sort without limit on the time column on top of
// Agg operator (transformable to timeseries query), or
// - a simple limit on top of other operator than Agg
if (!validSortLimit(sort, query)) {
return;
}
final RelNode newSort = sort.copy(sort.getTraitSet(),
ImmutableList.of(Util.last(query.rels)));
call.transformTo(DruidQuery.extendQuery(query, newSort));
}
示例3: onMatch
import org.apache.calcite.rel.core.Sort; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
final Project project = call.rel(0);
final Sort sort = call.rel(1);
if (sort.getClass() != Sort.class) {
return;
}
RelNode newProject =
project.copy(
project.getTraitSet(), ImmutableList.of(sort.getInput()));
final Sort newSort =
sort.copy(
sort.getTraitSet(),
newProject,
sort.getCollation(),
sort.offset,
sort.fetch);
call.transformTo(newSort);
}
示例4: onMatch
import org.apache.calcite.rel.core.Sort; //导入方法依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final Sort incomingSort = call.rel(0);
final RelTraitSet incomingTraits = incomingSort.getTraitSet();
RelNode input = incomingSort.getInput();
// if the Optiq sort rel includes a collation and a limit, we need to create a copy the sort rel that excludes the
// limit information.
if (!incomingSort.getCollation().getFieldCollations().isEmpty()) {
input = incomingSort.copy(incomingTraits, input, incomingSort.getCollation(), null, null);
}
RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL));
call.transformTo(new DrillLimitRel(incomingSort.getCluster(), convertedInput.getTraitSet().plus(DrillRel.DRILL_LOGICAL), convertedInput, incomingSort.offset, incomingSort.fetch));
}
示例5: onMatch
import org.apache.calcite.rel.core.Sort; //导入方法依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
final Sort incomingSort = call.rel(0);
final RelTraitSet incomingTraits = incomingSort.getTraitSet();
RelNode input = incomingSort.getInput();
// if the calcite sort rel includes a collation and a limit, we need to create a copy the sort rel that excludes the
// limit information.
if (!incomingSort.getCollation().getFieldCollations().isEmpty()) {
input = incomingSort.copy(incomingTraits, input, incomingSort.getCollation(), null, null);
}
RelNode convertedInput = convert(input, input.getTraitSet().plus(Rel.LOGICAL).simplify());
call.transformTo(new LimitRel(incomingSort.getCluster(), convertedInput.getTraitSet().plus(Rel.LOGICAL), convertedInput, incomingSort.offset, incomingSort.fetch));
}
示例6: onMatch
import org.apache.calcite.rel.core.Sort; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
final Sort sort = call.rel(0);
final Union union = call.rel(1);
List<RelNode> inputs = new ArrayList<>();
// Thus we use 'ret' as a flag to identify if we have finished pushing the
// sort past a union.
boolean ret = true;
final RelMetadataQuery mq = call.getMetadataQuery();
for (RelNode input : union.getInputs()) {
if (!RelMdUtil.checkInputForCollationAndLimit(mq, input,
sort.getCollation(), sort.offset, sort.fetch)) {
ret = false;
Sort branchSort = sort.copy(sort.getTraitSet(), input,
sort.getCollation(), sort.offset, sort.fetch);
inputs.add(branchSort);
} else {
inputs.add(input);
}
}
// there is nothing to change
if (ret) {
return;
}
// create new union and sort
Union unionCopy = (Union) union
.copy(union.getTraitSet(), inputs, union.all);
Sort result = sort.copy(sort.getTraitSet(), unionCopy, sort.getCollation(),
sort.offset, sort.fetch);
call.transformTo(result);
}
示例7: onMatch
import org.apache.calcite.rel.core.Sort; //导入方法依赖的package包/类
@Override public void onMatch(RelOptRuleCall call) {
final Sort sort = call.rel(0);
if (sort.offset == null && sort.fetch == null) {
return;
}
final RelTraitSet traitSet =
sort.getTraitSet().replace(EnumerableConvention.INSTANCE);
RelNode input = sort.getInput();
if (!sort.getCollation().getFieldCollations().isEmpty()) {
// Create a sort with the same sort key, but no offset or fetch.
input = sort.copy(
sort.getTraitSet(),
input,
sort.getCollation(),
null,
null);
}
RelNode x = convert(
input,
input.getTraitSet().replace(EnumerableConvention.INSTANCE));
call.transformTo(
new EnumerableLimit(
sort.getCluster(),
traitSet,
x,
sort.offset,
sort.fetch));
}
示例8: onMatch
import org.apache.calcite.rel.core.Sort; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
final Sort sort = call.rel(0);
final Project project = call.rel(1);
final RelOptCluster cluster = project.getCluster();
if (sort.getConvention() != project.getConvention()) {
return;
}
// Determine mapping between project input and output fields. If sort
// relies on non-trivial expressions, we can't push.
final Mappings.TargetMapping map =
RelOptUtil.permutationIgnoreCast(
project.getProjects(), project.getInput().getRowType());
for (RelFieldCollation fc : sort.getCollation().getFieldCollations()) {
if (map.getTargetOpt(fc.getFieldIndex()) < 0) {
return;
}
final RexNode node = project.getProjects().get(fc.getFieldIndex());
if (node.isA(SqlKind.CAST)) {
// Check whether it is a monotonic preserving cast, otherwise we cannot push
final RexCall cast = (RexCall) node;
final RexCallBinding binding =
RexCallBinding.create(cluster.getTypeFactory(), cast,
ImmutableList.of(RelCollations.of(RexUtil.apply(map, fc))));
if (cast.getOperator().getMonotonicity(binding) == SqlMonotonicity.NOT_MONOTONIC) {
return;
}
}
}
final RelCollation newCollation =
cluster.traitSet().canonize(
RexUtil.apply(map, sort.getCollation()));
final Sort newSort =
sort.copy(
sort.getTraitSet().replace(newCollation),
project.getInput(),
newCollation,
sort.offset,
sort.fetch);
RelNode newProject =
project.copy(
sort.getTraitSet(),
ImmutableList.<RelNode>of(newSort));
// Not only is newProject equivalent to sort;
// newSort is equivalent to project's input
// (but only if the sort is not also applying an offset/limit).
Map<RelNode, RelNode> equiv;
if (sort.offset == null
&& sort.fetch == null
&& cluster.getPlanner().getRelTraitDefs()
.contains(RelCollationTraitDef.INSTANCE)) {
equiv = ImmutableMap.of((RelNode) newSort, project.getInput());
} else {
equiv = ImmutableMap.of();
}
call.transformTo(newProject, equiv);
}
示例9: onMatch
import org.apache.calcite.rel.core.Sort; //导入方法依赖的package包/类
@Override public void onMatch(RelOptRuleCall call) {
final Sort sort = call.rel(0);
final Join join = call.rel(1);
// We create a new sort operator on the corresponding input
final RelNode newLeftInput;
final RelNode newRightInput;
final RelMetadataQuery mq = call.getMetadataQuery();
if (join.getJoinType() == JoinRelType.LEFT) {
// If the input is already sorted and we are not reducing the number of tuples,
// we bail out
if (RelMdUtil.checkInputForCollationAndLimit(mq, join.getLeft(),
sort.getCollation(), sort.offset, sort.fetch)) {
return;
}
newLeftInput = sort.copy(sort.getTraitSet(), join.getLeft(), sort.getCollation(),
sort.offset, sort.fetch);
newRightInput = join.getRight();
} else {
final RelCollation rightCollation =
RelCollationTraitDef.INSTANCE.canonize(
RelCollations.shift(sort.getCollation(),
-join.getLeft().getRowType().getFieldCount()));
// If the input is already sorted and we are not reducing the number of tuples,
// we bail out
if (RelMdUtil.checkInputForCollationAndLimit(mq, join.getRight(),
rightCollation, sort.offset, sort.fetch)) {
return;
}
newLeftInput = join.getLeft();
newRightInput = sort.copy(sort.getTraitSet().replace(rightCollation),
join.getRight(), rightCollation, sort.offset, sort.fetch);
}
// We copy the join and the top sort operator
final RelNode joinCopy = join.copy(join.getTraitSet(), join.getCondition(), newLeftInput,
newRightInput, join.getJoinType(), join.isSemiJoinDone());
final RelNode sortCopy = sort.copy(sort.getTraitSet(), joinCopy, sort.getCollation(),
sort.offset, sort.fetch);
call.transformTo(sortCopy);
}