当前位置: 首页>>代码示例>>Java>>正文


Java LogicalProject.getProjects方法代码示例

本文整理汇总了Java中org.apache.calcite.rel.logical.LogicalProject.getProjects方法的典型用法代码示例。如果您正苦于以下问题:Java LogicalProject.getProjects方法的具体用法?Java LogicalProject.getProjects怎么用?Java LogicalProject.getProjects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.calcite.rel.logical.LogicalProject的用法示例。


在下文中一共展示了LogicalProject.getProjects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onMatch

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
  final LogicalFilter filter = call.rel(0);
  final LogicalProject 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(LogicalFilter.create(newProject, newCondition));
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:SubstitutionVisitor.java

示例2: onMatch

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
	LogicalAggregate singleAggregate = call.rel(0);
	LogicalProject project = call.rel(1);
	LogicalAggregate aggregate = call.rel(2);

	// check singleAggRel is single_value agg
	if ((!singleAggregate.getGroupSet().isEmpty()) || (singleAggregate.getAggCallList().size() != 1) || !(singleAggregate.getAggCallList().get(0).getAggregation() instanceof SqlSingleValueAggFunction)) {
		return;
	}

	// check projRel only projects one expression
	// check this project only projects one expression, i.e. scalar
	// subqueries.
	List<RexNode> projExprs = project.getProjects();
	if (projExprs.size() != 1) {
		return;
	}

	// check the input to projRel is an aggregate on the entire input
	if (!aggregate.getGroupSet().isEmpty()) {
		return;
	}

	// singleAggRel produces a nullable type, so create the new
	// projection that casts proj expr to a nullable type.
	final RelOptCluster cluster = project.getCluster();
	RelNode newProject = RelOptUtil.createProject(aggregate, ImmutableList.of(rexBuilder.makeCast(cluster.getTypeFactory().createTypeWithNullability(projExprs.get(0).getType(), true), projExprs.get(0))), null);
	call.transformTo(newProject);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:30,代码来源:FlinkRelDecorrelator.java

