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


Java Join.getJoinType方法代码示例

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


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

示例1: isRemovableSelfJoin

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
/**
 * Determines whether a join is a removable self-join. It is if it's an
 * inner join between identical, simple factors and the equality portion of
 * the join condition consists of the same set of unique keys.
 *
 * @param joinRel the join
 *
 * @return true if the join is removable
 */
public static boolean isRemovableSelfJoin(Join joinRel) {
  final RelNode left = joinRel.getLeft();
  final RelNode right = joinRel.getRight();

  if (joinRel.getJoinType() != JoinRelType.INNER) {
    return false;
  }

  // Make sure the join is between the same simple factor
  final RelMetadataQuery mq = joinRel.getCluster().getMetadataQuery();
  final RelOptTable leftTable = mq.getTableOrigin(left);
  if (leftTable == null) {
    return false;
  }
  final RelOptTable rightTable = mq.getTableOrigin(right);
  if (rightTable == null) {
    return false;
  }
  if (!leftTable.getQualifiedName().equals(rightTable.getQualifiedName())) {
    return false;
  }

  // Determine if the join keys are identical and unique
  return areSelfJoinKeysUnique(mq, left, right, joinRel.getCondition());
}
 
开发者ID:apache,项目名称:calcite,代码行数:35,代码来源:LoptOptimizeJoinRule.java

示例2: checkCartesianJoin

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
/**
   * Check if the given RelNode contains any Cartesian join.
   * Return true if find one. Otherwise, return false.
   *
   * @param relNode   the RelNode to be inspected.
   * @param leftKeys  a list used for the left input into the join which has
   *                  equi-join keys. It can be empty or not (but not null),
   *                  this method will clear this list before using it.
   * @param rightKeys a list used for the right input into the join which has
   *                  equi-join keys. It can be empty or not (but not null),
   *                  this method will clear this list before using it.
   * @return          Return true if the given relNode contains Cartesian join.
   *                  Otherwise, return false
   */
