You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ke...@apache.org on 2024/10/28 18:18:29 UTC

(tinkerpop) branch v4-bulkset updated (ccd807f910 -> 755f87ef25)

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

kenhuuu pushed a change to branch v4-bulkset
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git


 discard ccd807f910 Update BulkSet GraphSONv4 serialization.
     new 755f87ef25 Update BulkSet GraphSONv4 serialization.

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (ccd807f910)
            \
             N -- N -- N   refs/heads/v4-bulkset (755f87ef25)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:
 .../structure/io/graphson/GraphSONMapperEmbeddedTypeTest.java      | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)


(tinkerpop) 01/01: Update BulkSet GraphSONv4 serialization.

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

kenhuuu pushed a commit to branch v4-bulkset
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 755f87ef2531618cda17db7b3fd7ef831d749390
Author: Ken Hu <10...@users.noreply.github.com>
AuthorDate: Mon Oct 28 10:15:49 2024 -0700

    Update BulkSet GraphSONv4 serialization.
---
 docs/src/dev/io/graphson.asciidoc                  | 24 +++++++++++++++++++++-
 .../structure/io/graphson/GraphSONModule.java      |  6 ++++--
 .../io/graphson/TraversalSerializersV4.java        |  5 ++---
 .../graphson/GraphSONMapperEmbeddedTypeTest.java   |  7 ++++---
 .../structure/io/graphson/empty-bulklist-v4.json   |  4 ++++
 .../structure/io/graphson/empty-bulkset-v4.json    |  4 ----
 .../structure/io/graphson/var-bulklist-v4.json     |  4 ++++
 .../structure/io/graphson/var-bulkset-v4.json      | 10 ---------
 .../io/AbstractTypedCompatibilityTest.java         |  2 --
 9 files changed, 41 insertions(+), 25 deletions(-)

diff --git a/docs/src/dev/io/graphson.asciidoc b/docs/src/dev/io/graphson.asciidoc
index 8d70cd2509..cede81a2da 100644
--- a/docs/src/dev/io/graphson.asciidoc
+++ b/docs/src/dev/io/graphson.asciidoc
@@ -2615,7 +2615,7 @@ The untyped version has one additional required key "type" which is always "vert
 
 ==== VertexProperty
 
-JOSN Object with required keys: "id", "value", "label", "properties" +
+JSON Object with required keys: "id", "value", "label", "properties" +
 "id" is any type GraphSON 4.0 type +
 "value" is any type GraphSON 4.0 type +
 "label" is a `g:List` of `String` +
@@ -2651,6 +2651,28 @@ JOSN Object with required keys: "id", "value", "label", "properties" +
 
 === Graph Process
 
