bitflicker64 commented on code in PR #3209:
URL: https://github.com/apache/hugegraph/pull/3209#discussion_r4174926263


##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/io/HugeGraphSONModule.java:
##########
@@ -755,18 +760,14 @@ public void 
writePropertiesField(Collection<HugeProperty<?>> properties,
                 String key = property.key();
                 Object val = property.value();
                 try {
-                    generator.writeFieldName(key);
-                    if (val != null) {
-                        JsonSerializer<Object> serializer =
-                                provider.findValueSerializer(val.getClass());
-                        serializer.serialize(val, generator, provider);
-                    } else {
-                        generator.writeNull();
-                    }
+                    // The provider contextualizes the serializer: a bare
+                    // findValueSerializer() returns a Map serializer without
+                    // its key serializer, so an OBJECT map value failed here
+                    provider.defaultSerializeField(key, val, generator);

Review Comment:
   Important: `defaultSerializeField()` goes through 
`findTypedValueSerializer()`, so on the typed GraphSON v2/v3 mappers 
(gremlin-server.yaml registers HugeGraphIoRegistry for 
`GraphSONMessageSerializerV2d0`/`V3d0`) every scalar property of every vertex 
and edge now gets a type wrapper. On master `"age":29` is written as a bare 
value inside the `hugegraph:HugeVertex` object; at this head it becomes 
`"age":{"@type":"g:Int32","@value":29}`. The same applies to Long, Double and 
Date values. Graphs with no DECIMAL or OBJECT keys see this too, so existing 
GraphSON v2/v3 clients get a different payload for ordinary `g.V()` results, 
which the PR description does not mention.
   
   Evidence: a standalone probe on gremlin-core/gremlin-shaded 3.5.1 with a 
TinkerPopJacksonModule serializer shaped like `writePropertiesField()`. The 
master form (`findValueSerializer(cls).serialize(...)`) gives 
`{"age":29,"big":5,"score":1.5}` on V2_0 and V3_0 with PARTIAL_TYPES. The form 
at this head gives 
`{"age":{"@type":"g:Int32","@value":29},"big":{"@type":"g:Int64","@value":5},"score":{"@type":"g:Double","@value":1.5}}`.
 GraphSON v1 and the REST mapper (untyped) are unchanged.
   
   Requested change: keep the contextualized serializer but leave out the type 
wrapper, for example `generator.writeFieldName(key)` followed by 
`provider.findValueSerializer(val.getClass(), null).serialize(val, generator, 
provider)` (null still writes `writeNull()`). In the same probe that variant 
fixes the v1 map case and gives master's bare scalars on v2. Please also add a 
`HugeGraphSONModuleTest` case that serializes a vertex with an INT property 
through `GraphSONMessageSerializerV2d0` with HugeGraphIoRegistry and asserts 
the property value is not wrapped.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to