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 f7872d6d624261f77b408a310eed6f01e3adc91f
Author: Yang Xia <[email protected]>
AuthorDate: Mon Sep 16 09:08:35 2024 -0700

    serialize string labels as list
---
 .../structure/io/binary/types/EdgeSerializer.java      | 18 ++++++++++++------
 .../io/binary/types/VertexPropertySerializer.java      |  6 ++++--
 .../structure/io/binary/types/VertexSerializer.java    |  8 ++++++--
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/EdgeSerializer.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/EdgeSerializer.java
index 6c52b815e5..32d3550faf 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/EdgeSerializer.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/EdgeSerializer.java
@@ -29,6 +29,8 @@ import 
org.apache.tinkerpop.gremlin.structure.util.detached.DetachedEdge;
 import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -42,12 +44,15 @@ public class EdgeSerializer extends 
SimpleTypeSerializer<Edge> {
     @Override
     protected Edge readValue(final Buffer buffer, final GraphBinaryReader 
context) throws IOException {
         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 inVId = context.read(buffer);
-        final String inVLabel = context.readValue(buffer, String.class, false);
+        // reading single string value for now according to GraphBinaryV4
+        final String inVLabel = (String) context.readValue(buffer, 
ArrayList.class, false).get(0);
         final Object outVId = context.read(buffer);
-        final String outVLabel = context.readValue(buffer, String.class, 
false);
+        // reading single string value for now according to GraphBinaryV4
+        final String outVLabel = (String) context.readValue(buffer, 
ArrayList.class, false).get(0);
 
         // discard the parent vertex
         context.read(buffer);
@@ -72,12 +77,13 @@ public class EdgeSerializer extends 
SimpleTypeSerializer<Edge> {
     protected void writeValue(final Edge value, final Buffer buffer, final 
GraphBinaryWriter context) throws IOException {
 
         context.write(value.id(), buffer);
-        context.writeValue(value.label(), buffer, false);
+        // serializing label as list here for now according to GraphBinaryV4
+        context.writeValue(Collections.singletonList(value.label()), buffer, 
false);
 
         context.write(value.inVertex().id(), buffer);
-        context.writeValue(value.inVertex().label(), buffer, false);
+        
context.writeValue(Collections.singletonList(value.inVertex().label()), buffer, 
false);
         context.write(value.outVertex().id(), buffer);
-        context.writeValue(value.outVertex().label(), buffer, false);
+        
context.writeValue(Collections.singletonList(value.outVertex().label()), 
buffer, false);
 
         // we don't serialize the parent Vertex for edges.
         context.write(null, buffer);
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/VertexPropertySerializer.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/VertexPropertySerializer.java
index dd3afbec05..7c0297cabf 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/VertexPropertySerializer.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/VertexPropertySerializer.java
@@ -28,6 +28,7 @@ import org.apache.tinkerpop.gremlin.structure.io.Buffer;
 import 
org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -44,7 +45,7 @@ public class VertexPropertySerializer extends 
SimpleTypeSerializer<VertexPropert
     protected VertexProperty readValue(final Buffer buffer, final 
GraphBinaryReader context) throws IOException {
         final DetachedVertexProperty.Builder builder = 
DetachedVertexProperty.build()
                 .setId(context.read(buffer))
-                .setLabel(context.readValue(buffer, String.class, false))
+                .setLabel((String) context.readValue(buffer, ArrayList.class, 
false).get(0))
                 .setValue(context.read(buffer));
 
         // discard the parent vertex - we only send "references"
@@ -61,7 +62,8 @@ public class VertexPropertySerializer extends 
SimpleTypeSerializer<VertexPropert
     @Override
     protected void writeValue(final VertexProperty value, final Buffer buffer, 
final GraphBinaryWriter context) throws IOException {
         context.write(value.id(), buffer);
-        context.writeValue(value.label(), buffer, false);
+        // serializing label as list here for now according to GraphBinaryV4
+        context.writeValue(Collections.singletonList(value.label()), buffer, 
false);
         context.write(value.value(), buffer);
 
         // we don't serialize the parent vertex, let's hold a place for it
diff --git 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/VertexSerializer.java
 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/VertexSerializer.java
index f25055e9a2..ea2a2e77d8 100644
--- 
a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/VertexSerializer.java
+++ 
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/VertexSerializer.java
@@ -28,6 +28,8 @@ import 
org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
 import 
org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertexProperty;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -41,7 +43,8 @@ public class VertexSerializer extends 
SimpleTypeSerializer<Vertex> {
     @Override
     protected Vertex readValue(final Buffer buffer, final GraphBinaryReader 
context) throws IOException {
         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 List<DetachedVertexProperty> properties = context.read(buffer);
 
         final DetachedVertex.Builder builder = 
DetachedVertex.build().setId(id).setLabel(label);
@@ -58,7 +61,8 @@ public class VertexSerializer extends 
SimpleTypeSerializer<Vertex> {
     @Override
     protected void writeValue(final Vertex value, final Buffer buffer, final 
GraphBinaryWriter context) throws IOException {
         context.write(value.id(), buffer);
-        context.writeValue(value.label(), buffer, false);
+        // serializing label as list here for now according to GraphBinaryV4
+        context.writeValue(Collections.singletonList(value.label()), buffer, 
false);
         if (value.properties() == null) {
             context.write(null, buffer);
         }

Reply via email to