Java Code Examples for org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep#getReturnClass()

The following examples show how to use org.apache.tinkerpop.gremlin.process.traversal.step.map.GraphStep#getReturnClass() . 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: TinkerGraphStep.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
public TinkerGraphStep(final GraphStep<S, E> originalGraphStep) {
    super(originalGraphStep.getTraversal(), originalGraphStep.getReturnClass(), originalGraphStep.isStartStep(), originalGraphStep.getIds());
    originalGraphStep.getLabels().forEach(this::addLabel);

    // we used to only setIteratorSupplier() if there were no ids OR the first id was instanceof Element,
    // but that allowed the filter in g.V(v).has('k','v') to be ignored.  this created problems for
    // PartitionStrategy which wants to prevent someone from passing "v" from one TraversalSource to
    // another TraversalSource using a different partition
    this.setIteratorSupplier(() -> (Iterator<E>) (Vertex.class.isAssignableFrom(this.returnClass) ? this.vertices() : this.edges()));
}
 
Example 2
Source File: JanusGraphStep.java    From grakn with GNU Affero General Public License v3.0 5 votes vote down vote up
public JanusGraphStep(GraphStep<S, E> originalStep) {
    super(originalStep.getTraversal(), originalStep.getReturnClass(), originalStep.isStartStep(), originalStep.getIds());
    originalStep.getLabels().forEach(this::addLabel);
    this.setIteratorSupplier(() -> {
        if (this.ids == null) {
            return Collections.emptyIterator();
        } else if (this.ids.length > 0) {
            Graph graph = (Graph) traversal.asAdmin().getGraph().get();
            return iteratorList((Iterator) graph.vertices(this.ids));
        }
        if (hasLocalContainers.isEmpty()) {
            hasLocalContainers.put(new ArrayList<>(), new QueryInfo(new ArrayList<>(), 0, BaseQuery.NO_LIMIT));
        }
        JanusGraphTransaction tx = JanusGraphTraversalUtil.getTx(traversal);
        GraphCentricQuery globalQuery = buildGlobalGraphCentricQuery(tx);

        Multimap<Integer, GraphCentricQuery> queries = ArrayListMultimap.create();
        if (globalQuery != null && !globalQuery.getSubQuery(0).getBackendQuery().isEmpty()) {
            queries.put(0, globalQuery);
        } else {
            hasLocalContainers.entrySet().forEach(c -> queries.put(c.getValue().getLowLimit(), buildGraphCentricQuery(tx, c)));
        }

        GraphCentricQueryBuilder builder = (GraphCentricQueryBuilder) tx.query();
        List<Iterator<E>> responses = new ArrayList<>();
        queries.entries().forEach(q -> executeGraphCentryQuery(builder, responses, q));

        return new MultiDistinctOrderedIterator<E>(lowLimit, highLimit, responses, orders);
    });
}
 
Example 3
Source File: TitanGraphStep.java    From titan1withtp3.1 with Apache License 2.0 5 votes vote down vote up
public TitanGraphStep(final GraphStep<S, E> originalStep) {
    super(originalStep.getTraversal(), originalStep.getReturnClass(), originalStep.isStartStep(), originalStep.getIds());
    originalStep.getLabels().forEach(this::addLabel);
    this.setIteratorSupplier(() -> {
        TitanTransaction tx = TitanTraversalUtil.getTx(traversal);
        TitanGraphQuery query = tx.query();
        for (HasContainer condition : hasContainers) {
            query.has(condition.getKey(), TitanPredicate.Converter.convert(condition.getBiPredicate()), condition.getValue());
        }
        for (OrderEntry order : orders) query.orderBy(order.key, order.order);
        if (limit != BaseQuery.NO_LIMIT) query.limit(limit);
        ((GraphCentricQueryBuilder) query).profiler(queryProfiler);
        return Vertex.class.isAssignableFrom(this.returnClass) ? query.vertices().iterator() : query.edges().iterator();
    });
}
 
Example 4
Source File: TinkerGraphStep.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public TinkerGraphStep(final GraphStep<S, E> originalGraphStep) {
    super(originalGraphStep.getTraversal(), originalGraphStep.getReturnClass(), originalGraphStep.isStartStep(), originalGraphStep.getIds());
    originalGraphStep.getLabels().forEach(this::addLabel);

    // we used to only setIteratorSupplier() if there were no ids OR the first id was instanceof Element,
    // but that allowed the filter in g.V(v).has('k','v') to be ignored.  this created problems for
    // PartitionStrategy which wants to prevent someone from passing "v" from one TraversalSource to
    // another TraversalSource using a different partition
    this.setIteratorSupplier(() -> (Iterator<E>) (Vertex.class.isAssignableFrom(this.returnClass) ? this.vertices() : this.edges()));
}
 
Example 5
Source File: GraphStrategy.java    From sqlg with MIT License 5 votes vote down vote up
@Override
protected SqlgStep constructSqlgStep(Step startStep) {
    Preconditions.checkArgument(startStep instanceof GraphStep, "Expected a GraphStep, found instead a " + startStep.getClass().getName());
    GraphStep<?, ?> graphStep = (GraphStep) startStep;
    //noinspection unchecked
    return new SqlgGraphStep(this.sqlgGraph, this.traversal, graphStep.getReturnClass(), graphStep.isStartStep(), graphStep.getIds());
}
 
Example 6
Source File: BitsyGraphStep.java    From bitsy with Apache License 2.0 4 votes vote down vote up
public BitsyGraphStep(final GraphStep<S, E> originalGraphStep) {
    super(originalGraphStep.getTraversal(), originalGraphStep.getReturnClass(), originalGraphStep.isStartStep(), originalGraphStep.getIds());
    originalGraphStep.getLabels().forEach(this::addLabel);
    this.setIteratorSupplier(() -> (Iterator<E>) (Vertex.class.isAssignableFrom(this.returnClass) ? this.vertices() : this.edges()));
}
 
Example 7
Source File: HBaseGraphStep.java    From hgraphdb with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public HBaseGraphStep(final GraphStep<S, E> originalGraphStep) {
    super(originalGraphStep.getTraversal(), originalGraphStep.getReturnClass(), originalGraphStep.isStartStep(), originalGraphStep.getIds());
    originalGraphStep.getLabels().forEach(this::addLabel);
    this.setIteratorSupplier(() -> (Iterator<E>) (Vertex.class.isAssignableFrom(this.returnClass) ? this.vertices() : this.edges()));
}
 
Example 8
Source File: Neo4jGraphStep.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
public Neo4jGraphStep(final GraphStep<S, E> originalGraphStep) {
    super(originalGraphStep.getTraversal(), originalGraphStep.getReturnClass(), originalGraphStep.isStartStep(), originalGraphStep.getIds());
    originalGraphStep.getLabels().forEach(this::addLabel);
    this.setIteratorSupplier(() -> (Iterator<E>) (Vertex.class.isAssignableFrom(this.returnClass) ? this.vertices() : this.edges()));
}