Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor#processTraverserPathLabels()

The following examples show how to use org.apache.tinkerpop.gremlin.process.traversal.step.PathProcessor#processTraverserPathLabels() . 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: TraversalSelectStep.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
protected Traverser.Admin<E> processNextStart() {
    final Traverser.Admin<S> traverser = this.starts.next();
    final Iterator<E> keyIterator = TraversalUtil.applyAll(traverser, this.keyTraversal);
    if (keyIterator.hasNext()) {
        final E key = keyIterator.next();
        try {
            final E end = getScopeValue(pop, key, traverser);
            final Traverser.Admin<E> outTraverser = traverser.split(null == end ? null : TraversalUtil.applyNullable(end, this.selectTraversal), this);
            if (!(this.getTraversal().getParent() instanceof MatchStep)) {
                PathProcessor.processTraverserPathLabels(outTraverser, this.keepLabels);
            }
            return outTraverser;
        } catch (KeyNotFoundException nfe) {
            return EmptyTraverser.instance();
        }
    } else {
        return EmptyTraverser.instance();
    }
}
 
Example 2
Source File: SelectStep.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
protected Traverser.Admin<Map<String, E>> processNextStart() throws NoSuchElementException {
    final Traverser.Admin<S> traverser = this.starts.next();
    final Map<String, E> bindings = new LinkedHashMap<>(this.selectKeys.size(), 1.0f);
    try {
        for (final String selectKey : this.selectKeys) {
            final E end = this.getScopeValue(this.pop, selectKey, traverser);
            bindings.put(selectKey, TraversalUtil.applyNullable(end, this.traversalRing.next()));
        }
    } catch (KeyNotFoundException nfe) {
        return EmptyTraverser.instance();
    } finally {
        this.traversalRing.reset();
    }

    return PathProcessor.processTraverserPathLabels(traverser.split(bindings, this), this.keepLabels);
}
 
Example 3
Source File: MatchStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private <S> Traverser.Admin<S> retractUnnecessaryLabels(final Traverser.Admin<S> traverser) {
    if (null == this.parent.getKeepLabels())
        return traverser;

    final Set<String> keepers = new HashSet<>(this.parent.getKeepLabels());
    final Set<String> tags = traverser.getTags();
    for (final Traversal.Admin<?, ?> matchTraversal : this.parent.matchTraversals) { // get remaining traversal patterns for the traverser
        final String startStepId = matchTraversal.getStartStep().getId();
        if (!tags.contains(startStepId)) {
            keepers.addAll(this.parent.getReferencedLabelsMap().get(startStepId)); // get the reference labels required for those remaining traversals
        }
    }
    return PathProcessor.processTraverserPathLabels(traverser, keepers); // remove all reference labels that are no longer required
}
 
Example 4
Source File: SelectOneStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
protected Traverser.Admin<E> processNextStart() throws NoSuchElementException {
    final Traverser.Admin<S> traverser = this.starts.next();

    try {
        final S o = getScopeValue(pop, selectKey, traverser);
        if (null == o) return traverser.split(null, this);
        final Traverser.Admin<E> outTraverser = traverser.split(TraversalUtil.applyNullable(o, this.selectTraversal), this);
        if (!(this.getTraversal().getParent() instanceof MatchStep))
            PathProcessor.processTraverserPathLabels(outTraverser, this.keepLabels);
        return outTraverser;
    } catch (KeyNotFoundException nfe) {
        return EmptyTraverser.instance();
    }
}
 
Example 5
Source File: DedupGlobalStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
protected Traverser.Admin<S> processNextStart() {
    if (null != this.barrier) {
        this.barrierIterator = this.barrier.entrySet().iterator();
        this.barrier = null;
    }
    while (this.barrierIterator != null && this.barrierIterator.hasNext()) {
        if (null == this.barrierIterator)
            this.barrierIterator = this.barrier.entrySet().iterator();
        final Map.Entry<Object, Traverser.Admin<S>> entry = this.barrierIterator.next();
        if (this.duplicateSet.add(entry.getKey()))
            return PathProcessor.processTraverserPathLabels(entry.getValue(), this.keepLabels);
    }
    return PathProcessor.processTraverserPathLabels(super.processNextStart(), this.keepLabels);
}
 
Example 6
Source File: MathStep.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
protected Traverser.Admin<Double> processNextStart() {
    return PathProcessor.processTraverserPathLabels(super.processNextStart(), this.keepLabels);
}
 
Example 7
Source File: PathStep.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
protected Traverser.Admin<Path> processNextStart() {
    return PathProcessor.processTraverserPathLabels(super.processNextStart(), this.keepLabels);
}
 
Example 8
Source File: TreeSideEffectStep.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
protected Traverser.Admin<S> processNextStart() {
    return PathProcessor.processTraverserPathLabels(super.processNextStart(), this.keepLabels);
}
 
Example 9
Source File: WherePredicateStep.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
protected Traverser.Admin<S> processNextStart() {
    return PathProcessor.processTraverserPathLabels(super.processNextStart(), this.keepLabels);
}
 
Example 10
Source File: PathFilterStep.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
protected Traverser.Admin<S> processNextStart() {
    return PathProcessor.processTraverserPathLabels(super.processNextStart(), this.keepLabels);
}
 
Example 11
Source File: WhereTraversalStep.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
@Override
protected Traverser.Admin<S> processNextStart() {
    return PathProcessor.processTraverserPathLabels(super.processNextStart(), this.keepLabels);
}
 
Example 12
Source File: PixyCoalesceStep.java    From pixy with Apache License 2.0 4 votes vote down vote up
@Override
protected Traverser.Admin processNextStart() {
    return PathProcessor.processTraverserPathLabels(super.processNextStart(), this.keepLabels);
}