SebastianGruza commented on code in PR #771:
URL: 
https://github.com/apache/hugegraph-toolchain/pull/771#discussion_r4074509702


##########
hugegraph-loader/src/main/java/org/apache/hugegraph/loader/util/JsonUtil.java:
##########
@@ -47,6 +48,15 @@ public final class JsonUtil {
     private static final Logger LOG = Log.logger(JsonUtil.class);
     private static final ObjectMapper MAPPER = new ObjectMapper();
 
+    static {
+        /*
+         * Read JSON fraction literals as BigDecimal: a DECIMAL column keeps
+         * every digit (a double would keep 17), the other numeric types are
+         * narrowed by DataTypeUtil as before.
+         */
+        MAPPER.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);

Review Comment:
   Good catch, thanks: that would have been a silent id change on reload. Done 
in the form you propose: the TEXT branch of `parseSingleValue` formats a 
`BigDecimal` through `Double.toString(((BigDecimal) value).doubleValue())`, 
i.e. exactly the string the Double path produced. 
`testConvertDecimalFromJsonLine` now has a TEXT case with your three literals 
plus an integer: `1.50 -> "1.5"`, `1e-7 -> "1.0E-7"`, `12345678901.0 -> 
"1.2345678901E10"`, `7 -> "7"`. The comment above the flag now speaks about all 
target types.
   



##########
hugegraph-client/src/main/java/org/apache/hugegraph/structure/constant/DataType.java:
##########
@@ -33,7 +35,12 @@ public enum DataType {
     TEXT(8, "text", String.class),
     BLOB(9, "blob", byte[].class),
     DATE(10, "date", Date.class),
-    UUID(11, "uuid", UUID.class);
+    UUID(11, "uuid", UUID.class),
+    /*
+     * Arbitrary-precision decimal (java.math.BigDecimal), stored exactly by
+     * the server; sent and received as a plain decimal string in JSON

Review Comment:
   Done: "sent as a plain JSON number (BigDecimal.toPlainString(), every 
digit), returned by the server as a plain decimal string; new 
BigDecimal(String) restores it exactly".
   



-- 
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