Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer#testAll()

The following examples show how to use org.apache.tinkerpop.gremlin.process.traversal.step.util.HasContainer#testAll() . 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: TraversalUtil.java    From hugegraph with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static <V> Iterator<V> filterResult(
                              List<HasContainer> hasContainers,
                              Iterator<? extends Element> iterator) {
    Iterator<?> result = new FilterIterator<>(iterator, elem -> {
        return HasContainer.testAll(elem, hasContainers);
    });
    return (Iterator<V>) result;
}
 
Example 2
Source File: TinkerGraphStep.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
private <E extends Element> Iterator<E> iteratorList(final Iterator<E> iterator) {
    final List<E> list = new ArrayList<>();
    while (iterator.hasNext()) {
        final E e = iterator.next();
        if (HasContainer.testAll(e, this.hasContainers))
            list.add(e);
    }
    return list.iterator();
}
 
Example 3
Source File: JanusGraphStep.java    From grakn with GNU Affero General Public License v3.0 5 votes vote down vote up
private <A extends Element> Iterator<A> iteratorList(Iterator<A> iterator) {
    List<A> list = new ArrayList<>();
    while (iterator.hasNext()) {
        A e = iterator.next();
        if (HasContainer.testAll(e, this.getHasContainers())) {
            list.add(e);
        }
    }
    return list.iterator();
}
 
Example 4
Source File: HasStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean filter(final Traverser.Admin<S> traverser) {
    // the generic S is defined as Element but Property can also be used with HasStep so this seems to cause
    // problems with some jdk versions.
    if (traverser.get() instanceof Element)
        return HasContainer.testAll(traverser.get(), this.hasContainers);
    else if (traverser.get() instanceof Property)
        return HasContainer.testAll((Property) traverser.get(), this.hasContainers);
    else
        throw new IllegalStateException(String.format(
                "Traverser to has() must be of type Property or Element, not %s",
                traverser.get().getClass().getName()));
}
 
Example 5
Source File: TinkerGraphStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
private <E extends Element> Iterator<E> iteratorList(final Iterator<E> iterator) {
    final List<E> list = new ArrayList<>();
    while (iterator.hasNext()) {
        final E e = iterator.next();
        if (HasContainer.testAll(e, this.hasContainers))
            list.add(e);
    }

    // close the old iterator to release resources since we are returning a new iterator (over list)
    // out of this function.
    CloseableIterator.closeIterator(iterator);

    return new TinkerGraphIterator<>(list.iterator());
}
 
Example 6
Source File: SqlgHasStep.java    From sqlg with MIT License 4 votes vote down vote up
@Override
protected boolean filter(final Traverser.Admin<S> traverser) {
    return HasContainer.testAll(traverser.get(), this.hasContainers);
}