+==== BulkSet
+
+JSON Array that contains the expanded entries of the BulkSet.
+Note: BulkSet is serialized to g:List so there is no BulkSet deserializer.
+
+[source,json]
+----
+{
+  "@type": "g:List",
+  "@value": [
+    "marko",
+    "josh",
+    "josh"
+  ]
+}
+----
+
+[source,json]
+----
+[ "marko", "josh", "josh" ]
+----
+
 ==== Direction
 
 JSON String of the enum value.
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONModule.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONModule.java
index 904809360d..b19cbb4931 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONModule.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONModule.java
@@ -149,6 +149,10 @@ abstract class GraphSONModule extends TinkerPopJacksonModule {
                     put(Double.class, "Double");
                     put(Float.class, "Float");
 
+                    // BulkSet is expanded to List during serialization but we want the List deserializer to be
+                    // registered to g:List so this entry must be added before List.
+                    put(BulkSet.class, "List");
+
                     put(Map.class, "Map");
                     put(List.class, "List");
                     put(Set.class, "Set");
@@ -165,7 +169,6 @@ abstract class GraphSONModule extends TinkerPopJacksonModule {
                     put(TraversalExplanation.class, "TraversalExplanation");
                     put(Traverser.class, "Traverser");
                     put(Tree.class, "Tree");
-                    put(BulkSet.class, "BulkSet");
                     put(AndP.class, "P");
                     put(OrP.class, "P");
                     put(P.class, "P");
@@ -299,7 +302,6 @@ abstract class GraphSONModule extends TinkerPopJacksonModule {
             addDeserializer(Double.class, new GraphSONSerializersV4.DoubleJacksonDeserializer());
 
             // traversal
-            addDeserializer(BulkSet.class, new TraversalSerializersV4.BulkSetJacksonDeserializer());
             Stream.of(VertexProperty.Cardinality.values(),
                     Column.values(),
                     Direction.values(),
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV4.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV4.java
index 041824525d..01b698b589 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV4.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/TraversalSerializersV4.java
@@ -152,9 +152,8 @@ final class TraversalSerializersV4 {
         public void serialize(final BulkSet bulkSet, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
                 throws IOException {
             jsonGenerator.writeStartArray();
-            for (Map.Entry entry : (Set<Map.Entry>) bulkSet.asBulk().entrySet()) {
-                jsonGenerator.writeObject(entry.getKey());
-                jsonGenerator.writeObject(entry.getValue());
+            for (Object element : bulkSet) {
+                jsonGenerator.writeObject(element);
             }
             jsonGenerator.writeEndArray();
         }
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperEmbeddedTypeTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperEmbeddedTypeTest.java
index b6ae2dc189..94086371dc 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperEmbeddedTypeTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONMapperEmbeddedTypeTest.java
@@ -119,15 +119,16 @@ public class GraphSONMapperEmbeddedTypeTest extends AbstractGraphSONTest {
 
     @Test
     public void shouldHandleBulkSet() throws Exception {
-        // only supported on V3/V4
-        assumeThat(version, not(anyOf(startsWith("v1"), startsWith("v2"))));
+        // only supported on V4
+        assumeThat(version, not(anyOf(startsWith("v1"), startsWith("v2"), startsWith("v3"))));
 
         final BulkSet<String> bs = new BulkSet<>();
         bs.add("test1", 1);
         bs.add("test2", 2);
         bs.add("test3", 3);
 
-        assertEquals(bs, serializeDeserialize(mapper, bs, BulkSet.class));
+        final List<String> expandedBs = new ArrayList<>(bs);
+        assertEquals(expandedBs, serializeDeserializeAuto(mapper, bs));
     }
 
     @Test
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/empty-bulklist-v4.json b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/empty-bulklist-v4.json
new file mode 100644
index 0000000000..aacbd803fb
--- /dev/null
+++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/empty-bulklist-v4.json
@@ -0,0 +1,4 @@
+{
+  "@type" : "g:List",
+  "@value" : [ ]
+}
\ No newline at end of file
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/empty-bulkset-v4.json b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/empty-bulkset-v4.json
deleted file mode 100644
index f9fb4a5eed..0000000000
--- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/empty-bulkset-v4.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
-  "@type" : "g:BulkSet",
-  "@value" : [ ]
-}
\ No newline at end of file
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/var-bulklist-v4.json b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/var-bulklist-v4.json
new file mode 100644
index 0000000000..ac763480b2
--- /dev/null
+++ b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/var-bulklist-v4.json
@@ -0,0 +1,4 @@
+{
+  "@type" : "g:List",
+  "@value" : [ "marko", "josh", "josh" ]
+}
\ No newline at end of file
diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/var-bulkset-v4.json b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/var-bulkset-v4.json
deleted file mode 100644
index c216a36171..0000000000
--- a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphson/var-bulkset-v4.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
-  "@type" : "g:BulkSet",
-  "@value" : [ "marko", {
-    "@type" : "g:Int64",
-    "@value" : 1
-  }, "josh", {
-    "@type" : "g:Int64",
-    "@value" : 2
-  } ]
-}
\ No newline at end of file
diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java
index 3b7bdf9093..bd8dee9cb4 100644
--- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java
+++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/AbstractTypedCompatibilityTest.java
@@ -882,7 +882,6 @@ public abstract class AbstractTypedCompatibilityTest extends AbstractCompatibili
     }
 
     @Test
-    @Ignore("re-enable after GraphSONV4 bulklist is implemented")
     public void shouldReadWriteVarBulkList() throws Exception {
         final String resourceName = "var-bulklist";
 
@@ -898,7 +897,6 @@ public abstract class AbstractTypedCompatibilityTest extends AbstractCompatibili
     }
 
     @Test
-    @Ignore("re-enable after GraphSONV4 bulklist is implemented")
     public void shouldReadWriteEmptyBulkList() throws Exception {
         final String resourceName = "empty-bulklist";