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


Java Join类代码示例

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


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

示例1: apply

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
public boolean apply(Join join, JoinRelType joinType, RexNode exp) {
  if (joinType != JoinRelType.INNER) {
    return true;  // In OUTER join, we could not pull-up the filter.
                  // All we can do is keep the filter with JOIN, and
                  // then decide whether the filter could be pushed down
                  // into LEFT/RIGHT.
  }

  List<RexNode> tmpLeftKeys = Lists.newArrayList();
  List<RexNode> tmpRightKeys = Lists.newArrayList();
  List<RelDataTypeField> sysFields = Lists.newArrayList();

  RexNode remaining = RelOptUtil.splitJoinCondition(sysFields, join.getLeft(), join.getRight(), exp, tmpLeftKeys, tmpRightKeys, null, null);

  if (remaining.isAlwaysTrue()) {
    return true;
  }

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

示例2: apply

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
public boolean apply(Join join, JoinRelType joinType, RexNode exp) {
  if (joinType != JoinRelType.INNER) {
    return true;  // In OUTER join, we could not pull-up the filter.
                  // All we can do is keep the filter with JOIN, and
                  // then decide whether the filter could be pushed down
                  // into LEFT/RIGHT.
  }

  List<RexNode> tmpLeftKeys = Lists.newArrayList();
  List<RexNode> tmpRightKeys = Lists.newArrayList();
  List<RelDataTypeField> sysFields = Lists.newArrayList();
  List<Integer> filterNulls = Lists.newArrayList();

  RexNode remaining = RelOptUtil.splitJoinCondition(sysFields, join.getLeft(), join.getRight(),
      exp, tmpLeftKeys, tmpRightKeys, filterNulls, null);

  return remaining.isAlwaysTrue();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:19,代码来源:FilterJoinRulesUtil.java

示例3: apply

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
public boolean apply(Join join, JoinRelType joinType, RexNode exp) {
  if (joinType != JoinRelType.INNER) {
    return true;  // In OUTER join, we could not pull-up the filter.
                  // All we can do is keep the filter with JOIN, and
                  // then decide whether the filter could be pushed down
                  // into LEFT/RIGHT.
  }

  List<RexNode> tmpLeftKeys = Lists.newArrayList();
  List<RexNode> tmpRightKeys = Lists.newArrayList();
  List<RelDataTypeField> sysFields = Lists.newArrayList();
  List<Integer> filterNulls = Lists.newArrayList();

  RexNode remaining = RelOptUtil.splitJoinCondition(sysFields, join.getLeft(), join.getRight(), exp, tmpLeftKeys, tmpRightKeys, filterNulls, null);

  if (remaining.isAlwaysTrue()) {
    return true;
  }

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

示例4: visitJoin

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
public Result visitJoin(Join e) {
  final Result leftResult = visitChild(0, e.getLeft());
  final Result rightResult = visitChild(1, e.getRight());
  final Context leftContext = leftResult.qualifiedContext();
  final Context rightContext =
      rightResult.qualifiedContext();
  SqlNode sqlCondition = convertConditionToSqlNode(e.getCondition(),
      leftContext,
      rightContext,
      e.getLeft().getRowType().getFieldCount());
  SqlNode join =
      new SqlJoin(POS,
          leftResult.asFrom(),
          SqlLiteral.createBoolean(false, POS),
          joinType(e.getJoinType()).symbol(POS),
          rightResult.asFrom(),
          JoinConditionType.ON.symbol(POS),
          sqlCondition);
  return result(join, leftResult, rightResult);
}
 
开发者ID:qubole,项目名称:quark,代码行数:21,代码来源:RelToSqlConverter.java

示例5: onMatch

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
public void onMatch(RelOptRuleCall call) {
  final Delta delta = call.rel(0);
  Util.discard(delta);
  final Join join = call.rel(1);
  final RelNode left = join.getLeft();
  final RelNode right = join.getRight();

  final LogicalDelta rightWithDelta = LogicalDelta.create(right);
  final LogicalJoin joinL = LogicalJoin.create(left, rightWithDelta,
      join.getCondition(), join.getVariablesSet(), join.getJoinType(),
      join.isSemiJoinDone(),
      ImmutableList.copyOf(join.getSystemFieldList()));

  final LogicalDelta leftWithDelta = LogicalDelta.create(left);
  final LogicalJoin joinR = LogicalJoin.create(leftWithDelta, right,
      join.getCondition(), join.getVariablesSet(), join.getJoinType(),
      join.isSemiJoinDone(),
      ImmutableList.copyOf(join.getSystemFieldList()));

  List<RelNode> inputsToUnion = Lists.newArrayList();
  inputsToUnion.add(joinL);
  inputsToUnion.add(joinR);

  final LogicalUnion newNode = LogicalUnion.create(inputsToUnion, true);
  call.transformTo(newNode);
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:StreamRules.java

示例6: getColumnOrigins

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
public Set<RelColumnOrigin> getColumnOrigins(Join rel, RelMetadataQuery mq,
    int iOutputColumn) {
  int nLeftColumns = rel.getLeft().getRowType().getFieldList().size();
  Set<RelColumnOrigin> set;
  boolean derived = false;
  if (iOutputColumn < nLeftColumns) {
    set = mq.getColumnOrigins(rel.getLeft(), iOutputColumn);
    if (rel.getJoinType().generatesNullsOnLeft()) {
      derived = true;
    }
  } else {
    set = mq.getColumnOrigins(rel.getRight(), iOutputColumn - nLeftColumns);
    if (rel.getJoinType().generatesNullsOnRight()) {
      derived = true;
    }
  }
  if (derived) {
    // nulls are generated due to outer join; that counts
    // as derivation
    set = createDerivedColumnOrigins(set);
  }
  return set;
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:RelMdColumnOrigins.java

示例7: averageJoinColumnSizes

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
private List<Double> averageJoinColumnSizes(Join rel, RelMetadataQuery mq,
    boolean semijoin) {
  final RelNode left = rel.getLeft();
  final RelNode right = rel.getRight();
  final List<Double> lefts = mq.getAverageColumnSizes(left);
  final List<Double> rights =
      semijoin ? null : mq.getAverageColumnSizes(right);
  if (lefts == null && rights == null) {
    return null;
  }
  final int fieldCount = rel.getRowType().getFieldCount();
  Double[] sizes = new Double[fieldCount];
  if (lefts != null) {
    lefts.toArray(sizes);
  }
  if (rights != null) {
    final int leftCount = left.getRowType().getFieldCount();
    for (int i = 0; i < rights.size(); i++) {
      sizes[leftCount + i] = rights.get(i);
    }
  }
  return ImmutableNullableList.copyOf(sizes);
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:RelMdSize.java

示例8: getJoinRowCount

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
/** Returns an estimate of the number of rows returned by a {@link Join}. */
public static Double getJoinRowCount(RelMetadataQuery mq, Join join,
    RexNode condition) {
  // Row count estimates of 0 will be rounded up to 1.
  // So, use maxRowCount where the product is very small.
  final Double left = mq.getRowCount(join.getLeft());
  final Double right = mq.getRowCount(join.getRight());
  if (left == null || right == null) {
    return null;
  }
  if (left <= 1D || right <= 1D) {
    Double max = mq.getMaxRowCount(join);
    if (max != null && max <= 1D) {
      return max;
    }
  }
  double product = left * right;

  // TODO:  correlation factor
  return product * mq.getSelectivity(join, condition);
}
 
开发者ID:apache,项目名称:calcite,代码行数:22,代码来源:RelMdUtil.java

示例9: getPredicates

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
/** Infers predicates for a {@link org.apache.calcite.rel.core.Join}. */
public RelOptPredicateList getPredicates(Join join, RelMetadataQuery mq) {
  RexBuilder rB = join.getCluster().getRexBuilder();
  RelNode left = join.getInput(0);
  RelNode right = join.getInput(1);

  final RelOptPredicateList leftInfo = mq.getPulledUpPredicates(left);
  final RelOptPredicateList rightInfo = mq.getPulledUpPredicates(right);

  JoinConditionBasedPredicateInference jI =
      new JoinConditionBasedPredicateInference(join,
          RexUtil.composeConjunction(rB, leftInfo.pulledUpPredicates, false),
          RexUtil.composeConjunction(rB, rightInfo.pulledUpPredicates,
              false));

  return jI.inferPredicates(false);
}
 
开发者ID:apache,项目名称:calcite,代码行数:18,代码来源:RelMdPredicates.java

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

示例11: shiftRightFilter

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
/**
 * Shifts a filter originating from the right child of the LogicalJoin to the
 * right, to reflect the filter now being applied on the resulting
 * MultiJoin.
 *
 * @param joinRel     the original LogicalJoin
 * @param left        the left child of the LogicalJoin
 * @param right       the right child of the LogicalJoin
 * @param rightFilter the filter originating from the right child
 * @return the adjusted right filter
 */
private RexNode shiftRightFilter(
    Join joinRel,
    RelNode left,
    MultiJoin right,
    RexNode rightFilter) {
  if (rightFilter == null) {
    return null;
  }

  int nFieldsOnLeft = left.getRowType().getFieldList().size();
  int nFieldsOnRight = right.getRowType().getFieldList().size();
  int[] adjustments = new int[nFieldsOnRight];
  for (int i = 0; i < nFieldsOnRight; i++) {
    adjustments[i] = nFieldsOnLeft;
  }
  rightFilter =
      rightFilter.accept(
          new RelOptUtil.RexInputConverter(
              joinRel.getCluster().getRexBuilder(),
              right.getRowType().getFieldList(),
              joinRel.getRowType().getFieldList(),
              adjustments));
  return rightFilter;
}
 
开发者ID:apache,项目名称:calcite,代码行数:36,代码来源:JoinToMultiJoinRule.java

示例12: combinePostJoinFilters

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
/**
 * Combines the post-join filters from the left and right inputs (if they
 * are MultiJoinRels) into a single AND'd filter.
 *
 * @param joinRel the original LogicalJoin
 * @param left    left child of the LogicalJoin
 * @param right   right child of the LogicalJoin
 * @return combined post-join filters AND'd together
 */
private List<RexNode> combinePostJoinFilters(
    Join joinRel,
    RelNode left,
    RelNode right) {
  final List<RexNode> filters = Lists.newArrayList();
  if (right instanceof MultiJoin) {
    final MultiJoin multiRight = (MultiJoin) right;
    filters.add(
        shiftRightFilter(joinRel, left, multiRight,
            multiRight.getPostJoinFilter()));
  }

  if (left instanceof MultiJoin) {
    filters.add(((MultiJoin) left).getPostJoinFilter());
  }

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

示例13: onMatch

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

  // Push expression in join condition into Project below Join.
  RelNode newJoin = RelOptUtil.pushDownJoinConditions(join, call.builder());

  // If the join is the same, we bail out
  if (newJoin instanceof Join) {
    final RexNode newCondition = ((Join) newJoin).getCondition();
    if (join.getCondition().toString().equals(newCondition.toString())) {
      return;
    }
  }

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

示例14: createSwappedJoinExprs

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
/**
 * Creates projection expressions reflecting the swapping of a join's input.
 *
 * @param newJoin   the RelNode corresponding to the join with its inputs
 *                  swapped
 * @param origJoin  original LogicalJoin
 * @param origOrder if true, create the projection expressions to reflect
 *                  the original (pre-swapped) join projection; otherwise,
 *                  create the projection to reflect the order of the swapped
 *                  projection
 * @return array of expression representing the swapped join inputs
 */
public static List<RexNode> createSwappedJoinExprs(
    RelNode newJoin,
    Join origJoin,
    boolean origOrder) {
  final List<RelDataTypeField> newJoinFields =
      newJoin.getRowType().getFieldList();
  final RexBuilder rexBuilder = newJoin.getCluster().getRexBuilder();
  final List<RexNode> exps = new ArrayList<>();
  final int nFields =
      origOrder ? origJoin.getRight().getRowType().getFieldCount()
          : origJoin.getLeft().getRowType().getFieldCount();
  for (int i = 0; i < newJoinFields.size(); i++) {
    final int source = (i + nFields) % newJoinFields.size();
    RelDataTypeField field =
        origOrder ? newJoinFields.get(source) : newJoinFields.get(i);
    exps.add(rexBuilder.makeInputRef(field.getType(), source));
  }
  return exps;
}
 
开发者ID:apache,项目名称:calcite,代码行数:32,代码来源:RelOptUtil.java

示例15: testCollation

import org.apache.calcite.rel.core.Join; //导入依赖的package包/类
/** Unit test for
 * {@link org.apache.calcite.rel.metadata.RelMdCollation#project}
 * and other helper functions for deducing collations. */
@Test public void testCollation() {
  final Project rel = (Project) convertSql("select * from emp, dept");
  final Join join = (Join) rel.getInput();
  final RelOptTable empTable = join.getInput(0).getTable();
  final RelOptTable deptTable = join.getInput(1).getTable();
  Frameworks.withPlanner(
      new Frameworks.PlannerAction<Void>() {
        public Void apply(RelOptCluster cluster,
            RelOptSchema relOptSchema,
            SchemaPlus rootSchema) {
          checkCollation(cluster, empTable, deptTable);
          return null;
        }
      });
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:RelMetadataTest.java


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