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

x33g5p2x  于2022-01-26 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(175)

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

Project.getTraitSet介绍

暂无

代码示例

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

public RelNode align(Project rel, List<RelFieldCollation> collations) {
 // 1) We extract the collations indices
 boolean containsWindowing = false;
 for (RexNode childExp : rel.getChildExps()) {
  if (childExp instanceof RexOver) {
   // TODO: support propagation for partitioning/ordering in windowing
   containsWindowing = true;
   break;
  }
 }
 ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
 if (!containsWindowing) {
  for (RelFieldCollation c : collations) {
   RexNode rexNode = rel.getChildExps().get(c.getFieldIndex());
   if (rexNode instanceof RexInputRef) {
    int newIdx = ((RexInputRef) rexNode).getIndex();
    propagateCollations.add(c.copy((newIdx)));
   }
  }
 }
 // 2) We propagate
 final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
 // 3) Return new Project
 return rel.copy(rel.getTraitSet(), ImmutableList.of(child));
}

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

@Override
public void onMatch(RelOptRuleCall call) {
 final Project project = call.rel(0);
 boolean changed = false;
 final RexBuilder rexBuilder = project.getCluster().getRexBuilder();
 List<RexNode> newProjects = new ArrayList<>();
 for (RexNode oldNode : project.getProjects()) {
  RexNode newNode = analyzeRexNode(rexBuilder, oldNode);
  if (!newNode.toString().equals(oldNode.toString())) {
   changed = true;
   newProjects.add(newNode);
  } else {
   newProjects.add(oldNode);
  }
 }
 if (!changed) {
  return;
 }
 Project newProject = project.copy(project.getTraitSet(), project.getInput(), newProjects,
   project.getRowType(), project.getFlags());
 call.transformTo(newProject);
}

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

protected void apply(RelOptRuleCall call, Project project, Filter filter, TableScan scan) {
 RelOptPlanner planner = call.getPlanner();
 List<RelOptMaterialization> materializations =
   (planner instanceof VolcanoPlanner)
     ? ((VolcanoPlanner) planner).getMaterializations()
     : ImmutableList.<RelOptMaterialization>of();
 if (!materializations.isEmpty()) {
  RelNode root = project.copy(project.getTraitSet(), Collections.singletonList(
    filter.copy(filter.getTraitSet(), Collections.singletonList(
      (RelNode) scan))));
  // Costing is done in transformTo(), so we call it repeatedly with all applicable
  // materialized views and cheapest one will be picked
  List<RelOptMaterialization> applicableMaterializations =
    VolcanoPlanner.getApplicableMaterializations(root, materializations);
  for (RelOptMaterialization materialization : applicableMaterializations) {
   List<RelNode> subs = new MaterializedViewSubstitutionVisitor(
     materialization.queryRel, root, relBuilderFactory).go(materialization.tableRel);
   for (RelNode s : subs) {
    call.transformTo(s);
   }
  }
 }
}

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

@Override
  public RelNode convert(RelNode rel) {
    final Project project = (Project) rel;
    final RelNode input = project.getInput();

    return new StreamsProjectRel(project.getCluster(),
                   project.getTraitSet().replace(StreamsLogicalConvention.INSTANCE),
                   convert(input, input.getTraitSet().replace(StreamsLogicalConvention.INSTANCE)), project.getProjects(),
                   project.getRowType());
  }
}

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

public RelNode align(Project rel, List<RelFieldCollation> collations) {
 // 1) We extract the collations indices
 boolean containsWindowing = false;
 for (RexNode childExp : rel.getChildExps()) {
  if (childExp instanceof RexOver) {
   // TODO: support propagation for partitioning/ordering in windowing
   containsWindowing = true;
   break;
  }
 }
 ImmutableList.Builder<RelFieldCollation> propagateCollations = ImmutableList.builder();
 if (!containsWindowing) {
  for (RelFieldCollation c : collations) {
   RexNode rexNode = rel.getChildExps().get(c.getFieldIndex());
   if (rexNode instanceof RexInputRef) {
    int newIdx = ((RexInputRef) rexNode).getIndex();
    propagateCollations.add(c.copy((newIdx)));
   }
  }
 }
 // 2) We propagate
 final RelNode child = dispatchAlign(rel.getInput(), propagateCollations.build());
 // 3) Return new Project
 return rel.copy(rel.getTraitSet(), ImmutableList.of(child));
}

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

public void onMatch(RelOptRuleCall call) {
  final Filter filter = call.rel(0);
  final Project project = call.rel(1);
  final List<RexNode> newProjects = new ArrayList<>(project.getProjects());
  newProjects.add(filter.getCondition());
  final RelOptCluster cluster = filter.getCluster();
  RelDataType newRowType =
    cluster.getTypeFactory().builder()
      .addAll(project.getRowType().getFieldList())
      .add("condition", Util.last(newProjects).getType())
      .build();
  final RelNode newProject =
    project.copy(project.getTraitSet(),
      project.getInput(),
      newProjects,
      newRowType);
  final RexInputRef newCondition =
    cluster.getRexBuilder().makeInputRef(newProject,
      newProjects.size() - 1);
  call.transformTo(filter.copy(filter.getTraitSet(), newProject, newCondition));
 }
}

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

newCondition);
RelNode newProjRel = projectFactory == null ? project.copy(project.getTraitSet(), newFilterRel,
  project.getProjects(), project.getRowType()) : projectFactory.createProject(newFilterRel,
  project.getProjects(), project.getRowType().getFieldNames());

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

