variables.add(Scoping.Variable.START); else if (startStep instanceof WherePredicateStep) { if (((WherePredicateStep) startStep).getStartKey().isPresent()) variables.add(Scoping.Variable.START); } else if (startStep instanceof WhereTraversalStep.WhereStartStep) { if (((WherePredicateStep) endStep).getStartKey().isPresent()) variables.add(Scoping.Variable.END); } else if (endStep instanceof WhereTraversalStep.WhereEndStep) {
public WherePredicateStep(final Traversal.Admin traversal, final Optional<String> startKey, final P<String> predicate) { super(traversal); this.startKey = startKey.orElse(null); if (null != this.startKey) this.scopeKeys.add(this.startKey); this.predicate = (P) predicate; this.selectKeys = new ArrayList<>(); this.configurePredicates(this.predicate); }
else if (step instanceof HasStep) rank = 2; else if (step instanceof WherePredicateStep && ((WherePredicateStep) step).getLocalChildren().isEmpty()) rank = 3; else if (step instanceof TraversalFilterStep || step instanceof NotStep)
private void setPredicateValues(final P<Object> predicate, final Traverser.Admin<S> traverser, final Iterator<String> selectKeysIterator) { if (predicate instanceof ConnectiveP) ((ConnectiveP<Object>) predicate).getPredicates().forEach(p -> this.setPredicateValues(p, traverser, selectKeysIterator)); else predicate.setValue(TraversalUtil.applyNullable((S) this.getScopeValue(Pop.last, selectKeysIterator.next(), traverser), this.traversalRing.next())); }
WherePredicateStep<?> wps=(WherePredicateStep<?>)step; if (wps.getPredicate().isPresent() && wps.getPredicate().get().getBiPredicate() instanceof FullText){ Object referTo=previous; if (wps.getStartKey().isPresent()){ referTo=stepsByLabel.get(wps.getStartKey().get()); rs.addHasContainer(new HasContainer("__dummy__", wps.getPredicate().get())); traversal.removeStep(idx);
} else if (startStep instanceof WherePredicateStep) { // necessary for GraphComputer so the projection is not select'd from a path final WherePredicateStep<?> whereStep = (WherePredicateStep<?>) startStep; TraversalHelper.insertBeforeStep(new MatchStartStep(matchTraversal, whereStep.getStartKey().orElse(null)), (Step) whereStep, matchTraversal); // where('a',eq('b')) --> as('a').where(eq('b')) whereStep.removeStartKey(); } else { throw new IllegalArgumentException("All match()-traversals must have a single start label (i.e. variable): " + matchTraversal);
private Optional<String> labelFromWhereEqPredicate(WherePredicateStep<Vertex> whereStep) { Optional<P<?>> optionalPredicate = whereStep.getPredicate(); return optionalPredicate.flatMap(predicate -> { if (!predicate.getBiPredicate().equals(Compare.eq)) return Optional.empty(); return Optional.of((String) predicate.getValue()); }); }
/** * Filters the current object based on the object itself or the path history. * * @param predicate the filter to apply * @return the traversal with an appended {@link WherePredicateStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#where-step" target="_blank">Reference Documentation - Where Step</a> * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#using-where-with-match" target="_blank">Reference Documentation - Where with Match</a> * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#using-where-with-select" target="_blank">Reference Documentation - Where with Select</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, E> where(final P<String> predicate) { this.asAdmin().getBytecode().addStep(Symbols.where, predicate); return this.asAdmin().addStep(new WherePredicateStep<>(this.asAdmin(), Optional.empty(), predicate)); }
@Override public void modulateBy(final Traversal.Admin<?, ?> traversal) throws UnsupportedOperationException { this.traversalRing.addTraversal(this.integrateChild(traversal)); } }
@Override public Set<TraverserRequirement> getRequirements() { return this.getSelfAndChildRequirements(TraverserRequirement.OBJECT, TraverserRequirement.SIDE_EFFECTS); }
WherePredicateStep<?> wps=(WherePredicateStep<?>)step; if (wps.getPredicate().isPresent() && wps.getPredicate().get().getBiPredicate() instanceof FullText){ Object referTo=previous; if (wps.getStartKey().isPresent()){ referTo=stepsByLabel.get(wps.getStartKey().get()); rs.addHasContainer(new HasContainer("__dummy__", wps.getPredicate().get())); traversal.removeStep(idx);
} else if (startStep instanceof WherePredicateStep) { // necessary for GraphComputer so the projection is not select'd from a path final WherePredicateStep<?> whereStep = (WherePredicateStep<?>) startStep; TraversalHelper.insertBeforeStep(new MatchStartStep(matchTraversal, whereStep.getStartKey().orElse(null)), (Step) whereStep, matchTraversal); // where('a',eq('b')) --> as('a').where(eq('b')) whereStep.removeStartKey(); } else { throw new IllegalArgumentException("All match()-traversals must have a single start label (i.e. variable): " + matchTraversal);
propertyFetchers.forEach(PropertyFetcher::fetchAllKeys); else { String possibleLabel = ((P) wherePredicateStep.getPredicate().get()).getValue().toString(); traversal.getSteps().forEach(step -> { if (step.getLabels().contains(possibleLabel)){
@Override protected boolean filter(final Traverser.Admin<S> traverser) { final Object value = null == this.startKey ? TraversalUtil.applyNullable(traverser, this.traversalRing.next()) : TraversalUtil.applyNullable((S) this.getScopeValue(Pop.last, this.startKey, traverser), this.traversalRing.next()); this.setPredicateValues(this.predicate, traverser, this.selectKeys.iterator()); this.traversalRing.reset(); return this.predicate.test(value); }
/** * Filters the current object based on the object itself or the path history. * * @param startKey the key containing the object to filter * @param predicate the filter to apply * @return the traversal with an appended {@link WherePredicateStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#where-step" target="_blank">Reference Documentation - Where Step</a> * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#using-where-with-match" target="_blank">Reference Documentation - Where with Match</a> * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#using-where-with-select" target="_blank">Reference Documentation - Where with Select</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, E> where(final String startKey, final P<String> predicate) { this.asAdmin().getBytecode().addStep(Symbols.where, startKey, predicate); return this.asAdmin().addStep(new WherePredicateStep<>(this.asAdmin(), Optional.ofNullable(startKey), predicate)); }
@Override public void modulateBy(final Traversal.Admin<?, ?> traversal) throws UnsupportedOperationException { this.traversalRing.addTraversal(this.integrateChild(traversal)); } }
@Override public Set<TraverserRequirement> getRequirements() { return this.getSelfAndChildRequirements(TraverserRequirement.OBJECT, TraverserRequirement.SIDE_EFFECTS); }
private void setPredicateValues(final P<Object> predicate, final Traverser.Admin<S> traverser, final Iterator<String> selectKeysIterator) { if (predicate instanceof ConnectiveP) ((ConnectiveP<Object>) predicate).getPredicates().forEach(p -> this.setPredicateValues(p, traverser, selectKeysIterator)); else predicate.setValue(TraversalUtil.applyNullable((S) this.getScopeValue(Pop.last, selectKeysIterator.next(), traverser), this.traversalRing.next())); }
variables.add(Scoping.Variable.START); else if (startStep instanceof WherePredicateStep) { if (((WherePredicateStep) startStep).getStartKey().isPresent()) variables.add(Scoping.Variable.START); } else if (startStep instanceof WhereTraversalStep.WhereStartStep) { if (((WherePredicateStep) endStep).getStartKey().isPresent()) variables.add(Scoping.Variable.END); } else if (endStep instanceof WhereTraversalStep.WhereEndStep) {
/** * Filters the current object based on the object itself or the path history. * * @param predicate the filter to apply * @return the traversal with an appended {@link WherePredicateStep} * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#where-step" target="_blank">Reference Documentation - Where Step</a> * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#using-where-with-match" target="_blank">Reference Documentation - Where with Match</a> * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#using-where-with-select" target="_blank">Reference Documentation - Where with Select</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, E> where(final P<String> predicate) { this.asAdmin().getBytecode().addStep(Symbols.where, predicate); return this.asAdmin().addStep(new WherePredicateStep<>(this.asAdmin(), Optional.empty(), predicate)); }