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


Java RexUtil.composeConjunction方法代码示例

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


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

示例1: convert

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
public static DrillJoinRel convert(Join join, ConversionContext context) throws InvalidRelException{
  RelNode left = context.toRel(join.getLeft());
  RelNode right = context.toRel(join.getRight());

  List<RexNode> joinConditions = new ArrayList<RexNode>();
  // right fields appear after the LHS fields.
  final int rightInputOffset = left.getRowType().getFieldCount();
  for (JoinCondition condition : join.getConditions()) {
    RelDataTypeField leftField = left.getRowType().getField(ExprHelper.getFieldName(condition.getLeft()), true, false);
    RelDataTypeField rightField = right.getRowType().getField(ExprHelper.getFieldName(condition.getRight()), true, false);
      joinConditions.add(
          context.getRexBuilder().makeCall(
              SqlStdOperatorTable.EQUALS,
              context.getRexBuilder().makeInputRef(leftField.getType(), leftField.getIndex()),
              context.getRexBuilder().makeInputRef(rightField.getType(), rightInputOffset + rightField.getIndex())
              )
              );
  }
  RexNode rexCondition = RexUtil.composeConjunction(context.getRexBuilder(), joinConditions, false);
  DrillJoinRel joinRel = new DrillJoinRel(context.getCluster(), context.getLogicalTraits(), left, right, rexCondition, join.getJoinType());

  return joinRel;
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:24,代码来源:DrillJoinRel.java

示例2: buildJoinCondition

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
private RexNode buildJoinCondition(RelNode convertedLeft, RelNode convertedRight, List<Integer> leftKeys,
    List<Integer> rightKeys, List<Boolean> filterNulls, RexBuilder builder) {
  List<RexNode> equijoinList = Lists.newArrayList();
  final int numLeftFields = convertedLeft.getRowType().getFieldCount();
  List<RelDataTypeField> leftTypes = convertedLeft.getRowType().getFieldList();
  List<RelDataTypeField> rightTypes = convertedRight.getRowType().getFieldList();

  for (int i=0; i < leftKeys.size(); i++) {
    int leftKeyOrdinal = leftKeys.get(i).intValue();
    int rightKeyOrdinal = rightKeys.get(i).intValue();

    equijoinList.add(builder.makeCall(
        filterNulls.get(i) ? SqlStdOperatorTable.EQUALS : SqlStdOperatorTable.IS_NOT_DISTINCT_FROM,
        builder.makeInputRef(leftTypes.get(leftKeyOrdinal).getType(), leftKeyOrdinal),
        builder.makeInputRef(rightTypes.get(rightKeyOrdinal).getType(), rightKeyOrdinal + numLeftFields)
    ));
  }
  return RexUtil.composeConjunction(builder, equijoinList, false);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:20,代码来源:JoinRule.java

示例3: convert

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
public static JoinRel convert(Join join, ConversionContext context) throws InvalidRelException{
  RelNode left = context.toRel(join.getLeft());
  RelNode right = context.toRel(join.getRight());

  List<RexNode> joinConditions = new ArrayList<RexNode>();
  // right fields appear after the LHS fields.
  final int rightInputOffset = left.getRowType().getFieldCount();
  for (JoinCondition condition : join.getConditions()) {
    RelDataTypeField leftField = left.getRowType().getField(ExprHelper.getFieldName(condition.getLeft()), true, false);
    RelDataTypeField rightField = right.getRowType().getField(ExprHelper.getFieldName(condition.getRight()), true, false);
      joinConditions.add(
          context.getRexBuilder().makeCall(
              SqlStdOperatorTable.EQUALS,
              context.getRexBuilder().makeInputRef(leftField.getType(), leftField.getIndex()),
              context.getRexBuilder().makeInputRef(rightField.getType(), rightInputOffset + rightField.getIndex())
              )
              );
  }
  RexNode rexCondition = RexUtil.composeConjunction(context.getRexBuilder(), joinConditions, false);
  JoinRel joinRel = new JoinRel(context.getCluster(), context.getLogicalTraits(), left, right, rexCondition, join.getJoinType());

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

示例4: convertUsing

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
/**
 * Returns an expression for matching columns of a USING clause or inferred
 * from NATURAL JOIN. "a JOIN b USING (x, y)" becomes "a.x = b.x AND a.y =
 * b.y". Returns null if the column list is empty.
 *
 * @param leftNamespace Namespace of left input to join
 * @param rightNamespace Namespace of right input to join
 * @param nameList List of column names to join on
 * @return Expression to match columns from name list, or true if name list
 * is empty
 */
private RexNode convertUsing(SqlValidatorNamespace leftNamespace,
	SqlValidatorNamespace rightNamespace,
	List<String> nameList) {
	final SqlNameMatcher nameMatcher = catalogReader.nameMatcher();
	final List<RexNode> list = Lists.newArrayList();
	for (String name : nameList) {
		List<RexNode> operands = new ArrayList<>();
		int offset = 0;
		for (SqlValidatorNamespace n : ImmutableList.of(leftNamespace,
			rightNamespace)) {
			final RelDataType rowType = n.getRowType();
			final RelDataTypeField field = nameMatcher.field(rowType, name);
			operands.add(
				rexBuilder.makeInputRef(field.getType(),
					offset + field.getIndex()));
			offset += rowType.getFieldList().size();
		}
		list.add(rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, operands));
	}
	return RexUtil.composeConjunction(rexBuilder, list, false);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:33,代码来源:SqlToRelConverter.java

示例5: buildJoinCondition

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
private RexNode buildJoinCondition(RelNode convertedLeft, RelNode convertedRight, List<Integer> leftKeys,
    List<Integer> rightKeys, List<Boolean> filterNulls, RexBuilder builder) {
  List<RexNode> equijoinList = Lists.newArrayList();
  final int numLeftFields = convertedLeft.getRowType().getFieldCount();
  List<RelDataTypeField> leftTypes = convertedLeft.getRowType().getFieldList();
  List<RelDataTypeField> rightTypes = convertedRight.getRowType().getFieldList();

  for (int i=0; i < leftKeys.size(); i++) {
    int leftKeyOrdinal = leftKeys.get(i).intValue();
    int rightKeyOrdinal = rightKeys.get(i).intValue();

    equijoinList.add(builder.makeCall(
         filterNulls.get(i) ? SqlStdOperatorTable.EQUALS : SqlStdOperatorTable.IS_NOT_DISTINCT_FROM,
         builder.makeInputRef(leftTypes.get(leftKeyOrdinal).getType(), leftKeyOrdinal),
         builder.makeInputRef(rightTypes.get(rightKeyOrdinal).getType(), rightKeyOrdinal + numLeftFields)
    ));
  }
  return RexUtil.composeConjunction(builder, equijoinList, false);
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:20,代码来源:DrillJoinRule.java

示例6: convertUsing

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
/**
 * Returns an expression for matching columns of a USING clause or inferred
 * from NATURAL JOIN. "a JOIN b USING (x, y)" becomes "a.x = b.x AND a.y =
 * b.y". Returns null if the column list is empty.
 *
 * @param leftNamespace Namespace of left input to join
 * @param rightNamespace Namespace of right input to join
 * @param nameList List of column names to join on
 * @return Expression to match columns from name list, or true if name list
 * is empty
 */
private RexNode convertUsing(SqlValidatorNamespace leftNamespace,
                             SqlValidatorNamespace rightNamespace,
                             List<String> nameList) {
  final SqlNameMatcher nameMatcher = catalogReader.nameMatcher();
  final List<RexNode> list = Lists.newArrayList();
  for (String name : nameList) {
    List<RexNode> operands = new ArrayList<>();
    int offset = 0;
    for (SqlValidatorNamespace n : ImmutableList.of(leftNamespace,
        rightNamespace)) {
      final RelDataType rowType = n.getRowType();
      final RelDataTypeField field = nameMatcher.field(rowType, name);
      operands.add(
          rexBuilder.makeInputRef(field.getType(),
              offset + field.getIndex()));
      offset += rowType.getFieldList().size();
    }
    list.add(rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, operands));
  }
  return RexUtil.composeConjunction(rexBuilder, list, false);
}
 
开发者ID:apache,项目名称:kylin,代码行数:33,代码来源:SqlToRelConverter.java

示例7: unionPreds

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
/**
 * AND's two predicates together, either of which may be null, removing
 * redundant filters.
 *
 * @param rexBuilder rexBuilder used to construct AND'd RexNode
 * @param pred1      first predicate
 * @param pred2      second predicate
 * @return AND'd predicate or individual predicates if one is null
 */
public static RexNode unionPreds(
    RexBuilder rexBuilder,
    RexNode pred1,
    RexNode pred2) {
  final List<RexNode> unionList = new ArrayList<>();
  final Set<String> strings = new HashSet<>();

  for (RexNode rex : RelOptUtil.conjunctions(pred1)) {
    if (strings.add(rex.toString())) {
      unionList.add(rex);
    }
  }
  for (RexNode rex2 : RelOptUtil.conjunctions(pred2)) {
    if (strings.add(rex2.toString())) {
      unionList.add(rex2);
    }
  }

  return RexUtil.composeConjunction(rexBuilder, unionList, true);
}
 
开发者ID:apache,项目名称:calcite,代码行数:30,代码来源:RelMdUtil.java

示例8: minusPreds

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
/**
 * Takes the difference between two predicates, removing from the first any
 * predicates also in the second
 *
 * @param rexBuilder rexBuilder used to construct AND'd RexNode
 * @param pred1      first predicate
 * @param pred2      second predicate
 * @return MINUS'd predicate list
 */
public static RexNode minusPreds(
    RexBuilder rexBuilder,
    RexNode pred1,
    RexNode pred2) {
  final List<RexNode> list1 = RelOptUtil.conjunctions(pred1);
  final List<RexNode> list2 = RelOptUtil.conjunctions(pred2);
  final List<RexNode> minusList = new ArrayList<>();

  for (RexNode rex1 : list1) {
    boolean add = true;
    for (RexNode rex2 : list2) {
      if (rex2.toString().compareTo(rex1.toString()) == 0) {
        add = false;
        break;
      }
    }
    if (add) {
      minusList.add(rex1);
    }
  }

  return RexUtil.composeConjunction(rexBuilder, minusList, true);
}
 
开发者ID:apache,项目名称:calcite,代码行数:33,代码来源:RelMdUtil.java

示例9: getSelectivity

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
public Double getSelectivity(Aggregate rel, RelMetadataQuery mq,
    RexNode predicate) {
  final List<RexNode> notPushable = new ArrayList<>();
  final List<RexNode> pushable = new ArrayList<>();
  RelOptUtil.splitFilters(
      rel.getGroupSet(),
      predicate,
      pushable,
      notPushable);
  final RexBuilder rexBuilder = rel.getCluster().getRexBuilder();
  RexNode childPred =
      RexUtil.composeConjunction(rexBuilder, pushable, true);

  Double selectivity = mq.getSelectivity(rel.getInput(), childPred);
  if (selectivity == null) {
    return null;
  } else {
    RexNode pred =
        RexUtil.composeConjunction(rexBuilder, notPushable, true);
    return selectivity * RelMdUtil.guessSelectivity(pred);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:23,代码来源:RelMdSelectivity.java

示例10: getPredicates

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

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

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

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

示例11: convertUsing

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
/**
 * Returns an expression for matching columns of a USING clause or inferred
 * from NATURAL JOIN. "a JOIN b USING (x, y)" becomes "a.x = b.x AND a.y =
 * b.y". Returns null if the column list is empty.
 *
 * @param leftNamespace Namespace of left input to join
 * @param rightNamespace Namespace of right input to join
 * @param nameList List of column names to join on
 * @return Expression to match columns from name list, or true if name list
 * is empty
 */
private RexNode convertUsing(SqlValidatorNamespace leftNamespace,
    SqlValidatorNamespace rightNamespace,
    List<String> nameList) {
  final SqlNameMatcher nameMatcher = catalogReader.nameMatcher();
  final List<RexNode> list = Lists.newArrayList();
  for (String name : nameList) {
    List<RexNode> operands = new ArrayList<>();
    int offset = 0;
    for (SqlValidatorNamespace n : ImmutableList.of(leftNamespace,
        rightNamespace)) {
      final RelDataType rowType = n.getRowType();
      final RelDataTypeField field = nameMatcher.field(rowType, name);
      operands.add(
          rexBuilder.makeInputRef(field.getType(),
              offset + field.getIndex()));
      offset += rowType.getFieldList().size();
    }
    list.add(rexBuilder.makeCall(SqlStdOperatorTable.EQUALS, operands));
  }
  return RexUtil.composeConjunction(rexBuilder, list, false);
}
 
开发者ID:apache,项目名称:calcite,代码行数:33,代码来源:SqlToRelConverter.java

示例12: singleton

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 *
 * <p>{@code COUNT(*)}, and {@code COUNT} applied to all NOT NULL arguments,
 * become {@code 1}; otherwise
 * {@code CASE WHEN arg0 IS NOT NULL THEN 1 ELSE 0 END}.
 */
public RexNode singleton(RexBuilder rexBuilder, RelDataType inputRowType,
    AggregateCall aggregateCall) {
  final List<RexNode> predicates = new ArrayList<>();
  for (Integer arg : aggregateCall.getArgList()) {
    final RelDataType type = inputRowType.getFieldList().get(arg).getType();
    if (type.isNullable()) {
      predicates.add(
          rexBuilder.makeCall(SqlStdOperatorTable.IS_NOT_NULL,
              rexBuilder.makeInputRef(type, arg)));
    }
  }
  final RexNode predicate =
      RexUtil.composeConjunction(rexBuilder, predicates, true);
  if (predicate == null) {
    return rexBuilder.makeExactLiteral(BigDecimal.ONE);
  } else {
    return rexBuilder.makeCall(SqlStdOperatorTable.CASE, predicate,
        rexBuilder.makeExactLiteral(BigDecimal.ONE),
        rexBuilder.makeExactLiteral(BigDecimal.ZERO));
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:29,代码来源:SqlSplittableAggFunction.java

示例13: splitJoinCondition

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
/**
 * Splits out the equi-join (and optionally, a single non-equi) components
 * of a join condition, and returns what's left. Projection might be
 * required by the caller to provide join keys that are not direct field
 * references.
 *
 * @param sysFieldList  list of system fields
 * @param inputs        join inputs
 * @param condition     join condition
 * @param joinKeys      The join keys from the inputs which are equi-join
 *                      keys
 * @param filterNulls   The join key positions for which null values will not
 *                      match. null values only match for the "is not distinct
 *                      from" condition.
 * @param rangeOp       if null, only locate equi-joins; otherwise, locate a
 *                      single non-equi join predicate and return its operator
 *                      in this list; join keys associated with the non-equi
 *                      join predicate are at the end of the key lists
 *                      returned
 * @return What's left, never null
 */
public static RexNode splitJoinCondition(
    List<RelDataTypeField> sysFieldList,
    List<RelNode> inputs,
    RexNode condition,
    List<List<RexNode>> joinKeys,
    List<Integer> filterNulls,
    List<SqlOperator> rangeOp) {
  final List<RexNode> nonEquiList = new ArrayList<>();

  splitJoinCondition(
      sysFieldList,
      inputs,
      condition,
      joinKeys,
      filterNulls,
      rangeOp,
      nonEquiList);

  // Convert the remainders into a list that are AND'ed together.
  return RexUtil.composeConjunction(
      inputs.get(0).getCluster().getRexBuilder(), nonEquiList, false);
}
 
开发者ID:apache,项目名称:calcite,代码行数:44,代码来源:RelOptUtil.java

示例14: splitCorrelatedFilterCondition

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
@Deprecated // to be removed before 2.0
public static RexNode splitCorrelatedFilterCondition(
    LogicalFilter filter,
    List<RexInputRef> joinKeys,
    List<RexNode> correlatedJoinKeys) {
  final List<RexNode> nonEquiList = new ArrayList<>();

  splitCorrelatedFilterCondition(
      filter,
      filter.getCondition(),
      joinKeys,
      correlatedJoinKeys,
      nonEquiList);

  // Convert the remainders into a list that are AND'ed together.
  return RexUtil.composeConjunction(
      filter.getCluster().getRexBuilder(), nonEquiList, true);
}
 
开发者ID:apache,项目名称:calcite,代码行数:19,代码来源:RelOptUtil.java

示例15: createEquiJoinCondition

import org.apache.calcite.rex.RexUtil; //导入方法依赖的package包/类
/** Builds an equi-join condition from a set of left and right keys. */
public static RexNode createEquiJoinCondition(
    final RelNode left, final List<Integer> leftKeys,
    final RelNode right, final List<Integer> rightKeys,
    final RexBuilder rexBuilder) {
  final List<RelDataType> leftTypes =
      RelOptUtil.getFieldTypeList(left.getRowType());
  final List<RelDataType> rightTypes =
      RelOptUtil.getFieldTypeList(right.getRowType());
  return RexUtil.composeConjunction(rexBuilder,
      new AbstractList<RexNode>() {
        @Override public RexNode get(int index) {
          final int leftKey = leftKeys.get(index);
          final int rightKey = rightKeys.get(index);
          return rexBuilder.makeCall(SqlStdOperatorTable.EQUALS,
              rexBuilder.makeInputRef(leftTypes.get(leftKey), leftKey),
              rexBuilder.makeInputRef(rightTypes.get(rightKey),
                  leftTypes.size() + rightKey));
        }

        @Override public int size() {
          return leftKeys.size();
        }
      },
      false);
}
 
开发者ID:apache,项目名称:calcite,代码行数:27,代码来源:RelOptUtil.java


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