Add GremlinLang number type suffixes and fix Long deserialization in JS GLV#3340
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3340 +/- ##
============================================
- Coverage 77.87% 75.49% -2.38%
+ Complexity 13578 13309 -269
============================================
Files 1015 1023 +8
Lines 59308 60252 +944
Branches 6835 7075 +240
============================================
- Hits 46184 45487 -697
- Misses 10817 12079 +1262
- Partials 2307 2686 +379 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
96e2774 to
42f474b
Compare
gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/gremlin-lang.ts
Outdated
Show resolved
Hide resolved
gremlin-js/gremlin-javascript/lib/structure/io/binary/internals/NumberSerializationStrategy.js
Show resolved
Hide resolved
|
Question: if a user inputs a number that is larger than the max long, it isn't suffixed to be a BigInteger? |
Correct. A user can't even input such a value accurately as a number in the first place, since JS number only has 53 bits of precision vs 63 bits for Java Long. Any integer-looking number beyond safe range has already lost precision, so it gets D. For true BigInteger, users need to use JS bigint type. |
42f474b to
f2d10b5
Compare
|
Thanks @kirill-stepanishin, the changes look great VOTE +1 |
|
VOTE +1 |
1 similar comment
|
VOTE +1 |
Adds proper Gremlin type suffixes to GremlinLang string generation and fixes precision loss in Long deserialization.
GremlinLang (
gremlin-lang.ts)42), beyond Int32 →Lsuffix (3000000000L)Dsuffix (3.14D)bigint→Nsuffix (5N), previously unhandledDLong deserialization (
LongSerializer.js)MIN_SAFE_INTEGER-MAX_SAFE_INTEGERnow returnBigIntinstead of a precision-losingNumberviaparseFloat()NumberSerializationStrategy fix
MIN_SAFE_INTEGER..MAX_SAFE_INTEGERboundsTest updates
Dsuffix on floatsbigint, Int32 boundaries, safe integer boundaries, and float suffixmax-long/min-longmodel values changed from impreciseNumberto exactBigIntmin-longmoved from byte-exact (run) to object-level (runWriteRead) — previously passed only because precision loss was symmetrical in both directions