public static void collect(RexNode node, RexNode seek, Logic logic, List<Logic> logicList) { node.accept(new LogicVisitor(seek, logicList), logic); // Convert FALSE (which can only exist within LogicVisitor) to // UNKNOWN_AS_TRUE. Collections.replaceAll(logicList, Logic.FALSE, Logic.UNKNOWN_AS_TRUE); }
/** Finds a suitable logic for evaluating {@code seek} within a list of * expressions. * * <p>Chooses a logic that is safe (that is, gives the right * answer) with the fewest possibilities (that is, we prefer one that * returns [true as true, false as false, unknown as false] over one that * distinguishes false from unknown). */ public static Logic find(Logic logic, List<RexNode> nodes, RexNode seek) { final Set<Logic> set = EnumSet.noneOf(Logic.class); final LogicVisitor visitor = new LogicVisitor(seek, set); for (RexNode node : nodes) { node.accept(visitor, logic); } // Convert FALSE (which can only exist within LogicVisitor) to // UNKNOWN_AS_TRUE. if (set.remove(Logic.FALSE)) { set.add(Logic.UNKNOWN_AS_TRUE); } switch (set.size()) { case 0: throw new IllegalArgumentException("not found: " + seek); case 1: return Iterables.getOnlyElement(set); default: return Logic.TRUE_FALSE_UNKNOWN; } }
/** Finds a suitable logic for evaluating {@code seek} within a list of * expressions. * * <p>Chooses a logic that is safe (that is, gives the right * answer) with the fewest possibilities (that is, we prefer one that * returns [true as true, false as false, unknown as false] over one that * distinguishes false from unknown). */ public static Logic find(Logic logic, List<RexNode> nodes, RexNode seek) { final Set<Logic> set = EnumSet.noneOf(Logic.class); final LogicVisitor visitor = new LogicVisitor(seek, set); for (RexNode node : nodes) { node.accept(visitor, logic); } // Convert FALSE (which can only exist within LogicVisitor) to // UNKNOWN_AS_TRUE. if (set.remove(Logic.FALSE)) { set.add(Logic.UNKNOWN_AS_TRUE); } switch (set.size()) { case 0: throw new IllegalArgumentException("not found: " + seek); case 1: return Iterables.getOnlyElement(set); default: return Logic.TRUE_FALSE_UNKNOWN; } }
public static void collect(RexNode node, RexNode seek, Logic logic, List<Logic> logicList) { node.accept(new LogicVisitor(seek, logicList), logic); // Convert FALSE (which can only exist within LogicVisitor) to // UNKNOWN_AS_TRUE. Collections.replaceAll(logicList, Logic.FALSE, Logic.UNKNOWN_AS_TRUE); }