示例3: visit

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
@Override
public RelNode visit(LogicalProject project) {
	try {
		stack.push(project);
		for (RexNode node : project.getProjects()) {
			node.accept(rexVisitor(project));
		}
	} finally {
		stack.pop();
	}
	return super.visit(project);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:13,代码来源:FlinkRelDecorrelator.java

示例4: convert

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
public RelNode convert(RelNode rel) {
    final LogicalProject project = (LogicalProject) rel;

    return new JdbcProject(
            rel.getCluster(),
            rel.getTraitSet().replace(getOut()),
            convert(
                    project.getInput(),
                    project.getInput().getTraitSet().replace(getOut())),
            project.getProjects(),
            project.getRowType());
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:13,代码来源:JdbcRules.java

示例5: onMatch

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
@Override
public void onMatch(RelOptRuleCall call) {
    LogicalProject project = call.rel(0);

    RelTraitSet origTraitSet = project.getTraitSet();
    RelTraitSet traitSet = origTraitSet.replace(OLAPRel.CONVENTION).simplify();

    OLAPProjectRel olapProj = new OLAPProjectRel(project.getCluster(), traitSet, //
            convert(project.getInput(), traitSet), project.getProjects(), project.getRowType());
    call.transformTo(olapProj);
}
 
开发者ID:apache,项目名称:kylin,代码行数:12,代码来源:OLAPProjectRule.java

示例6: matches

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
@Override public boolean matches(RelOptRuleCall call) {
  LogicalProject project = call.rel(0);
  for (RexNode e : project.getProjects()) {
    if (!(e instanceof RexInputRef)) {
      return false;
    }
  }

  return true;
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:CassandraRules.java

示例7: convert

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
public RelNode convert(RelNode rel) {
  final LogicalProject project = (LogicalProject) rel;
  final RelTraitSet traitSet = project.getTraitSet().replace(out);
  return new CassandraProject(project.getCluster(), traitSet,
      convert(project.getInput(), out), project.getProjects(),
      project.getRowType());
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:CassandraRules.java

示例8: convert

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
public RelNode convert(RelNode rel) {
  final LogicalProject project = (LogicalProject) rel;
  final RelTraitSet traitSet = project.getTraitSet().replace(out);
  return new MongoProject(project.getCluster(), traitSet,
      convert(project.getInput(), out), project.getProjects(),
      project.getRowType());
}
 
开发者ID:apache,项目名称:calcite,代码行数:8,代码来源:MongoRules.java

示例9: onMatch

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
  SemiJoin semiJoin = call.rel(0);
  LogicalProject project = call.rel(1);

  // Convert the LHS semi-join keys to reference the child projection
  // expression; all projection expressions must be RexInputRefs,
  // otherwise, we wouldn't have created this semi-join.
  final List<Integer> newLeftKeys = new ArrayList<>();
  final List<Integer> leftKeys = semiJoin.getLeftKeys();
  final List<RexNode> projExprs = project.getProjects();
  for (int leftKey : leftKeys) {
    RexInputRef inputRef = (RexInputRef) projExprs.get(leftKey);
    newLeftKeys.add(inputRef.getIndex());
  }

  // convert the semijoin condition to reflect the LHS with the project
  // pulled up
  RexNode newCondition = adjustCondition(project, semiJoin);

  SemiJoin newSemiJoin =
      SemiJoin.create(project.getInput(), semiJoin.getRight(), newCondition,
          ImmutableIntList.copyOf(newLeftKeys), semiJoin.getRightKeys());

  // Create the new projection.  Note that the projection expressions
  // are the same as the original because they only reference the LHS
  // of the semijoin and the semijoin only projects out the LHS
  final RelBuilder relBuilder = call.builder();
  relBuilder.push(newSemiJoin);
  relBuilder.project(projExprs, project.getRowType().getFieldNames());

  call.transformTo(relBuilder.build());
}
 
开发者ID:apache,项目名称:calcite,代码行数:33,代码来源:SemiJoinProjectTransposeRule.java

示例10: convert

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
public RelNode convert(RelNode rel) {
  final LogicalProject project = (LogicalProject) rel;

  return new JdbcProject(
      rel.getCluster(),
      rel.getTraitSet().replace(out),
      convert(
          project.getInput(),
          project.getInput().getTraitSet().replace(out)),
      project.getProjects(),
      project.getRowType());
}
 
开发者ID:apache,项目名称:calcite,代码行数:13,代码来源:JdbcRules.java

示例11: onMatch

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
  LogicalAggregate singleAggregate = call.rel(0);
  LogicalProject project = call.rel(1);
  LogicalAggregate aggregate = call.rel(2);

  // check singleAggRel is single_value agg
  if ((!singleAggregate.getGroupSet().isEmpty())
      || (singleAggregate.getAggCallList().size() != 1)
      || !(singleAggregate.getAggCallList().get(0).getAggregation()
      instanceof SqlSingleValueAggFunction)) {
    return;
  }

  // check projRel only projects one expression
  // check this project only projects one expression, i.e. scalar
  // sub-queries.
  List<RexNode> projExprs = project.getProjects();
  if (projExprs.size() != 1) {
    return;
  }

  // check the input to project is an aggregate on the entire input
  if (!aggregate.getGroupSet().isEmpty()) {
    return;
  }

  // singleAggRel produces a nullable type, so create the new
  // projection that casts proj expr to a nullable type.
  final RelOptCluster cluster = project.getCluster();
  RelNode newProject =
      RelOptUtil.createProject(aggregate,
          ImmutableList.of(
              rexBuilder.makeCast(
                  cluster.getTypeFactory().createTypeWithNullability(
                      projExprs.get(0).getType(),
                      true),
                  projExprs.get(0))),
          null);
  call.transformTo(newProject);
}
 
开发者ID:apache,项目名称:calcite,代码行数:41,代码来源:RelDecorrelator.java

示例12: visit

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
@Override public RelNode visit(LogicalProject project) {
  try {
    stack.push(project);
    for (RexNode node : project.getProjects()) {
      node.accept(rexVisitor(project));
    }
  } finally {
    stack.pop();
  }
  return super.visit(project);
}
 
开发者ID:apache,项目名称:calcite,代码行数:12,代码来源:RelDecorrelator.java

示例13: convert

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
public RelNode convert(RelNode rel) {
  final LogicalProject project = (LogicalProject) rel;
  return new BindableProject(rel.getCluster(),
      rel.getTraitSet().replace(BindableConvention.INSTANCE),
      convert(project.getInput(),
          project.getInput().getTraitSet()
              .replace(BindableConvention.INSTANCE)),
      project.getProjects(),
      project.getRowType());
}
 
开发者ID:apache,项目名称:calcite,代码行数:11,代码来源:Bindables.java

示例14: convert

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
public RelNode convert(RelNode rel) {
  LogicalProject project = (LogicalProject) rel;
  return new JdbcRules.JdbcProject(rel.getCluster(), rel.getTraitSet().replace(this.out), convert(
      project.getInput(), project.getInput().getTraitSet().replace(this.out)), project.getProjects(),
      project.getRowType());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:7,代码来源:DrillJdbcRuleBase.java

示例15: decorrelateRel

import org.apache.calcite.rel.logical.LogicalProject; //导入方法依赖的package包/类
/**
 * Rewrite LogicalProject.
 *
 * @param rel the project rel to rewrite
 */
public Frame decorrelateRel(LogicalProject rel) {
	//
	// Rewrite logic:
	//
	// 1. Pass along any correlated variables coming from the input.
	//

	final RelNode oldInput = rel.getInput();
	Frame frame = getInvoke(oldInput, rel);
	if (frame == null) {
		// If input has not been rewritten, do not rewrite this rel.
		return null;
	}
	final List<RexNode> oldProjects = rel.getProjects();
	final List<RelDataTypeField> relOutput = rel.getRowType().getFieldList();

	// LogicalProject projects the original expressions,
	// plus any correlated variables the input wants to pass along.
	final List<Pair<RexNode, String>> projects = Lists.newArrayList();

	// If this LogicalProject has correlated reference, create value generator
	// and produce the correlated variables in the new output.
	if (cm.mapRefRelToCorVar.containsKey(rel)) {
		decorrelateInputWithValueGenerator(rel);

		// The old input should be mapped to the LogicalJoin created by
		// rewriteInputWithValueGenerator().
		frame = map.get(oldInput);
	}

	// LogicalProject projects the original expressions
	final Map<Integer, Integer> mapOldToNewOutputPos = Maps.newHashMap();
	int newPos;
	for (newPos = 0; newPos < oldProjects.size(); newPos++) {
		projects.add(newPos, Pair.of(decorrelateExpr(oldProjects.get(newPos)), relOutput.get(newPos).getName()));
		mapOldToNewOutputPos.put(newPos, newPos);
	}

	// Project any correlated variables the input wants to pass along.
	final SortedMap<Correlation, Integer> mapCorVarToOutputPos = new TreeMap<>();
	for (Map.Entry<Correlation, Integer> entry : frame.corVarOutputPos.entrySet()) {
		projects.add(RexInputRef.of2(entry.getValue(), frame.r.getRowType().getFieldList()));
		mapCorVarToOutputPos.put(entry.getKey(), newPos);
		newPos++;
	}

	RelNode newProject = RelOptUtil.createProject(frame.r, projects, false);

	return register(rel, newProject, mapOldToNewOutputPos, mapCorVarToOutputPos);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:56,代码来源:FlinkRelDecorrelator.java


注:本文中的org.apache.calcite.rel.logical.LogicalProject.getProjects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。