newCondition);
RelNode newProjRel = projectFactory == null ? project.copy(project.getTraitSet(), newFilterRel,
  project.getProjects(), project.getRowType()) : projectFactory.createProject(newFilterRel,
  project.getProjects(), project.getRowType().getFieldNames());

代码示例来源:origin: Qihoo360/Quicksql

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);
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

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);
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

final Project newInput = childProject.copy(childProject.getTraitSet(),
  childProject.getInput(), childProject.getProjects(), rowType);
stack.push(new Frame(newInput, frame.fields));

代码示例来源:origin: org.apache.calcite/calcite-core

public void onMatch(RelOptRuleCall call) {
 Project project = call.rel(0);
 assert isTrivial(project);
 RelNode stripped = project.getInput();
 if (stripped instanceof Project) {
  // Rename columns of child projection if desired field names are given.
  Project childProject = (Project) stripped;
  stripped = childProject.copy(childProject.getTraitSet(),
    childProject.getInput(), childProject.getProjects(),
    project.getRowType());
 }
 RelNode child = call.getPlanner().register(stripped, project);
 call.transformTo(child);
}

代码示例来源:origin: Qihoo360/Quicksql

public void onMatch(RelOptRuleCall call) {
 Project project = call.rel(0);
 assert isTrivial(project);
 RelNode stripped = project.getInput();
 if (stripped instanceof Project) {
  // Rename columns of child projection if desired field names are given.
  Project childProject = (Project) stripped;
  stripped = childProject.copy(childProject.getTraitSet(),
    childProject.getInput(), childProject.getProjects(),
    project.getRowType());
 }
 RelNode child = call.getPlanner().register(stripped, project);
 call.transformTo(child);
}

代码示例来源:origin: Qihoo360/Quicksql

final RelNode newProject = project.copy(project.getTraitSet(),
     ImmutableList.of(Util.last(query.rels)));
 RelNode newNode = DruidQuery.extendQuery(query, newProject);
final RelNode newProject = project.copy(project.getTraitSet(), input, below, builder.build());
final DruidQuery newQuery = DruidQuery.extendQuery(query, newProject);
final RelNode newProject2 = project.copy(project.getTraitSet(), newQuery, above,
    project.getRowType());
call.transformTo(newProject2);

代码示例来源:origin: dremio/dremio-oss

@Override
 public void onMatch(RelOptRuleCall call) {
  final Project toTransform = call.rel(0);
  final RelNode input = toTransform.getInput();
  final RelTraitSet traits = toTransform.getTraitSet().plus(Rel.LOGICAL);
  final RelNode convertedInput = convert(input, input.getTraitSet().plus(Rel.LOGICAL).simplify());
  call.transformTo(new ProjectRel(toTransform.getCluster(), traits, convertedInput, toTransform.getProjects(), toTransform.getRowType()));
 }
}

代码示例来源:origin: org.apache.drill.exec/drill-java-exec

@Override
 public void onMatch(RelOptRuleCall call) {
  final Project project = call.rel(0);
  final RelNode input = project.getInput();
  final RelTraitSet traits = project.getTraitSet().plus(DrillRel.DRILL_LOGICAL);
  final RelNode convertedInput = convert(input, input.getTraitSet().plus(DrillRel.DRILL_LOGICAL).simplify());
  call.transformTo(new DrillProjectRel(
    project.getCluster(), traits, convertedInput, project.getProjects(), project.getRowType()));
 }
}

代码示例来源:origin: org.apache.calcite/calcite-druid

!= null) {
 final RelNode newProject = project.copy(project.getTraitSet(),
   ImmutableList.of(Util.last(query.rels)));
 RelNode newNode = DruidQuery.extendQuery(query, newProject);
final RelNode newProject = project.copy(project.getTraitSet(), input, below, builder.build());
final DruidQuery newQuery = DruidQuery.extendQuery(query, newProject);
final RelNode newProject2 = project.copy(project.getTraitSet(), newQuery, above,
    project.getRowType());
call.transformTo(newProject2);

代码示例来源:origin: org.apache.calcite/calcite-druid

.copy(project.getTraitSet(), ImmutableList.of(Util.last(query.rels)));
final DruidQuery newQuery = DruidQuery.extendQuery(query, newProject);
call.transformTo(newQuery);

代码示例来源:origin: Qihoo360/Quicksql

public void onMatch(RelOptRuleCall call) {
 Project project = call.rel(0);
 DruidQuery query = call.rel(1);
 final RelOptCluster cluster = project.getCluster();
 final RexBuilder rexBuilder = cluster.getRexBuilder();
 if (!DruidQuery.isValidSignature(query.signature() + 'o')) {
  return;
 }
 Pair<ImmutableMap<String, String>, Boolean> scanned = scanProject(query, project);
 // Only try to push down Project when there will be Post aggregators in result DruidQuery
 if (scanned.right) {
  Pair<Project, Project> splitProjectAggregate = splitProject(rexBuilder, query,
      project, scanned.left, cluster);
  Project inner = splitProjectAggregate.left;
  Project outer = splitProjectAggregate.right;
  DruidQuery newQuery = DruidQuery.extendQuery(query, inner);
  // When all project get pushed into DruidQuery, the project can be replaced by DruidQuery.
  if (outer != null) {
   Project newProject = outer.copy(outer.getTraitSet(), newQuery, outer.getProjects(),
     outer.getRowType());
   call.transformTo(newProject);
  } else {
   call.transformTo(newQuery);
  }
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

? project.copy(project.getTraitSet(), newFilterRel,
  project.getProjects(), project.getRowType())
: relBuilder.push(newFilterRel)

相关文章