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

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

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

Project.getInput介绍

暂无

代码示例

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

static HiveTableScan getTableScan(RelNode r, boolean traverseProject) {

  while (r != null && !(r instanceof HiveTableScan)) {
   if (r instanceof HepRelVertex) {
    r = ((HepRelVertex) r).getCurrentRel();
   } else if (r instanceof Filter) {
    r = ((Filter) r).getInput();
   } else if (traverseProject && r instanceof Project) {
    r = ((Project) r).getInput();
   } else {
    r = null;
   }
  }
  return r == null ? null : (HiveTableScan) r;
 }
}

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

static HiveTableScan getTableScan(RelNode r, boolean traverseProject) {
 while (r != null && !(r instanceof HiveTableScan)) {
  if (r instanceof HepRelVertex) {
   r = ((HepRelVertex) r).getCurrentRel();
  } else if (r instanceof Filter) {
   r = ((Filter) r).getInput();
  } else if (traverseProject && r instanceof Project) {
   r = ((Project) r).getInput();
  } else {
   r = null;
  }
 }
 return r == null ? null : (HiveTableScan) r;
}

代码示例来源: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 RelOptMaterialization apply(RelOptMaterialization materialization) {
 final RelNode viewScan = materialization.tableRel;
 final RelNode newViewScan;
 if (viewScan instanceof Project) {
  // There is a Project on top (due to nullability)
  final Project pq = (Project) viewScan;
  newViewScan = HiveProject.create(optCluster, copyNodeScan(pq.getInput()),
    pq.getChildExps(), pq.getRowType(), Collections.<RelCollation> emptyList());
 } else {
  newViewScan = copyNodeScan(viewScan);
 }
 return new RelOptMaterialization(newViewScan, materialization.queryRel, null,
   materialization.qualifiedTableName);
}

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

);
if (RexUtil.isIdentity(newProjectRexNodes, selectProject.getInput().getRowType())) {
 relBuilder.push(selectProject.getInput());
 relBuilder.project(
   newProjectRexNodes,

代码示例来源: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/hive

private boolean isPartitionPredicate(RexNode expr, RelNode r) {
 if (r instanceof Project) {
  expr = RelOptUtil.pushFilterPastProject(expr, (Project) r);
  return isPartitionPredicate(expr, ((Project) r).getInput());
 } else if (r instanceof Filter) {
  return isPartitionPredicate(expr, ((Filter) r).getInput());
 } else if (r instanceof HiveTableScan) {
  RelOptHiveTable table = (RelOptHiveTable) ((HiveTableScan) r).getTable();
  ImmutableBitSet cols = RelOptUtil.InputFinder.bits(expr);
  return table.containsPartitionColumnsOnly(cols);
 }
 return false;
}

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

public Result translate(Project e) {
 // This variant is for the top project as we want to keep
 // the column aliases instead of producing STAR
 Result x = visitChild(0, e.getInput());
 parseCorrelTable(e, x);
 final Builder builder =
   x.builder(e, Clause.SELECT);
 final List<SqlNode> selectList = new ArrayList<>();
 for (RexNode ref : e.getChildExps()) {
  SqlNode sqlExpr = builder.context.toSql(null, ref);
  addSelect(selectList, sqlExpr, e.getRowType());
 }
 builder.setSelect(new SqlNodeList(selectList, POS));
 return builder.result();
}

代码示例来源: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

private boolean isPartitionPredicate(RexNode expr, RelNode r) {
 if (r instanceof Project) {
  expr = RelOptUtil.pushFilterPastProject(expr, (Project) r);
  return isPartitionPredicate(expr, ((Project) r).getInput());
 } else if (r instanceof Filter) {
  return isPartitionPredicate(expr, ((Filter) r).getInput());
 } else if (r instanceof HiveTableScan) {
  RelOptHiveTable table = (RelOptHiveTable) ((HiveTableScan) r).getTable();
  ImmutableBitSet cols = RelOptUtil.InputFinder.bits(expr);
  return table.containsPartitionColumnsOnly(cols);
 }
 return false;
}

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

private static RelNode getNewProject(RexNode filterCondToPushBelowProj, RexNode unPushedFilCondAboveProj, Project oldProj,
  RelDataTypeFactory typeFactory, RelBuilder relBuilder) {
 // convert the filter to one that references the child of the project
 RexNode newPushedCondition = RelOptUtil.pushPastProject(filterCondToPushBelowProj, oldProj);
 // Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
 // nullable and not-nullable conditions, but a CAST might get in the way of
 // other rewrites.
 if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
  newPushedCondition = ((RexCall) newPushedCondition).getOperands().get(0);
 }
 RelNode newPushedFilterRel = relBuilder.push(oldProj.getInput()).filter(newPushedCondition).build();
 RelNode newProjRel = relBuilder.push(newPushedFilterRel)
   .project(oldProj.getProjects(), oldProj.getRowType().getFieldNames()).build();
 if (unPushedFilCondAboveProj != null) {
  // Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
  // nullable and not-nullable conditions, but a CAST might get in the way of
  // other rewrites.
  if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
   unPushedFilCondAboveProj = ((RexCall) unPushedFilCondAboveProj).getOperands().get(0);
  }
  newProjRel = relBuilder.push(newProjRel).filter(unPushedFilCondAboveProj).build();
 }
 return newProjRel;
}

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

