This is an automated email from the ASF dual-hosted git repository. xiazcy pushed a commit to branch graphbinary-label-list in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit a77ef9c7ccca6c8e1d4bf56244a38127831905f3 Author: Yang Xia <[email protected]> AuthorDate: Mon Sep 16 21:10:56 2024 -0700 Update v4 gbin compatibility test files according to new serialization updates --- CHANGELOG.asciidoc | 1 + .../structure/io/binary/types/GraphSerializer.java | 17 +++++++++++------ .../structure/io/graphbinary/bulked-traverser-v4.gbin | Bin 81 -> 93 bytes .../io/graphbinary/max-offsetdatetime-v4.gbin | Bin 20 -> 20 bytes .../io/graphbinary/meta-vertexproperty-v4.gbin | Bin 55 -> 61 bytes .../io/graphbinary/min-offsetdatetime-v4.gbin | Bin 20 -> 20 bytes .../structure/io/graphbinary/no-prop-edge-v4.gbin | Bin 62 -> 80 bytes .../structure/io/graphbinary/no-prop-vertex-v4.gbin | Bin 24 -> 30 bytes .../structure/io/graphbinary/prop-path-v4.gbin | Bin 575 -> 635 bytes .../set-cardinality-vertexproperty-v4.gbin | Bin 72 -> 78 bytes .../structure/io/graphbinary/tinker-graph-v4.gbin | Bin 2264 -> 2504 bytes .../structure/io/graphbinary/traversal-edge-v4.gbin | Bin 81 -> 99 bytes .../structure/io/graphbinary/traversal-path-v4.gbin | Bin 108 -> 126 bytes .../structure/io/graphbinary/traversal-tree-v4.gbin | Bin 152 -> 176 bytes .../structure/io/graphbinary/traversal-vertex-v4.gbin | Bin 405 -> 441 bytes .../io/graphbinary/traversal-vertexproperty-v4.gbin | Bin 39 -> 45 bytes .../structure/io/graphbinary/var-type-map-v4.gbin | Bin 79 -> 95 bytes .../structure/io/graphbinary/vertex-traverser-v4.gbin | Bin 415 -> 451 bytes .../apache/tinkerpop/gremlin/structure/io/Model.java | 7 ++++--- 19 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index e561a2154e..6aaf4aa92d 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -65,6 +65,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima * Remove serializers for datatype removed from GraphBinaryV4 IO spec. * Add `DateTime` serializer for Java and Python according to GraphBinaryV4 IO spec. * Replaced `Date` with `OffsetDateTime` in Java core. +* Update serializers for `label` as a singleton list of string according to GraphBinaryV4 IO spec. * The `maxContentLength` setting for Gremlin Driver has been renamed to `maxResponseContentLength` and now blocks incoming responses that are too large based on total response size. * The `maxContentLength` setting for Gremlin Server has been renamed to `maxRequestContentLength`. diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/GraphSerializer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/GraphSerializer.java index f107b8afac..d81ce100c9 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/GraphSerializer.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/GraphSerializer.java @@ -35,6 +35,7 @@ import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; import java.io.IOException; import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -63,12 +64,13 @@ public class GraphSerializer extends SimpleTypeSerializer<Graph> { final Graph graph = (Graph) openMethod.invoke(null, conf); final int vertexCount = context.readValue(buffer, Integer.class, false); for (int ix = 0; ix < vertexCount; ix++) { - final Vertex v = graph.addVertex(T.id, context.read(buffer), T.label, context.readValue(buffer, String.class, false)); + final Vertex v = graph.addVertex(T.id, context.read(buffer), T.label, context.readValue(buffer, ArrayList.class, false).get(0)); final int vertexPropertyCount = context.readValue(buffer, Integer.class, false); for (int iy = 0; iy < vertexPropertyCount; iy++) { final Object id = context.read(buffer); - final String label = context.readValue(buffer, String.class, false); + // reading single string value for now according to GraphBinaryV4 + final String label = (String) context.readValue(buffer, ArrayList.class, false).get(0); final Object val = context.read(buffer); context.read(buffer); // toss parent as it's always null final VertexProperty<Object> vp = v.property(VertexProperty.Cardinality.list, label, val, T.id, id); @@ -83,7 +85,8 @@ public class GraphSerializer extends SimpleTypeSerializer<Graph> { final int edgeCount = context.readValue(buffer, Integer.class, false); for (int ix = 0; ix < edgeCount; ix++) { final Object id = context.read(buffer); - final String label = context.readValue(buffer, String.class, false); + // reading single string value for now according to GraphBinaryV4 + final String label = (String) context.readValue(buffer, ArrayList.class, false).get(0); final Object inId = context.read(buffer); final Vertex inV = graph.vertices(inId).next(); context.read(buffer); // toss in label - always null in this context @@ -131,12 +134,13 @@ public class GraphSerializer extends SimpleTypeSerializer<Graph> { final List<VertexProperty<Object>> vertexProperties = IteratorUtils.list(vertex.properties()); context.write(vertex.id(), buffer); - context.writeValue(vertex.label(), buffer, false); + // serializing label as list here for now according to GraphBinaryV4 + context.writeValue(Collections.singletonList(vertex.label()), buffer, false); context.writeValue(vertexProperties.size(), buffer, false); for (VertexProperty<Object> vp : vertexProperties) { context.write(vp.id(), buffer); - context.writeValue(vp.label(), buffer, false); + context.writeValue(Collections.singletonList(vp.label()), buffer, false); context.write(vp.value(), buffer); // maintain the VertexProperty format we have with this empty parent......... @@ -149,7 +153,8 @@ public class GraphSerializer extends SimpleTypeSerializer<Graph> { private void writeEdge(Buffer buffer, GraphBinaryWriter context, Edge edge) throws IOException { context.write(edge.id(), buffer); - context.writeValue(edge.label(), buffer, false); + // serializing label as list here for now according to GraphBinaryV4 + context.writeValue(Collections.singletonList(edge.label()), buffer, false); context.write(edge.inVertex().id(), buffer); diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/bulked-traverser-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/bulked-traverser-v4.gbin index ec0a589053..8878bbec8e 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/bulked-traverser-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/bulked-traverser-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/max-offsetdatetime-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/max-offsetdatetime-v4.gbin index 620169668a..e59db1ee46 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/max-offsetdatetime-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/max-offsetdatetime-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/meta-vertexproperty-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/meta-vertexproperty-v4.gbin index f06f76cbc4..dd181d43da 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/meta-vertexproperty-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/meta-vertexproperty-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/min-offsetdatetime-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/min-offsetdatetime-v4.gbin index b915bea8ca..e1ca5d6caf 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/min-offsetdatetime-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/min-offsetdatetime-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/no-prop-edge-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/no-prop-edge-v4.gbin index 201264742c..17ebdda413 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/no-prop-edge-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/no-prop-edge-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/no-prop-vertex-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/no-prop-vertex-v4.gbin index cb85436422..462187167c 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/no-prop-vertex-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/no-prop-vertex-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/prop-path-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/prop-path-v4.gbin index 9306df5aa8..4213e12a18 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/prop-path-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/prop-path-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/set-cardinality-vertexproperty-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/set-cardinality-vertexproperty-v4.gbin index 133922bb45..a5ee87ec28 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/set-cardinality-vertexproperty-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/set-cardinality-vertexproperty-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/tinker-graph-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/tinker-graph-v4.gbin index a0a76d1396..c1f53cba3a 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/tinker-graph-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/tinker-graph-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-edge-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-edge-v4.gbin index f5404427d4..25b658ecd1 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-edge-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-edge-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-path-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-path-v4.gbin index 5a0a2e5ef3..fda24e98c5 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-path-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-path-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-tree-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-tree-v4.gbin index 5e589e15f7..e1112df6e9 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-tree-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-tree-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-vertex-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-vertex-v4.gbin index 4347734a13..6b592bf0f2 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-vertex-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-vertex-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-vertexproperty-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-vertexproperty-v4.gbin index 8ddbebdefc..4120d8c419 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-vertexproperty-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/traversal-vertexproperty-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/var-type-map-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/var-type-map-v4.gbin index e2d511ef03..66d876a173 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/var-type-map-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/var-type-map-v4.gbin differ diff --git a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/vertex-traverser-v4.gbin b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/vertex-traverser-v4.gbin index 2448b5c74f..46e02df795 100644 Binary files a/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/vertex-traverser-v4.gbin and b/gremlin-test/src/main/resources/org/apache/tinkerpop/gremlin/structure/io/graphbinary/vertex-traverser-v4.gbin differ diff --git a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java index 2e309d4fb1..52db0ce318 100644 --- a/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java +++ b/gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/structure/io/Model.java @@ -38,7 +38,9 @@ import java.math.BigInteger; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.time.Duration; +import java.time.Instant; import java.time.OffsetDateTime; +import java.time.ZoneOffset; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.Arrays; @@ -105,9 +107,8 @@ public class Model { final Map<Object,Object> map = new HashMap<>(); map.put("test", 123); - map.put(new Date(1481295L), "red"); - map.put(Arrays.asList(1,2,3), new Date(1481295L)); - map.put(null, null); + map.put(OffsetDateTime.ofInstant(Instant.ofEpochMilli(1481295L), ZoneOffset.UTC), "red"); + map.put(Arrays.asList(1,2,3), OffsetDateTime.ofInstant(Instant.ofEpochMilli(1481295L), ZoneOffset.UTC)); addCoreEntry(map, "var-type-map", "Map is redefined so that to provide the ability to allow for non-String keys, which is not possible in JSON."); addCoreEntry(Collections.EMPTY_MAP, "empty-map");
