private static RexNode splitOr( final RexBuilder rexBuilder, RexNode condition, RexNode target) { List<RexNode> targets = RelOptUtil.disjunctions(target); for (RexNode e : RelOptUtil.disjunctions(condition)) { boolean found = removeAll(targets, e); if (!found) { return null; } } return RexUtil.composeConjunction(rexBuilder, Lists.transform(targets, RexUtil.notFn(rexBuilder)), false); }
private static RexNode splitOr( final RexBuilder rexBuilder, RexNode condition, RexNode target) { List<RexNode> conditions = RelOptUtil.disjunctions(condition); int conditionsLength = conditions.size(); int targetsLength = 0; for (RexNode e : RelOptUtil.disjunctions(target)) { removeAll(conditions, e); targetsLength++; } if (conditions.isEmpty() && conditionsLength == targetsLength) { return rexBuilder.makeLiteral(true); } else if (conditions.isEmpty()) { return condition; } return null; }
private static RexNode splitOr( final RexBuilder rexBuilder, RexNode condition, RexNode target) { List<RexNode> conditions = RelOptUtil.disjunctions(condition); int conditionsLength = conditions.size(); int targetsLength = 0; for (RexNode e : RelOptUtil.disjunctions(target)) { removeAll(conditions, e); targetsLength++; } if (conditions.isEmpty() && conditionsLength == targetsLength) { return rexBuilder.makeLiteral(true); } else if (conditions.isEmpty()) { return condition; } return null; }
/** * Given a list of Index Expressions(usually indexed fields/functions from one or a set of indexes), * separate a filter condition into * 1), relevant subset of conditions (by relevant, it means at least one given index Expression was found) and, * 2), the rest in remainderCondition * @param relevantPaths * @param condition * @return */ public IndexConditionInfo indexConditionRelatedToFields(List<LogicalExpression> relevantPaths, RexNode condition) { // Use the same filter analyzer that is used for partitioning columns RewriteCombineBinaryOperators reverseVisitor = new RewriteCombineBinaryOperators(true, builder); condition = condition.accept(reverseVisitor); RexSeparator separator = new RexSeparator(relevantPaths, scan, builder); RexNode indexCondition = separator.getSeparatedCondition(condition); if (indexCondition == null) { return new IndexConditionInfo(null, null, false); } List<RexNode> conjuncts = RelOptUtil.conjunctions(condition); List<RexNode> indexConjuncts = RelOptUtil.conjunctions(indexCondition); for (RexNode indexConjunction: indexConjuncts) { RexUtil.removeAll(conjuncts, indexConjunction); } RexNode remainderCondition = RexUtil.composeConjunction(builder, conjuncts, false); indexCondition = indexCondition.accept(reverseVisitor); return new IndexConditionInfo(indexCondition, remainderCondition, true); }
List<RexNode> conjs = RelOptUtil.conjunctions(r); for (RexNode e : RelOptUtil.conjunctions(target2)) { removeAll(conjs, e);
List<RexNode> conjs = RelOptUtil.conjunctions(r); for (RexNode e : RelOptUtil.conjunctions(target2)) { removeAll(conjs, e);