public static boolean checkCartesianJoin(RelNode relNode, List<Integer> leftKeys, List<Integer> rightKeys) {
  if (relNode instanceof Join) {
    leftKeys.clear();
    rightKeys.clear();

    Join joinRel = (Join) relNode;
    RelNode left = joinRel.getLeft();
    RelNode right = joinRel.getRight();

    RexNode remaining = RelOptUtil.splitJoinCondition(left, right, joinRel.getCondition(), leftKeys, rightKeys);
    if(joinRel.getJoinType() == JoinRelType.INNER) {
      if(leftKeys.isEmpty() || rightKeys.isEmpty()) {
        return true;
      }
    } else {
      if(!remaining.isAlwaysTrue() || leftKeys.isEmpty() || rightKeys.isEmpty()) {
        return true;
      }
    }
  }

  for (RelNode child : relNode.getInputs()) {
    if(checkCartesianJoin(child, leftKeys, rightKeys)) {
      return true;
    }
  }

  return false;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:44,代码来源:JoinUtils.java

示例3: checkCartesianJoin

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
/**
   * Check if the given RelNode contains any Cartesian join.
   * Return true if find one. Otherwise, return false.
   *
   * @param relNode   the RelNode to be inspected.
   * @param leftKeys  a list used for the left input into the join which has
   *                  equi-join keys. It can be empty or not (but not null),
   *                  this method will clear this list before using it.
   * @param rightKeys a list used for the right input into the join which has
   *                  equi-join keys. It can be empty or not (but not null),
   *                  this method will clear this list before using it.
   * @param filterNulls   The join key positions for which null values will not
   *                      match. null values only match for the "is not distinct
   *                      from" condition.
   * @return          Return true if the given relNode contains Cartesian join.
   *                  Otherwise, return false
   */
public static boolean checkCartesianJoin(RelNode relNode, List<Integer> leftKeys, List<Integer> rightKeys, List<Boolean> filterNulls) {
  if (relNode instanceof Join) {
    leftKeys.clear();
    rightKeys.clear();

    Join joinRel = (Join) relNode;
    RelNode left = joinRel.getLeft();
    RelNode right = joinRel.getRight();

    RexNode remaining = RelOptUtil.splitJoinCondition(left, right, joinRel.getCondition(), leftKeys, rightKeys, filterNulls);
    if(joinRel.getJoinType() == JoinRelType.INNER) {
      if(leftKeys.isEmpty() || rightKeys.isEmpty()) {
        return true;
      }
    } else {
      if(!remaining.isAlwaysTrue() || leftKeys.isEmpty() || rightKeys.isEmpty()) {
        return true;
      }
    }
  }

  for (RelNode child : relNode.getInputs()) {
    if(checkCartesianJoin(child, leftKeys, rightKeys, filterNulls)) {
      return true;
    }
  }

  return false;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:47,代码来源:JoinUtils.java

示例4: convert

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
@Override public RelNode convert(RelNode rel) {
  Join join = (Join) rel;
  return new BeamJoinRel(
      join.getCluster(),
      join.getTraitSet().replace(BeamLogicalConvention.INSTANCE),
      convert(join.getLeft(),
          join.getLeft().getTraitSet().replace(BeamLogicalConvention.INSTANCE)),
      convert(join.getRight(),
          join.getRight().getTraitSet().replace(BeamLogicalConvention.INSTANCE)),
      join.getCondition(),
      join.getVariablesSet(),
      join.getJoinType()
  );
}
 
开发者ID:apache,项目名称:beam,代码行数:15,代码来源:BeamJoinRule.java

示例5: checkCartesianJoin

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
/**
   * Check if the given RelNode contains any Cartesian join.
   * Return true if find one. Otherwise, return false.
   *
   * @param relNode     the RelNode to be inspected.
   * @param leftKeys    a list used for the left input into the join which has
   *                    equi-join keys. It can be empty or not (but not null),
   *                    this method will clear this list before using it.
   * @param rightKeys   a list used for the right input into the join which has
   *                    equi-join keys. It can be empty or not (but not null),
   *                    this method will clear this list before using it.
   * @param filterNulls The join key positions for which null values will not
   *                    match.
   * @return            Return true if the given relNode contains Cartesian join.
   *                    Otherwise, return false
   */
public static boolean checkCartesianJoin(RelNode relNode, List<Integer> leftKeys, List<Integer> rightKeys, List<Boolean> filterNulls) {
  if (relNode instanceof Join) {
    leftKeys.clear();
    rightKeys.clear();

    Join joinRel = (Join) relNode;
    RelNode left = joinRel.getLeft();
    RelNode right = joinRel.getRight();

    RexNode remaining = RelOptUtil.splitJoinCondition(left, right, joinRel.getCondition(), leftKeys, rightKeys, filterNulls);
    if (joinRel.getJoinType() == JoinRelType.INNER) {
      if (leftKeys.isEmpty() || rightKeys.isEmpty()) {
        return true;
      }
    } else {
      if (!remaining.isAlwaysTrue() || leftKeys.isEmpty() || rightKeys.isEmpty()) {
        return true;
      }
    }
  }

  for (RelNode child : relNode.getInputs()) {
    if (checkCartesianJoin(child, leftKeys, rightKeys, filterNulls)) {
      return true;
    }
  }

  return false;
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:46,代码来源:JoinUtils.java

示例6: visit

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
@Override
public RelInfo visit(RelContext context, RelNode node, List<RelInfo> inputStreams)
{
  Join join = (Join)node;
  if (inputStreams.size() != 2) {
    throw new UnsupportedOperationException("Join is a BiRel");
  }

  if ((join.getJoinType() == JoinRelType.FULL) || (join.getJoinType() == JoinRelType.LEFT) ||
      (join.getJoinType() == JoinRelType.RIGHT)) {
    throw new UnsupportedOperationException("Outer joins are not supported");
  }

  final List<Integer> leftKeys = new ArrayList<>();
  final List<Integer> rightKeys = new ArrayList<>();

  RexNode remaining =
      RelOptUtil.splitJoinCondition(join.getLeft(), join.getRight(), join.getCondition(), leftKeys, rightKeys);

  if (leftKeys.size() != rightKeys.size()) {
    throw new RuntimeException("Unexpected condition reached. Left and right condition count should be same");
  }

  if (leftKeys.size() == 0) {
    throw new UnsupportedOperationException("Theta joins are not supported.");
  }

  RelInfo relInfo = addInnerJoinOperator(join, leftKeys, rightKeys, context);

  if (!remaining.isAlwaysTrue()) {
    relInfo = addJoinFilter(join, remaining, relInfo, context);
  }

  return relInfo;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:36,代码来源:ApexRelNode.java

示例7: swap

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
/**
 * Returns a relational expression with the inputs switched round. Does not
 * modify <code>join</code>. Returns null if the join cannot be swapped (for
 * example, because it is an outer join).
 *
 * @param join           join to be swapped
 * @param swapOuterJoins whether outer joins should be swapped
 * @return swapped join if swapping possible; else null
 */
public static RelNode swap(Join join, boolean swapOuterJoins) {
  final JoinRelType joinType = join.getJoinType();
  if (!swapOuterJoins && joinType != JoinRelType.INNER) {
    return null;
  }
  final RexBuilder rexBuilder = join.getCluster().getRexBuilder();
  final RelDataType leftRowType = join.getLeft().getRowType();
  final RelDataType rightRowType = join.getRight().getRowType();
  final VariableReplacer variableReplacer =
      new VariableReplacer(rexBuilder, leftRowType, rightRowType);
  final RexNode oldCondition = join.getCondition();
  RexNode condition = variableReplacer.go(oldCondition);

  // NOTE jvs 14-Mar-2006: We preserve attribute semiJoinDone after the
  // swap.  This way, we will generate one semijoin for the original
  // join, and one for the swapped join, and no more.  This
  // doesn't prevent us from seeing any new combinations assuming
  // that the planner tries the desired order (semijoins after swaps).
  Join newJoin =
      join.copy(join.getTraitSet(), condition, join.getRight(),
          join.getLeft(), joinType.swap(), join.isSemiJoinDone());
  final List<RexNode> exps =
      RelOptUtil.createSwappedJoinExprs(newJoin, join, true);
  return RelOptUtil.createProject(
      newJoin,
      exps,
      join.getRowType().getFieldNames(),
      true);
}
 
开发者ID:apache,项目名称:calcite,代码行数:39,代码来源:JoinCommuteRule.java

示例8: onMatch

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
  final Join join = call.rel(0);

  if (join.getJoinType() != JoinRelType.INNER) {
    return;
  }

  if (join.getCondition().isAlwaysTrue()) {
    return;
  }

  if (!join.getSystemFieldList().isEmpty()) {
    // FIXME Enable this rule for joins with system fields
    return;
  }

  // NOTE jvs 14-Mar-2006:  See JoinCommuteRule for why we
  // preserve attribute semiJoinDone here.

  RelNode cartesianJoinRel =
      join.copy(
          join.getTraitSet(),
          join.getCluster().getRexBuilder().makeLiteral(true),
          join.getLeft(),
          join.getRight(),
          join.getJoinType(),
          join.isSemiJoinDone());

  final RelFactories.FilterFactory factory =
      RelFactories.DEFAULT_FILTER_FACTORY;
  RelNode filterRel =
      factory.createFilter(cartesianJoinRel, join.getCondition());

  call.transformTo(filterRel);
}
 
开发者ID:apache,项目名称:calcite,代码行数:36,代码来源:JoinExtractFilterRule.java

示例9: combineJoinFilters

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
/**
 * Combines the join filters from the left and right inputs (if they are
 * MultiJoinRels) with the join filter in the joinrel into a single AND'd
 * join filter, unless the inputs correspond to null generating inputs in an
 * outer join
 *
 * @param joinRel join rel
 * @param left    left child of the join
 * @param right   right child of the join
 * @return combined join filters AND-ed together
 */
private List<RexNode> combineJoinFilters(
    Join joinRel,
    RelNode left,
    RelNode right) {
  JoinRelType joinType = joinRel.getJoinType();

  // AND the join condition if this isn't a left or right outer join;
  // in those cases, the outer join condition is already tracked
  // separately
  final List<RexNode> filters = Lists.newArrayList();
  if ((joinType != JoinRelType.LEFT) && (joinType != JoinRelType.RIGHT)) {
    filters.add(joinRel.getCondition());
  }
  if (canCombine(left, joinType.generatesNullsOnLeft())) {
    filters.add(((MultiJoin) left).getJoinFilter());
  }
  // Need to adjust the RexInputs of the right child, since
  // those need to shift over to the right
  if (canCombine(right, joinType.generatesNullsOnRight())) {
    MultiJoin multiJoin = (MultiJoin) right;
    filters.add(
        shiftRightFilter(joinRel, left, multiJoin,
            multiJoin.getJoinFilter()));
  }

  return filters;
}
 
开发者ID:apache,项目名称:calcite,代码行数:39,代码来源:JoinToMultiJoinRule.java

示例10: onMatch

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
  Join origJoinRel = call.rel(0);
  if (origJoinRel.isSemiJoinDone()) {
    return;
  }

  // can't process outer joins using semijoins
  if (origJoinRel.getJoinType() != JoinRelType.INNER) {
    return;
  }

  // determine if we have a valid join condition
  final JoinInfo joinInfo = origJoinRel.analyzeCondition();
  if (joinInfo.leftKeys.size() == 0) {
    return;
  }

  RelNode semiJoin =
      SemiJoin.create(origJoinRel.getLeft(),
          origJoinRel.getRight(),
          origJoinRel.getCondition(),
          joinInfo.leftKeys,
          joinInfo.rightKeys);

  RelNode newJoinRel =
      origJoinRel.copy(
          origJoinRel.getTraitSet(),
          origJoinRel.getCondition(),
          semiJoin,
          origJoinRel.getRight(),
          JoinRelType.INNER,
          true);

  call.transformTo(newJoinRel);
}
 
开发者ID:apache,项目名称:calcite,代码行数:36,代码来源:JoinAddRedundantSemiJoinRule.java

示例11: test

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
public boolean test(Join input) {
  switch (input.getJoinType()) {
  case LEFT:
  case INNER:
    return true;
  default:
    return false;
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:10,代码来源:SemiJoinRule.java

示例12: visit

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
/** @see #dispatch */
public Result visit(Join e) {
  final Result leftResult = visitChild(0, e.getLeft()).resetAlias();
  final Result rightResult = visitChild(1, e.getRight()).resetAlias();
  final Context leftContext = leftResult.qualifiedContext();
  final Context rightContext = rightResult.qualifiedContext();
  SqlNode sqlCondition = null;
  SqlLiteral condType = JoinConditionType.ON.symbol(POS);
  JoinType joinType = joinType(e.getJoinType());
  if (e.getJoinType() == JoinRelType.INNER && e.getCondition().isAlwaysTrue()) {
    joinType = JoinType.COMMA;
    condType = JoinConditionType.NONE.symbol(POS);
  } else {
    sqlCondition = convertConditionToSqlNode(e.getCondition(),
        leftContext,
        rightContext,
        e.getLeft().getRowType().getFieldCount());
  }
  SqlNode join =
      new SqlJoin(POS,
          leftResult.asFrom(),
          SqlLiteral.createBoolean(false, POS),
          joinType.symbol(POS),
          rightResult.asFrom(),
          condType,
          sqlCondition);
  return result(join, leftResult, rightResult);
}
 
开发者ID:apache,项目名称:calcite,代码行数:29,代码来源:RelToSqlConverter.java

示例13: onMatch

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
public void onMatch(RelOptRuleCall call) {
  final Join origJoin = call.rel(0);
  final RelNode left = call.rel(1);
  final RelNode right = call.rel(2);

  // combine the children MultiJoin inputs into an array of inputs
  // for the new MultiJoin
  final List<ImmutableBitSet> projFieldsList = Lists.newArrayList();
  final List<int[]> joinFieldRefCountsList = Lists.newArrayList();
  final List<RelNode> newInputs =
      combineInputs(
          origJoin,
          left,
          right,
          projFieldsList,
          joinFieldRefCountsList);

  // combine the outer join information from the left and right
  // inputs, and include the outer join information from the current
  // join, if it's a left/right outer join
  final List<Pair<JoinRelType, RexNode>> joinSpecs = Lists.newArrayList();
  combineOuterJoins(
      origJoin,
      newInputs,
      left,
      right,
      joinSpecs);

  // pull up the join filters from the children MultiJoinRels and
  // combine them with the join filter associated with this LogicalJoin to
  // form the join filter for the new MultiJoin
  List<RexNode> newJoinFilters = combineJoinFilters(origJoin, left, right);

  // add on the join field reference counts for the join condition
  // associated with this LogicalJoin
  final ImmutableMap<Integer, ImmutableIntList> newJoinFieldRefCountsMap =
      addOnJoinFieldRefCounts(newInputs,
          origJoin.getRowType().getFieldCount(),
          origJoin.getCondition(),
          joinFieldRefCountsList);

  List<RexNode> newPostJoinFilters =
      combinePostJoinFilters(origJoin, left, right);

  final RexBuilder rexBuilder = origJoin.getCluster().getRexBuilder();
  RelNode multiJoin =
      new MultiJoin(
          origJoin.getCluster(),
          newInputs,
          RexUtil.composeConjunction(rexBuilder, newJoinFilters, false),
          origJoin.getRowType(),
          origJoin.getJoinType() == JoinRelType.FULL,
          Pair.right(joinSpecs),
          Pair.left(joinSpecs),
          projFieldsList,
          newJoinFieldRefCountsMap,
          RexUtil.composeConjunction(rexBuilder, newPostJoinFilters, true));

  call.transformTo(multiJoin);
}
 
开发者ID:apache,项目名称:calcite,代码行数:61,代码来源:JoinToMultiJoinRule.java

示例14: combineOuterJoins

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
/**
 * Combines the outer join conditions and join types from the left and right
 * join inputs. If the join itself is either a left or right outer join,
 * then the join condition corresponding to the join is also set in the
 * position corresponding to the null-generating input into the join. The
 * join type is also set.
 *
 * @param joinRel        join rel
 * @param combinedInputs the combined inputs to the join
 * @param left           left child of the joinrel
 * @param right          right child of the joinrel
 * @param joinSpecs      the list where the join types and conditions will be
 *                       copied
 */
private void combineOuterJoins(
    Join joinRel,
    List<RelNode> combinedInputs,
    RelNode left,
    RelNode right,
    List<Pair<JoinRelType, RexNode>> joinSpecs) {
  JoinRelType joinType = joinRel.getJoinType();
  boolean leftCombined =
      canCombine(left, joinType.generatesNullsOnLeft());
  boolean rightCombined =
      canCombine(right, joinType.generatesNullsOnRight());
  switch (joinType) {
  case LEFT:
    if (leftCombined) {
      copyOuterJoinInfo(
          (MultiJoin) left,
          joinSpecs,
          0,
          null,
          null);
    } else {
      joinSpecs.add(Pair.of(JoinRelType.INNER, (RexNode) null));
    }
    joinSpecs.add(Pair.of(joinType, joinRel.getCondition()));
    break;
  case RIGHT:
    joinSpecs.add(Pair.of(joinType, joinRel.getCondition()));
    if (rightCombined) {
      copyOuterJoinInfo(
          (MultiJoin) right,
          joinSpecs,
          left.getRowType().getFieldCount(),
          right.getRowType().getFieldList(),
          joinRel.getRowType().getFieldList());
    } else {
      joinSpecs.add(Pair.of(JoinRelType.INNER, (RexNode) null));
    }
    break;
  default:
    if (leftCombined) {
      copyOuterJoinInfo(
          (MultiJoin) left,
          joinSpecs,
          0,
          null,
          null);
    } else {
      joinSpecs.add(Pair.of(JoinRelType.INNER, (RexNode) null));
    }
    if (rightCombined) {
      copyOuterJoinInfo(
          (MultiJoin) right,
          joinSpecs,
          left.getRowType().getFieldCount(),
          right.getRowType().getFieldList(),
          joinRel.getRowType().getFieldList());
    } else {
      joinSpecs.add(Pair.of(JoinRelType.INNER, (RexNode) null));
    }
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:76,代码来源:JoinToMultiJoinRule.java

示例15: perform

import org.apache.calcite.rel.core.Join; //导入方法依赖的package包/类
protected void perform(RelOptRuleCall call, Project project,
    Join join, RelNode left, Aggregate aggregate) {
  final RelOptCluster cluster = join.getCluster();
  final RexBuilder rexBuilder = cluster.getRexBuilder();
  if (project != null) {
    final ImmutableBitSet bits =
        RelOptUtil.InputFinder.bits(project.getProjects(), null);
    final ImmutableBitSet rightBits =
        ImmutableBitSet.range(left.getRowType().getFieldCount(),
            join.getRowType().getFieldCount());
    if (bits.intersects(rightBits)) {
      return;
    }
  }
  final JoinInfo joinInfo = join.analyzeCondition();
  if (!joinInfo.rightSet().equals(
      ImmutableBitSet.range(aggregate.getGroupCount()))) {
    // Rule requires that aggregate key to be the same as the join key.
    // By the way, neither a super-set nor a sub-set would work.
    return;
  }
  if (!joinInfo.isEqui()) {
    return;
  }
  final RelBuilder relBuilder = call.builder();
  relBuilder.push(left);
  switch (join.getJoinType()) {
  case INNER:
    final List<Integer> newRightKeyBuilder = Lists.newArrayList();
    final List<Integer> aggregateKeys = aggregate.getGroupSet().asList();
    for (int key : joinInfo.rightKeys) {
      newRightKeyBuilder.add(aggregateKeys.get(key));
    }
    final ImmutableIntList newRightKeys = ImmutableIntList.copyOf(newRightKeyBuilder);
    relBuilder.push(aggregate.getInput());
    final RexNode newCondition =
        RelOptUtil.createEquiJoinCondition(relBuilder.peek(2, 0),
            joinInfo.leftKeys, relBuilder.peek(2, 1), newRightKeys,
            rexBuilder);
    relBuilder.semiJoin(newCondition);
    break;

  case LEFT:
    // The right-hand side produces no more than 1 row (because of the
    // Aggregate) and no fewer than 1 row (because of LEFT), and therefore
    // we can eliminate the semi-join.
    break;

  default:
    throw new AssertionError(join.getJoinType());
  }
  if (project != null) {
    relBuilder.project(project.getProjects(), project.getRowType().getFieldNames());
  }
  call.transformTo(relBuilder.build());
}
 
开发者ID:apache,项目名称:calcite,代码行数:57,代码来源:SemiJoinRule.java


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