Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.Path#hasLabel()
The following examples show how to use
org.apache.tinkerpop.gremlin.process.traversal.Path#hasLabel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MatchStep.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override protected Traverser.Admin<Object> processNextStart() throws NoSuchElementException { if (null == this.parent) this.parent = ((MatchStep) this.getTraversal().getParent().asStep()); while (true) { final Traverser.Admin traverser = this.starts.next(); // no end label if (null == this.matchKey) { // if (this.traverserStepIdAndLabelsSetByChild) -- traverser equality is based on stepId, lets ensure they are all at the parent traverser.setStepId(this.parent.getId()); this.parent.getMatchAlgorithm().recordEnd(traverser, this.getTraversal()); return this.retractUnnecessaryLabels(traverser); } // TODO: sideEffect check? // path check final Path path = traverser.path(); if (!path.hasLabel(this.matchKey) || traverser.get().equals(path.get(Pop.last, this.matchKey))) { // if (this.traverserStepIdAndLabelsSetByChild) -- traverser equality is based on stepId and thus, lets ensure they are all at the parent traverser.setStepId(this.parent.getId()); traverser.addLabels(this.matchKeyCollection); this.parent.getMatchAlgorithm().recordEnd(traverser, this.getTraversal()); return this.retractUnnecessaryLabels(traverser); } } }
Example 2
Source File: Scoping.java From tinkerpop with Apache License 2.0 | 6 votes |
/** * Finds the object with the specified key for the current traverser and throws an exception if the key cannot * be found. * * @throws KeyNotFoundException if the key does not exist */ public default <S> S getScopeValue(final Pop pop, final Object key, final Traverser.Admin<?> traverser) throws KeyNotFoundException { final Object object = traverser.get(); if (object instanceof Map && ((Map) object).containsKey(key)) return (S) ((Map) object).get(key); if (key instanceof String) { final String k = (String) key; if (traverser.getSideEffects().exists(k)) return traverser.getSideEffects().get(k); final Path path = traverser.path(); if (path.hasLabel(k)) return null == pop ? path.get(k) : path.get(pop, k); } throw new KeyNotFoundException(key, this); }
Example 3
Source File: ImmutablePath.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public boolean popEquals(final Pop pop, final Object other) { if (!(other instanceof Path)) return false; final Path otherPath = (Path) other; ImmutablePath currentPath = this; while (true) { if (currentPath.isTail()) break; for (final String label : currentPath.currentLabels) { if (!otherPath.hasLabel(label) || !this.get(pop, label).equals(otherPath.get(pop, label))) return false; } currentPath = currentPath.previousPath; } return true; }
Example 4
Source File: MatchStep.java From tinkerpop with Apache License 2.0 | 5 votes |
private boolean hasPathLabel(final Path path, final Set<String> labels) { for (final String label : labels) { if (path.hasLabel(label)) return true; } return false; }