You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2016/02/06 20:54:49 UTC
[18/30] incubator-tinkerpop git commit: minor nothings.
minor nothings.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/097e09a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/097e09a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/097e09a3
Branch: refs/heads/master
Commit: 097e09a39a151e6dbb8ebb268bc1792baac8765a
Parents: 1c9a31c
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Feb 3 13:48:31 2016 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Feb 3 13:48:31 2016 -0700
----------------------------------------------------------------------
.../gremlin/process/computer/GraphFilter.java | 80 +++++++++++---------
.../spark/structure/io/gryo/GryoSerializer.java | 4 +-
2 files changed, 47 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/097e09a3/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilter.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilter.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilter.java
index 082e1d4..e6083a1 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilter.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilter.java
@@ -20,6 +20,7 @@
package org.apache.tinkerpop.gremlin.process.computer;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.RangeGlobalStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.VertexStep;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalUtil;
@@ -46,7 +47,7 @@ public final class GraphFilter implements Cloneable, Serializable {
private Traversal.Admin<Vertex, Vertex> vertexFilter = null;
private Traversal.Admin<Vertex, Edge> edgeFilter = null;
- // private boolean dropAllEdges (make this a fast one if the end is limit(0)?)
+ protected boolean allowNoEdges = false;
protected Direction allowedEdgeDirection = Direction.BOTH;
protected Set<String> allowedEdgeLabels = new HashSet<>();
protected boolean allowAllRemainingEdges = false;
@@ -61,7 +62,10 @@ public final class GraphFilter implements Cloneable, Serializable {
if (!TraversalHelper.isLocalStarGraph(edgeFilter.asAdmin()))
throw GraphComputer.Exceptions.edgeFilterAccessesAdjacentVertices(edgeFilter);
this.edgeFilter = edgeFilter.asAdmin().clone();
- if (this.edgeFilter.getStartStep() instanceof VertexStep) {
+ if (this.edgeFilter.getEndStep() instanceof RangeGlobalStep && 0 == ((RangeGlobalStep) this.edgeFilter.getEndStep()).getHighRange()) {
+ this.allowNoEdges = true;
+ } else if (this.edgeFilter.getStartStep() instanceof VertexStep) {
+ this.allowedEdgeLabels.clear();
this.allowedEdgeLabels.addAll(Arrays.asList(((VertexStep) this.edgeFilter.getStartStep()).getEdgeLabels()));
this.allowedEdgeDirection = ((VertexStep) this.edgeFilter.getStartStep()).getDirection();
this.allowAllRemainingEdges = 1 == this.edgeFilter.getSteps().size();
@@ -135,41 +139,45 @@ public final class GraphFilter implements Cloneable, Serializable {
return null;
else if (this.legalVertex(vertex)) {
if (this.hasEdgeFilter()) {
- if (!this.allowedEdgeDirection.equals(Direction.BOTH))
- vertex.dropEdges(this.allowedEdgeDirection.opposite());
- if (!this.allowedEdgeLabels.isEmpty())
- vertex.keepEdges(this.allowedEdgeDirection, this.allowedEdgeLabels);
-
- if (!this.allowAllRemainingEdges) {
- final Map<String, List<Edge>> outEdges = new HashMap<>();
- final Map<String, List<Edge>> inEdges = new HashMap<>();
- this.legalEdges(vertex).forEachRemaining(edge -> {
- if (edge instanceof StarGraph.StarOutEdge) {
- List<Edge> edges = outEdges.get(edge.label());
- if (null == edges) {
- edges = new ArrayList<>();
- outEdges.put(edge.label(), edges);
+ if (this.allowNoEdges) {
+ vertex.dropEdges(Direction.BOTH);
+ } else {
+ if (!this.allowedEdgeDirection.equals(Direction.BOTH))
+ vertex.dropEdges(this.allowedEdgeDirection.opposite());
+ if (!this.allowedEdgeLabels.isEmpty())
+ vertex.keepEdges(this.allowedEdgeDirection, this.allowedEdgeLabels);
+
+ if (!this.allowAllRemainingEdges) {
+ final Map<String, List<Edge>> outEdges = new HashMap<>();
+ final Map<String, List<Edge>> inEdges = new HashMap<>();
+ this.legalEdges(vertex).forEachRemaining(edge -> {
+ if (edge instanceof StarGraph.StarOutEdge) {
+ List<Edge> edges = outEdges.get(edge.label());
+ if (null == edges) {
+ edges = new ArrayList<>();
+ outEdges.put(edge.label(), edges);
+ }
+ edges.add(edge);
+ } else {
+ List<Edge> edges = inEdges.get(edge.label());
+ if (null == edges) {
+ edges = new ArrayList<>();
+ inEdges.put(edge.label(), edges);
+ }
+ edges.add(edge);
}
- edges.add(edge);
- } else {
- List<Edge> edges = inEdges.get(edge.label());
- if (null == edges) {
- edges = new ArrayList<>();
- inEdges.put(edge.label(), edges);
- }
- edges.add(edge);
- }
- });
-
- if (outEdges.isEmpty())
- vertex.dropEdges(Direction.OUT);
- else
- vertex.setEdges(Direction.OUT, outEdges);
-
- if (inEdges.isEmpty())
- vertex.dropEdges(Direction.IN);
- else
- vertex.setEdges(Direction.IN, inEdges);
+ });
+
+ if (outEdges.isEmpty())
+ vertex.dropEdges(Direction.OUT);
+ else
+ vertex.setEdges(Direction.OUT, outEdges);
+
+ if (inEdges.isEmpty())
+ vertex.dropEdges(Direction.IN);
+ else
+ vertex.setEdges(Direction.IN, inEdges);
+ }
}
}
return vertex;
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/097e09a3/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/structure/io/gryo/GryoSerializer.java
----------------------------------------------------------------------
diff --git a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/structure/io/gryo/GryoSerializer.java b/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/structure/io/gryo/GryoSerializer.java
index 3819584..2c1dfa2 100644
--- a/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/structure/io/gryo/GryoSerializer.java
+++ b/spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/structure/io/gryo/GryoSerializer.java
@@ -30,6 +30,7 @@ import org.apache.spark.scheduler.CompressedMapStatus;
import org.apache.spark.scheduler.HighlyCompressedMapStatus;
import org.apache.spark.serializer.Serializer;
import org.apache.spark.serializer.SerializerInstance;
+import org.apache.spark.storage.BlockManagerId;
import org.apache.spark.util.SerializableConfiguration;
import org.apache.spark.util.collection.CompactBuffer;
import org.apache.tinkerpop.gremlin.hadoop.structure.io.ObjectWritable;
@@ -87,7 +88,8 @@ public final class GryoSerializer extends Serializer {
.addCustom(Tuple3[].class)
.addCustom(CompactBuffer.class, new CompactBufferSerializer())
.addCustom(CompactBuffer[].class)
- .addCustom(CompressedMapStatus.class, new ExternalizableSerializer()) // externalizable implemented so its okay
+ .addCustom(CompressedMapStatus.class)
+ .addCustom(BlockManagerId.class)
.addCustom(HighlyCompressedMapStatus.class, new ExternalizableSerializer()) // externalizable implemented so its okay
.addCustom(HttpBroadcast.class)
.addCustom(PythonBroadcast.class)