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


Java LogicalProject类代码示例

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


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

示例1: matches

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
@Override
public boolean matches(RelOptRuleCall call) {
  try {

    final LogicalProject project = (LogicalProject) call.rel(0);
    for (RexNode node : project.getChildExps()) {
      if (!checkedExpressions.get(node)) {
        return false;
      }
    }
    return true;

  } catch (ExecutionException e) {
    throw new IllegalStateException("Failure while trying to evaluate pushdown.", e);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:17,代码来源:DrillJdbcRuleBase.java

示例2: visit

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
@Override
public RelNode visit(LogicalProject project) {
  RelNode input = project.getInput().accept(this);
  RelDataType incomingRowType = input.getRowType();
  List<RexNode> newProjects;
  RelDataTypeField modField = incomingRowType.getField(UPDATE_COLUMN, false, false);
  if (modField == null) {
    return project;
  }
  newProjects = FluentIterable.from(project.getProjects())
    .append(new RexInputRef(modField.getIndex(), modField.getType()))
    .toList();
  FieldInfoBuilder fieldInfoBuilder = new FieldInfoBuilder(project.getCluster().getTypeFactory());
  for (RelDataTypeField field : project.getRowType().getFieldList()) {
    fieldInfoBuilder.add(field);
  }
  fieldInfoBuilder.add(UPDATE_COLUMN, modField.getType());
  return new LogicalProject(
    project.getCluster(),
    project.getTraitSet(),
    input,
    newProjects,
    fieldInfoBuilder.build()
  );
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:26,代码来源:IncrementalUpdateUtils.java

示例3: populate

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
private static boolean populate(List<RelNode> nodes, List<int[][]> tempLinks,
    RelNode rel) {
  if (nodes.isEmpty() && rel instanceof LogicalProject) {
    return populate(nodes, tempLinks, ((LogicalProject) rel).getInput());
  }
  if (rel instanceof TableScan) {
    nodes.add(rel);
    return true;
  }
  if (rel instanceof LogicalJoin) {
    LogicalJoin join = (LogicalJoin) rel;
    if (join.getJoinType() != JoinRelType.INNER) {
      throw new RuntimeException("only inner join allowed, but got "
          + join.getJoinType());
    }
    populate(nodes, tempLinks, join.getLeft());
    populate(nodes, tempLinks, join.getRight());
    for (RexNode rex : RelOptUtil.conjunctions(join.getCondition())) {
      tempLinks.add(grab(nodes, rex));
    }
    return true;
  }
  throw new RuntimeException("Invalid node type "
      + rel.getClass().getSimpleName() + " in lattice query");
}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:Lattice.java

示例4: getProjectChild

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
protected RelNode getProjectChild(
    RelOptRuleCall call,
    LogicalProject project,
    boolean leftChild) {
  // locate the appropriate MultiJoin based on which rule was fired
  // and which projection we're dealing with
  MultiJoin multiJoin;
  if (leftChild) {
    multiJoin = call.rel(2);
  } else if (call.rels.length == 4) {
    multiJoin = call.rel(3);
  } else {
    multiJoin = call.rel(4);
  }

  // create a new MultiJoin that reflects the columns in the projection
  // above the MultiJoin
  return RelOptUtil.projectMultiJoin(multiJoin, project);
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:MultiJoinProjectTransposeRule.java

示例5: 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

示例6: testSplitJoinCondition

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
/** Test case for
 * <a href="https://issues.apache.org/jira/browse/CALCITE-833">[CALCITE-833]
 * RelOptUtil.splitJoinCondition attempts to split a Join-Condition which
 * has a remaining condition</a>. */
@Test public void testSplitJoinCondition() {
  final String sql = "select * \n"
      + "from emp a \n"
      + "INNER JOIN dept b \n"
      + "ON CAST(a.empno AS int) <> b.deptno";

  final RelNode relNode = toRel(sql);
  final LogicalProject project = (LogicalProject) relNode;
  final LogicalJoin join = (LogicalJoin) project.getInput(0);
  final List<RexNode> leftJoinKeys = new ArrayList<>();
  final List<RexNode> rightJoinKeys = new ArrayList<>();
  final ArrayList<RelDataTypeField> sysFieldList = new ArrayList<>();
  final RexNode remaining = RelOptUtil.splitJoinCondition(sysFieldList,
      join.getInputs().get(0),
      join.getInputs().get(1),
      join.getCondition(),
      leftJoinKeys,
      rightJoinKeys,
      null,
      null);

  assertThat(remaining.toString(), is("<>(CAST($0):INTEGER NOT NULL, $9)"));
  assertThat(leftJoinKeys.isEmpty(), is(true));
  assertThat(rightJoinKeys.isEmpty(), is(true));
}
 
开发者ID:apache,项目名称:calcite,代码行数:30,代码来源:RexTransformerTest.java

示例7: toRel

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
@Override public RelNode toRel(ToRelContext context) {
  RelNode rel = LogicalTableScan.create(context.getCluster(), fromTable);
  final RexBuilder rexBuilder = context.getCluster().getRexBuilder();
  rel = LogicalFilter.create(
      rel, getConstraint(rexBuilder, rel.getRowType()));
  final List<RelDataTypeField> fieldList =
      rel.getRowType().getFieldList();
  final List<Pair<RexNode, String>> projects =
      new AbstractList<Pair<RexNode, String>>() {
        @Override public Pair<RexNode, String> get(int index) {
          return RexInputRef.of2(mapping.get(index), fieldList);
        }

        @Override public int size() {
          return mapping.size();
        }
      };
  return LogicalProject.create(rel, Pair.left(projects),
      Pair.right(projects));
}
 
开发者ID:apache,项目名称:calcite,代码行数:21,代码来源:MockCatalogReader.java

示例8: onMatch

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
  LogicalProject rel = call.rel(0);
  RelNode rawInput = call.rel(1);
  RelNode input = convert(rawInput, PHYSICAL);

  if (subsetHack && input instanceof RelSubset) {
    RelSubset subset = (RelSubset) input;
    for (RelNode child : subset.getRels()) {
      // skip logical nodes
      if (child.getTraitSet().getTrait(ConventionTraitDef.INSTANCE)
          == Convention.NONE) {
        continue;
      } else {
        RelTraitSet outcome = child.getTraitSet().replace(PHYSICAL);
        call.transformTo(
            new PhysProj(rel.getCluster(), outcome, convert(child, outcome),
                rel.getChildExps(), rel.getRowType()));
      }
    }
  } else {
    call.transformTo(
        PhysProj.create(input, rel.getChildExps(), rel.getRowType()));
  }

}
 
开发者ID:apache,项目名称:calcite,代码行数:26,代码来源:TraitPropagationTest.java

示例9: visit

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
@Override
public RelNode visit(LogicalProject project) {
  final RelNode input = project.getInput().accept(this);
  return new LogicalProject(
    cluster,
    copyOf(project.getTraitSet()),
    input,
    Lists.transform(project.getProjects(), COPY_REX_NODE),
    copyOf(project.getRowType())
  );
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:12,代码来源:CopyWithCluster.java

示例10: visit

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
@Override
public RelNode visit(LogicalProject project) {
  if(state == State.AGG) {
    toState(project, State.AGG_PROJECT);
  } else if(state == State.AGG_PROJECT) {
    // treat one or many projects the same.
  } else {
    toState(project, State.OUT);
  }
  return visitChildren(project);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:12,代码来源:AggJoinFinder.java

示例11: visit

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
@Override
public RelNode visit(LogicalProject project) {
  final RenameConvertToConvertFromVisitor renameVisitor = new RenameConvertToConvertFromVisitor(project.getCluster().getRexBuilder(), table);
  final List<RexNode> projExpr = Lists.newArrayList();
  for(RexNode rexNode : project.getChildExps()) {
    projExpr.add(rexNode.accept(unwrappingExpressionVisitor));
  }

  project =  project.copy(project.getTraitSet(),
      project.getInput(),
      projExpr,
      project.getRowType());

  List<RexNode> exprList = new ArrayList<>();
  boolean rewrite = false;

  for (RexNode rex : project.getChildExps()) {
    RexNode newExpr = rex.accept(renameVisitor);
    if (newExpr != rex) {
      rewrite = true;
    }
    exprList.add(newExpr);
  }

  if (rewrite == true) {
    LogicalProject newProject = project.copy(project.getTraitSet(), project.getInput(0), exprList, project.getRowType());
    return visitChild(newProject, 0, project.getInput());
  }

  return visitChild(project, 0, project.getInput());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:32,代码来源:PreProcessRel.java

示例12: expandRaw

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
private RelNode expandRaw(final Layout layout) {
  Preconditions.checkArgument(layout.getLayoutType() == LayoutType.RAW, "required raw layout");

  final List<LayoutField> fields = AccelerationUtils.selfOrEmpty(layout.getDetails().getDisplayFieldList());

  final List<String> names = FluentIterable
      .from(fields)
      .transform(new Function<LayoutField, String>() {
        @Nullable
        @Override
        public String apply(@Nullable final LayoutField input) {
          return input.getName();
        }
      })
      .toList();

  final List<RexInputRef> projections = FluentIterable
      .from(names)
      .transform(new Function<String, RexInputRef>() {
        @Nullable
        @Override
        public RexInputRef apply(@Nullable final String fieldName) {
          final RelDataTypeField field = getField(fieldName);
          return new RexInputRef(field.getIndex(), field.getType());
        }
      })
      .toList();

  return LogicalProject.create(view, projections, names);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:31,代码来源:LayoutExpander.java

示例13: projectJoinOutputWithNullability

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
/**
 * Pulls project above the join from its RHS input. Enforces nullability
 * for join output.
 *
 * @param join             Join
 * @param project          Original project as the right-hand input of the join
 * @param nullIndicatorPos Position of null indicator
 * @return the subtree with the new LogicalProject at the root
 */
private RelNode projectJoinOutputWithNullability(LogicalJoin join, LogicalProject project, int nullIndicatorPos) {
	final RelDataTypeFactory typeFactory = join.getCluster().getTypeFactory();
	final RelNode left = join.getLeft();
	final JoinRelType joinType = join.getJoinType();

	RexInputRef nullIndicator = new RexInputRef(nullIndicatorPos, typeFactory.createTypeWithNullability(join.getRowType().getFieldList().get(nullIndicatorPos).getType(), true));

	// now create the new project
	List<Pair<RexNode, String>> newProjExprs = Lists.newArrayList();

	// project everything from the LHS and then those from the original
	// projRel
	List<RelDataTypeField> leftInputFields = left.getRowType().getFieldList();

	for (int i = 0; i < leftInputFields.size(); i++) {
		newProjExprs.add(RexInputRef.of2(i, leftInputFields));
	}

	// Marked where the projected expr is coming from so that the types will
	// become nullable for the original projections which are now coming out
	// of the nullable side of the OJ.
	boolean projectPulledAboveLeftCorrelator = joinType.generatesNullsOnRight();

	for (Pair<RexNode, String> pair : project.getNamedProjects()) {
		RexNode newProjExpr = removeCorrelationExpr(pair.left, projectPulledAboveLeftCorrelator, nullIndicator);

		newProjExprs.add(Pair.of(newProjExpr, pair.right));
	}

	return RelOptUtil.createProject(join, newProjExprs, false);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:41,代码来源:FlinkRelDecorrelator.java

示例14: aggregateCorrelatorOutput

import org.apache.calcite.rel.logical.LogicalProject; //导入依赖的package包/类
/**
 * Pulls a {@link Project} above a {@link Correlate} from its RHS input.
 * Enforces nullability for join output.
 *
 * @param correlate Correlate
 * @param project   the original project as the RHS input of the join
 * @param isCount   Positions which are calls to the <code>COUNT</code>
 *                  aggregation function
 * @return the subtree with the new LogicalProject at the root
 */
private RelNode aggregateCorrelatorOutput(Correlate correlate, LogicalProject project, Set<Integer> isCount) {
	final RelNode left = correlate.getLeft();
	final JoinRelType joinType = correlate.getJoinType().toJoinType();

	// now create the new project
	final List<Pair<RexNode, String>> newProjects = Lists.newArrayList();

	// Project everything from the LHS and then those from the original
	// project
	final List<RelDataTypeField> leftInputFields = left.getRowType().getFieldList();

	for (int i = 0; i < leftInputFields.size(); i++) {
		newProjects.add(RexInputRef.of2(i, leftInputFields));
	}

	// Marked where the projected expr is coming from so that the types will
	// become nullable for the original projections which are now coming out
	// of the nullable side of the OJ.
	boolean projectPulledAboveLeftCorrelator = joinType.generatesNullsOnRight();

	for (Pair<RexNode, String> pair : project.getNamedProjects()) {
		RexNode newProjExpr = removeCorrelationExpr(pair.left, projectPulledAboveLeftCorrelator, isCount);
		newProjects.add(Pair.of(newProjExpr, pair.right));
	}

	return RelOptUtil.createProject(correlate, newProjects, false);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:38,代码来源:FlinkRelDecorrelator.java

示例15: 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


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