TINKERPOP-1359 SubgraphStep needed to check meta-properties feature on the 
source graph. CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/c90fc1e1
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/c90fc1e1
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/c90fc1e1

Branch: refs/heads/TINKERPOP-1278
Commit: c90fc1e1a1520bc3ac9872681fafb1173dd038bb
Parents: c8c77af
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Jul 8 16:34:52 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Jul 8 16:34:52 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                               |  3 ++-
 .../traversal/step/sideEffect/SubgraphStep.java  | 19 +++++++++++++++----
 2 files changed, 17 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c90fc1e1/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 3499304..999b2a9 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,7 +26,8 @@ 
image::https://raw.githubusercontent.com/apache/incubator-tinkerpop/master/docs/
 TinkerPop 3.1.3 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-* Enured calls to `Result.hasNext()` were idempotent.
+* Fixed bug in `SubgraphStep` where features were not being checked properly 
prior to reading meta-properties.
+* Ensured calls to `Result.hasNext()` were idempotent.
 * Avoid hamcrest conflict by using mockito-core instead of mockito-all 
dependency in `gremlin-test`.
 * Fixed bug in `GremlinExecutor` causing Gremlin Server to lock up when 
parallel requests were submitted on the same session if those parallel requests 
included a script that blocked indefinitely.
 * Changed `GremlinExecutor` timeout scheduling so that the timer would not 
start until a time closer to the actual start of script evaluation.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/c90fc1e1/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphStep.java
----------------------------------------------------------------------
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphStep.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphStep.java
index c7bcd57..aa88b5d 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphStep.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphStep.java
@@ -44,6 +44,7 @@ public final class SubgraphStep extends SideEffectStep<Edge> 
implements SideEffe
     private Graph subgraph;
     private String sideEffectKey;
     private Graph.Features.VertexFeatures parentGraphFeatures;
+    private boolean subgraphSupportsMetaProperties = false;
 
     private static final Map<String, Object> DEFAULT_CONFIGURATION = new 
HashMap<String, Object>() {{
         put(Graph.GRAPH, 
"org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph"); // hard 
coded because TinkerGraph is not part of gremlin-core
@@ -58,11 +59,14 @@ public final class SubgraphStep extends 
SideEffectStep<Edge> implements SideEffe
     @Override
     protected void sideEffect(final Traverser.Admin<Edge> traverser) {
         parentGraphFeatures = ((Graph) 
traversal.getGraph().get()).features().vertex();
-        if (null == this.subgraph) {
-            this.subgraph = traverser.sideEffects(this.sideEffectKey);
-            if (!this.subgraph.features().vertex().supportsUserSuppliedIds() 
|| !this.subgraph.features().edge().supportsUserSuppliedIds())
+        if (null == subgraph) {
+            subgraph = traverser.sideEffects(sideEffectKey);
+            if (!subgraph.features().vertex().supportsUserSuppliedIds() || 
!subgraph.features().edge().supportsUserSuppliedIds())
                 throw new IllegalArgumentException("The provided subgraph must 
support user supplied ids for vertices and edges: " + this.subgraph);
         }
+
+        subgraphSupportsMetaProperties = 
subgraph.features().vertex().supportsMetaProperties();
+
         addEdgeToSubgraph(traverser.get());
     }
 
@@ -99,10 +103,17 @@ public final class SubgraphStep extends 
SideEffectStep<Edge> implements SideEffe
         final Iterator<Vertex> vertexIterator = subgraph.vertices(vertex.id());
         if (vertexIterator.hasNext()) return vertexIterator.next();
         final Vertex subgraphVertex = subgraph.addVertex(T.id, vertex.id(), 
T.label, vertex.label());
+
         vertex.properties().forEachRemaining(vertexProperty -> {
             final VertexProperty.Cardinality cardinality = 
parentGraphFeatures.getCardinality(vertexProperty.key());
             final VertexProperty<?> subgraphVertexProperty = 
subgraphVertex.property(cardinality, vertexProperty.key(), 
vertexProperty.value(), T.id, vertexProperty.id());
-            vertexProperty.properties().forEachRemaining(property -> 
subgraphVertexProperty.property(property.key(), property.value()));
+
+            // only iterate the VertexProperties if the current graph can have 
them and if the subgraph can support
+            // them. unfortunately we don't have a way to write a test for 
this as we dont' have a graph that supports
+            // user supplied ids and doesn't support metaproperties.
+            if (parentGraphFeatures.supportsMetaProperties() && 
subgraphSupportsMetaProperties) {
+                vertexProperty.properties().forEachRemaining(property -> 
subgraphVertexProperty.property(property.key(), property.value()));
+            }
         });
         return subgraphVertex;
     }

Reply via email to