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 2019/04/16 22:01:35 UTC

[tinkerpop] branch TINKERPOP-2196 created (now b0f9957)

This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a change to branch TINKERPOP-2196
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


      at b0f9957  TINKERPOP-2196 Fixed PartitionStrategy when setting vertex label

This branch includes the following new commits:

     new b0f9957  TINKERPOP-2196 Fixed PartitionStrategy when setting vertex label

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[tinkerpop] 01/01: TINKERPOP-2196 Fixed PartitionStrategy when setting vertex label

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch TINKERPOP-2196
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit b0f99577697a15f65e796e6359231cc86f64fa7f
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Tue Apr 16 17:59:45 2019 -0400

    TINKERPOP-2196 Fixed PartitionStrategy when setting vertex label
    
    If includeMetaProperties is enabled and vertex label set then an error would follow because T.label was not being properly accounted for. You can't check cardinality for T.
---
 CHANGELOG.asciidoc                                 |  1 +
 .../strategy/decoration/PartitionStrategy.java     | 32 ++++++++++++----------
 .../decoration/PartitionStrategyProcessTest.java   | 10 +++++++
 3 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 9a33554..bb01a43 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -25,6 +25,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 
 * Improved folding of `property()` step into related mutating steps.
 * Removed `gperfutils` dependencies from Gremlin Console.
+* Fixed `PartitionStrategy` when setting vertex label and having `includeMetaProperties` configured to `true`.
 * Ensure `gremlin.sh` works when directories contain spaces
 * Enabled `ctrl+c` to interrupt long running processes in Gremlin Console.
 * Implemented `EdgeLabelVerificationStrategy`
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java
index 122debb..20581a7 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategy.java
@@ -214,20 +214,24 @@ public final class PartitionStrategy extends AbstractTraversalStrategy<Traversal
                     final Parameters parameters = ((Parameterizing) step).getParameters();
                     final Map<Object, List<Object>> params = parameters.getRaw();
                     params.forEach((k, v) -> {
-                        final List<Step> addPropertyStepsToAppend = new ArrayList<>(v.size());
-                        final VertexProperty.Cardinality cardinality = vertexFeatures.getCardinality((String) k);
-                        v.forEach(o -> {
-                            final AddPropertyStep addPropertyStep = new AddPropertyStep(traversal, cardinality, k, o);
-                            addPropertyStep.addPropertyMutations(partitionKey, writePartition);
-                            addPropertyStepsToAppend.add(addPropertyStep);
-
-                            // need to remove the parameter from the AddVertex/StartStep because it's now being added
-                            // via the AddPropertyStep
-                            parameters.remove(k);
-                        });
-
-                        Collections.reverse(addPropertyStepsToAppend);
-                        addPropertyStepsToAppend.forEach(s -> TraversalHelper.insertAfterStep(s, step, traversal));
+
+                        // need to filter out T based keys
+                        if (k instanceof String) {
+                            final List<Step> addPropertyStepsToAppend = new ArrayList<>(v.size());
+                            final VertexProperty.Cardinality cardinality = vertexFeatures.getCardinality((String) k);
+                            v.forEach(o -> {
+                                final AddPropertyStep addPropertyStep = new AddPropertyStep(traversal, cardinality, k, o);
+                                addPropertyStep.addPropertyMutations(partitionKey, writePartition);
+                                addPropertyStepsToAppend.add(addPropertyStep);
+
+                                // need to remove the parameter from the AddVertex/StartStep because it's now being added
+                                // via the AddPropertyStep
+                                parameters.remove(k);
+                            });
+
+                            Collections.reverse(addPropertyStepsToAppend);
+                            addPropertyStepsToAppend.forEach(s -> TraversalHelper.insertAfterStep(s, step, traversal));
+                        }
                     });
                 }
             }
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategyProcessTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategyProcessTest.java
index 2b463c5..ea976d4 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategyProcessTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/PartitionStrategyProcessTest.java
@@ -128,14 +128,24 @@ public class PartitionStrategyProcessTest extends AbstractGremlinProcessTest {
                 .partitionKey(partition).writePartition("B").addReadPartition("B").addReadPartition("A").create());
 
         final Vertex v = gOverA.addV().property("any", "thing").property("some", "thing").next();
+        final Vertex labelledV = gOverA.addV("person").property("name", "thing").property("that", "thing").next();
 
         assertNotNull(v);
         assertEquals("thing", g.V(v).values("any").next());
+        assertEquals(Vertex.DEFAULT_LABEL, g.V(v).label().next());
         assertEquals("A", g.V(v).values(partition).next());
         assertEquals("A", g.V(v).properties("any").values(partition).next());
         assertEquals("thing", g.V(v).values("some").next());
         assertEquals("A", g.V(v).properties("some").values(partition).next());
 
+        assertNotNull(labelledV);
+        assertEquals("thing", g.V(labelledV).values("name").next());
+        assertEquals("person", g.V(labelledV).label().next());
+        assertEquals("A", g.V(labelledV).values(partition).next());
+        assertEquals("A", g.V(labelledV).properties("name").values(partition).next());
+        assertEquals("thing", g.V(labelledV).values("that").next());
+        assertEquals("A", g.V(labelledV).properties("that").values(partition).next());
+
         gOverAB.V(v).property("that", "thing").iterate();
         assertEquals("thing", g.V(v).values("that").next());
         assertEquals("B", g.V(v).properties("that").values(partition).next());