input = project.getInput();

代码示例来源: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/drill

private static RelNode getNewProject(RexNode filterCondToPushBelowProj, RexNode unPushedFilCondAboveProj, Project oldProj,
  RelDataTypeFactory typeFactory, RelBuilder relBuilder) {
 // convert the filter to one that references the child of the project
 RexNode newPushedCondition = RelOptUtil.pushPastProject(filterCondToPushBelowProj, oldProj);
 // Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
 // nullable and not-nullable conditions, but a CAST might get in the way of
 // other rewrites.
 if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
  newPushedCondition = ((RexCall) newPushedCondition).getOperands().get(0);
 }
 RelNode newPushedFilterRel = relBuilder.push(oldProj.getInput()).filter(newPushedCondition).build();
 RelNode newProjRel = relBuilder.push(newPushedFilterRel)
   .project(oldProj.getProjects(), oldProj.getRowType().getFieldNames()).build();
 if (unPushedFilCondAboveProj != null) {
  // Remove cast of BOOLEAN NOT NULL to BOOLEAN or vice versa. Filter accepts
  // nullable and not-nullable conditions, but a CAST might get in the way of
  // other rewrites.
  if (RexUtil.isNullabilityCast(typeFactory, newPushedCondition)) {
   unPushedFilCondAboveProj = ((RexCall) unPushedFilCondAboveProj).getOperands().get(0);
  }
  newProjRel = relBuilder.push(newProjRel).filter(unPushedFilCondAboveProj).build();
 }
 return newProjRel;
}

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

public void onMatch(RelOptRuleCall call) {
 final Project topProject = call.rel(0);
 final Project bottomProject = call.rel(1);
 // If top project does not reference any column at the bottom project,
 // we can just remove botton project
 final ImmutableBitSet topRefs =
   RelOptUtil.InputFinder.bits(topProject.getChildExps(), null);
 if (topRefs.isEmpty()) {
  RelBuilder relBuilder = call.builder();
  relBuilder.push(bottomProject.getInput());
  relBuilder.project(topProject.getChildExps());
  call.transformTo(relBuilder.build());
  return;
 }
 super.onMatch(call);
}

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

project.getInput(), newCondition) : filterFactory.createFilter(project.getInput(),
newCondition);

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

final Join swappedJoin = (Join) bottomProject.getInput(0);
call.transformTo(swappedJoin);

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

public void onMatch(RelOptRuleCall call) {
    final Project project = call.rel(0);
    //TODO: replace HiveSubQRemoveRelBuilder with calcite's once calcite 1.11.0 is released
    final HiveSubQRemoveRelBuilder builder = new HiveSubQRemoveRelBuilder(null, call.rel(0).getCluster(), null);
    final RexSubQuery e =
        RexUtil.SubQueryFinder.find(project.getProjects());
    assert e != null;
    final RelOptUtil.Logic logic =
        LogicVisitor.find(RelOptUtil.Logic.TRUE_FALSE_UNKNOWN,
            project.getProjects(), e);
    builder.push(project.getInput());
    final int fieldCount = builder.peek().getRowType().getFieldCount();
    final RexNode target = apply(e, HiveFilter.getVariablesSet(e),
        logic, builder, 1, fieldCount, false);
    final RexShuttle shuttle = new ReplaceSubQueryShuttle(e, target);
    builder.project(shuttle.apply(project.getProjects()),
        project.getRowType().getFieldNames());
    call.transformTo(builder.build());
  }
};

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

final RelNode swappedJoin = swappedProject.getInput();
assert(swappedJoin instanceof  Join);

相关文章