Java Code Examples for org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils#concat()
The following examples show how to use
org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils#concat() .
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: StarGraph.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) { if (direction.equals(Direction.OUT)) { return null == this.outEdges ? Collections.emptyIterator() : edgeLabels.length == 0 ? IteratorUtils.flatMap(this.outEdges.values().iterator(), List::iterator) : this.outEdges.entrySet().stream() .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels)) .map(Map.Entry::getValue) .flatMap(List::stream) .iterator(); } else if (direction.equals(Direction.IN)) { return null == this.inEdges ? Collections.emptyIterator() : edgeLabels.length == 0 ? IteratorUtils.flatMap(this.inEdges.values().iterator(), List::iterator) : this.inEdges.entrySet().stream() .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels)) .map(Map.Entry::getValue) .flatMap(List::stream) .iterator(); } else return IteratorUtils.concat(this.edges(Direction.IN, edgeLabels), this.edges(Direction.OUT, edgeLabels)); }
Example 2
Source File: Neo4jVertex.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { this.graph.tx().readWrite(); return new Iterator<Vertex>() { final Iterator<Neo4jRelationship> relationshipIterator = 0 == edgeLabels.length ? BOTH == direction ? IteratorUtils.concat(getBaseVertex().relationships(Neo4jHelper.mapDirection(OUT)).iterator(), getBaseVertex().relationships(Neo4jHelper.mapDirection(IN)).iterator()) : getBaseVertex().relationships(Neo4jHelper.mapDirection(direction)).iterator() : BOTH == direction ? IteratorUtils.concat(getBaseVertex().relationships(Neo4jHelper.mapDirection(OUT), (edgeLabels)).iterator(), getBaseVertex().relationships(Neo4jHelper.mapDirection(IN), (edgeLabels)).iterator()) : getBaseVertex().relationships(Neo4jHelper.mapDirection(direction), (edgeLabels)).iterator(); @Override public boolean hasNext() { return this.relationshipIterator.hasNext(); } @Override public Neo4jVertex next() { return new Neo4jVertex(this.relationshipIterator.next().other(getBaseVertex()), graph); } }; }
Example 3
Source File: Neo4jVertex.java From tinkerpop with Apache License 2.0 | 6 votes |
@Override public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) { this.graph.tx().readWrite(); return new Iterator<Edge>() { final Iterator<Neo4jRelationship> relationshipIterator = 0 == edgeLabels.length ? BOTH == direction ? IteratorUtils.concat(getBaseVertex().relationships(Neo4jHelper.mapDirection(OUT)).iterator(), getBaseVertex().relationships(Neo4jHelper.mapDirection(IN)).iterator()) : getBaseVertex().relationships(Neo4jHelper.mapDirection(direction)).iterator() : BOTH == direction ? IteratorUtils.concat(getBaseVertex().relationships(Neo4jHelper.mapDirection(OUT), (edgeLabels)).iterator(), getBaseVertex().relationships(Neo4jHelper.mapDirection(IN), (edgeLabels)).iterator()) : getBaseVertex().relationships(Neo4jHelper.mapDirection(direction), (edgeLabels)).iterator(); @Override public boolean hasNext() { return this.relationshipIterator.hasNext(); } @Override public Neo4jEdge next() { return new Neo4jEdge(this.relationshipIterator.next(), graph); } }; }
Example 4
Source File: TinkerVertex.java From tinkergraph-gremlin with Apache License 2.0 | 5 votes |
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { return TinkerHelper.inComputerMode(this.graph) ? direction.equals(Direction.BOTH) ? IteratorUtils.concat( IteratorUtils.map(this.edges(Direction.OUT, edgeLabels), Edge::inVertex), IteratorUtils.map(this.edges(Direction.IN, edgeLabels), Edge::outVertex)) : IteratorUtils.map(this.edges(direction, edgeLabels), edge -> edge.vertices(direction.opposite()).next()) : (Iterator) TinkerHelper.getVertices(this, direction, edgeLabels); }
Example 5
Source File: SpecializedTinkerVertex.java From tinkergraph-gremlin with Apache License 2.0 | 5 votes |
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { Iterator<Edge> edges = edges(direction, edgeLabels); if (direction == Direction.IN) { return IteratorUtils.map(edges, Edge::outVertex); } else if (direction == Direction.OUT) { return IteratorUtils.map(edges, Edge::inVertex); } else if (direction == Direction.BOTH) { return IteratorUtils.concat(vertices(Direction.IN, edgeLabels), vertices(Direction.OUT, edgeLabels)); } else { return Collections.emptyIterator(); } }
Example 6
Source File: StarGraph.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { if (direction.equals(Direction.OUT)) return IteratorUtils.map(this.edges(direction, edgeLabels), Edge::inVertex); else if (direction.equals(Direction.IN)) return IteratorUtils.map(this.edges(direction, edgeLabels), Edge::outVertex); else return IteratorUtils.concat(this.vertices(Direction.IN, edgeLabels), this.vertices(Direction.OUT, edgeLabels)); }
Example 7
Source File: TinkerVertex.java From tinkerpop with Apache License 2.0 | 5 votes |
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { return TinkerHelper.inComputerMode(this.graph) ? direction.equals(Direction.BOTH) ? IteratorUtils.concat( IteratorUtils.map(this.edges(Direction.OUT, edgeLabels), Edge::inVertex), IteratorUtils.map(this.edges(Direction.IN, edgeLabels), Edge::outVertex)) : IteratorUtils.map(this.edges(direction, edgeLabels), edge -> edge.vertices(direction.opposite()).next()) : (Iterator) TinkerHelper.getVertices(this, direction, edgeLabels); }
Example 8
Source File: Bytecode.java From tinkerpop with Apache License 2.0 | 2 votes |
/** * Get both the {@link TraversalSource} and {@link Traversal} instructions of this bytecode. * The traversal source instructions are provided prior to the traversal instructions. * * @return an interable of all the instructions in this bytecode */ public Iterable<Instruction> getInstructions() { return () -> IteratorUtils.concat(this.sourceInstructions.iterator(), this.stepInstructions.iterator()); }