You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/04/09 16:12:10 UTC
[13/15] incubator-tinkerpop git commit: if no edge labels are
required for Vertex.edges(), then use a faster iterator model than Streaming.
if no edge labels are required for Vertex.edges(), then use a faster iterator model than Streaming.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/c26342a7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/c26342a7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/c26342a7
Branch: refs/heads/TINKERPOP3-581
Commit: c26342a77f101f06d557068abdcac96509b23b4c
Parents: aabc66f
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Apr 8 16:08:14 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Apr 8 16:08:14 2015 -0600
----------------------------------------------------------------------
.../gremlin/structure/util/star/StarGraph.java | 46 ++++++++++----------
.../computer/spark/SparkGraphComputer.java | 3 --
2 files changed, 22 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c26342a7/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
index fd9b52a..0af926f 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraph.java
@@ -54,9 +54,11 @@ import java.util.stream.Stream;
public final class StarGraph implements Graph {
private static final Configuration STAR_GRAPH_CONFIGURATION = new BaseConfiguration();
+
static {
STAR_GRAPH_CONFIGURATION.setProperty(Graph.GRAPH, StarGraph.class.getCanonicalName());
}
+
private StarVertex starVertex = null;
private Long nextId = 0l;
@@ -283,37 +285,33 @@ public final class StarGraph implements Graph {
@Override
public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) {
if (direction.equals(Direction.OUT)) {
- return this.outEdges.entrySet().stream()
- .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
- .map(Map.Entry::getValue)
- .flatMap(List::stream)
- .iterator();
+ return 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 this.inEdges.entrySet().stream()
- .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
- .map(Map.Entry::getValue)
- .flatMap(List::stream)
- .iterator();
- } else {
- return Stream.concat(this.inEdges.entrySet().stream(), this.outEdges.entrySet().stream())
- .filter(entry -> ElementHelper.keyExists(entry.getKey(), edgeLabels))
- .map(Map.Entry::getValue)
- .flatMap(List::stream)
- .iterator();
- }
+ return 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));
}
@Override
public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
- if (direction.equals(Direction.OUT)) {
+ if (direction.equals(Direction.OUT))
return IteratorUtils.map(this.edges(direction, edgeLabels), Edge::inVertex);
- } else if (direction.equals(Direction.IN)) {
+ else if (direction.equals(Direction.IN))
return IteratorUtils.map(this.edges(direction, edgeLabels), Edge::outVertex);
- } else {
- return IteratorUtils.<Vertex>concat(
- IteratorUtils.map(this.edges(Direction.IN, edgeLabels), Edge::outVertex),
- IteratorUtils.map(this.edges(Direction.OUT, edgeLabels), Edge::inVertex));
- }
+ else
+ return IteratorUtils.concat(this.vertices(Direction.IN, edgeLabels), this.vertices(Direction.OUT, edgeLabels));
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c26342a7/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkGraphComputer.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkGraphComputer.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkGraphComputer.java
index 9f3fd78..4b063bb 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkGraphComputer.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/spark/SparkGraphComputer.java
@@ -206,10 +206,7 @@ public final class SparkGraphComputer implements GraphComputer {
if (!this.mapReducers.isEmpty()) {
// drop all edges and messages in the graphRDD as they are no longer needed for the map reduce jobs
final JavaPairRDD<Object, VertexWritable> mapReduceGraphRDD = SparkExecutor.prepareGraphRDDForMapReduce(graphRDD, viewIncomingRDD).setName("mapReduceGraphRDD").cache();
- // TODO: boolean first = true;
for (final MapReduce mapReduce : this.mapReducers) {
- // TODO: if (first) first = false;
- // TODO: else graphRDD.unpersist(); // the original graphRDD is no longer needed so free up its memory
// execute the map reduce job
final HadoopConfiguration newApacheConfiguration = new HadoopConfiguration(apacheConfiguration);
mapReduce.storeState(newApacheConfiguration);