@Override public P<V> or(final Predicate<? super V> predicate) { if (!(predicate instanceof P)) throw new IllegalArgumentException("Only P predicates can be or'd together"); else if (predicate instanceof OrP) this.predicates.addAll(((OrP) predicate).getPredicates()); else this.predicates.add((P<V>) predicate); return this; }
public static Condition convOr(HugeGraph graph, HugeType type, HasContainer has) { P<?> p = has.getPredicate(); assert p instanceof OrP; @SuppressWarnings("unchecked") List<P<Object>> predicates = ((OrP<Object>) p).getPredicates(); if (predicates.size() < 2) { throw newUnsupportedPredicate(p); } Condition cond = null; for (P<Object> predicate : predicates) { HasContainer newHas = new HasContainer(has.getKey(), predicate); Condition newCond = convHas2Condition(newHas, type, graph); if (cond == null) { cond = newCond; } else { cond = Condition.or(newCond, cond); } } return cond; }
} else if (hasContainer.getPredicate() instanceof OrP && edgeLabels.isEmpty()) { boolean removeContainer = true; final List<P<?>> orps = ((OrP) hasContainer.getPredicate()).getPredicates(); final List<String> newEdges = new ArrayList<>(); for (int i = 0; i < orps.size(); i++) {
@Override public P<V> or(final Predicate<? super V> predicate) { if (!(predicate instanceof P)) throw new IllegalArgumentException("Only P predicates can be or'd together"); else if (predicate instanceof OrP) this.predicates.addAll(((OrP) predicate).getPredicates()); else this.predicates.add((P<V>) predicate); return this; }
private List<HasContainer> optimizeOutside(ReplacedStep<?, ?> replacedStep, List<HasContainer> hasContainers) { List<HasContainer> result = new ArrayList<>(); for (HasContainer hasContainer : hasContainers) { if (hasContainerKeyNotIdOrLabel(hasContainer) && hasContainer.getPredicate() instanceof OrP) { OrP<?> orP = (OrP) hasContainer.getPredicate(); List<? extends P<?>> predicates = orP.getPredicates(); if (predicates.size() == 2) { if (predicates.get(0).getBiPredicate() == Compare.lt && predicates.get(1).getBiPredicate() == Compare.gt) { replacedStep.addHasContainer(hasContainer); result.add(hasContainer); } } } } return result; }
private List<HasContainer> optimizeOutside(ReplacedStep<?, ?> replacedStep, List<HasContainer> hasContainers) { List<HasContainer> result = new ArrayList<>(); for (HasContainer hasContainer : hasContainers) { if (hasContainerKeyNotIdOrLabel(hasContainer) && hasContainer.getPredicate() instanceof OrP) { OrP<?> orP = (OrP) hasContainer.getPredicate(); List<? extends P<?>> predicates = orP.getPredicates(); if (predicates.size() == 2) { if (predicates.get(0).getBiPredicate() == Compare.lt && predicates.get(1).getBiPredicate() == Compare.gt) { replacedStep.addHasContainer(hasContainer); result.add(hasContainer); } } } } return result; }
public static Condition convOr(HugeGraph graph, HugeType type, HasContainer has) { P<?> p = has.getPredicate(); assert p instanceof OrP; @SuppressWarnings("unchecked") List<P<Object>> predicates = ((OrP<Object>) p).getPredicates(); if (predicates.size() < 2) { throw newUnsupportedPredicate(p); } Condition cond = null; for (P<Object> predicate : predicates) { HasContainer newHas = new HasContainer(has.getKey(), predicate); Condition newCond = convHas2Condition(newHas, type, graph); if (cond == null) { cond = newCond; } else { cond = Condition.or(newCond, cond); } } return cond; }
public void putKeyValueMap(HasContainer hasContainer, Multimap<String, Object> keyValueMap, SchemaTableTree schemaTableTree) { if (p instanceof OrP) { OrP<?> orP = (OrP<?>) p; Preconditions.checkState(orP.getPredicates().size() == 2, "Only handling OrP with 2 predicates!"); P<?> p1 = orP.getPredicates().get(0); P<?> p2 = orP.getPredicates().get(1); keyValueMap.put(hasContainer.getKey(), p1.getValue()); keyValueMap.put(hasContainer.getKey(), p2.getValue());
} else if (hasContainer.getPredicate() instanceof OrP && edgeLabels.isEmpty()) { boolean removeContainer = true; final List<P<?>> orps = ((OrP) hasContainer.getPredicate()).getPredicates(); final List<String> newEdges = new ArrayList<>(); for (int i = 0; i < orps.size(); i++) {
public void putKeyValueMap(HasContainer hasContainer, Multimap<String, Object> keyValueMap, SchemaTableTree schemaTableTree) { if (p instanceof OrP) { OrP<?> orP = (OrP<?>) p; Preconditions.checkState(orP.getPredicates().size() == 2, "Only handling OrP with 2 predicates!"); P<?> p1 = orP.getPredicates().get(0); P<?> p2 = orP.getPredicates().get(1); keyValueMap.put(hasContainer.getKey(), p1.getValue()); keyValueMap.put(hasContainer.getKey(), p2.getValue());
List<? extends P<?>> predicates = orP.getPredicates(); if (predicates.size() == 2) { if (predicates.get(0).getBiPredicate() == Compare.lt && predicates.get(1).getBiPredicate() == Compare.gt) {
List<? extends P<?>> predicates = orP.getPredicates(); if (predicates.size() == 2) { if (predicates.get(0).getBiPredicate() == Compare.lt && predicates.get(1).getBiPredicate() == Compare.gt) {
} else if (p instanceof OrP) { OrP<?> orP = (OrP<?>) p; Preconditions.checkState(orP.getPredicates().size() == 2, "Only handling OrP with 2 predicates!"); P<?> p1 = orP.getPredicates().get(0); String key; if (hasContainer.getKey().equals(T.id.getAccessor())) { P<?> p2 = orP.getPredicates().get(1); result += " or " + prefix + key + compareToSql((Compare) p2.getBiPredicate()); return result;
} else if (p instanceof OrP) { OrP<?> orP = (OrP<?>) p; Preconditions.checkState(orP.getPredicates().size() == 2, "Only handling OrP with 2 predicates!"); P<?> p1 = orP.getPredicates().get(0); String key; if (hasContainer.getKey().equals(T.id.getAccessor())) { P<?> p2 = orP.getPredicates().get(1); result += " or " + prefix + key + compareToSql((Compare) p2.getBiPredicate()); return result;