Repository navigation
Native insert_many: store a whole number that fits an int as an Integer, as the JVM build does - #496
Merged
Merged
Conversation
…er, as the JVM build does The engine's JSON reader types a whole number as an Integer when it fits an int and as a Long beyond, and the JVM build keeps that on both of its insert_many routes. The native build read every whole number as a Long, at the top level, inside lists and maps, and with parallel=True. The same rows had other stored types on the two packages, and a JSONL export of the native database was longer because it has to say which numbers are Long. The native library now narrows on the three routes insert_many uses (columns, JSON rows, parallel rows). A row that JSON text cannot carry keeps Long, as on the JVM build, and insert_columns still stores int64 columns as Long. A test reads the stored types through SQL on both wheels.
…DataFrame paths keeps Long On the native build a column set the buffers cannot carry goes down insert_many's row path. On the JVM build those entry points store Long, so the narrowing is now a flag that only insert_many sets, down to the JSON entry and the parallel writers.
…he native package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
The same Python rows loaded with
insert_manyhad other stored types on the two packages.arcadedb-jvmstores a whole number that fits 32 bits as anInteger, which is also how the engine's own JSON reader types it.arcadedbstored every one as aLong: at the top level, inside lists and maps, and withparallel=True. A JSONL export has to say which numbers areLong, so the same documents exported to longer text from a native database. The native build now stores the types of the JVM build.insert_manyvaluearcadedb-jvmarcadedbbeforearcadedbafter{"n": 7}INTEGERLONGINTEGER{"n": 2**40}LONGLONGLONG{"l": [1, 2**40]}INTEGER,LONGLONG,LONGINTEGER,LONG{"n": 7, "x": float("nan")}LONGLONGLONGThe "before" column is read from the code. The new test reads the stored types with the SQL method
type()on both wheels.What does not change: a declared property keeps its declared type, a row that JSON text cannot carry (such as one with a NaN) keeps
Longon both, andinsert_columns,insert_dataframe, andinsert_arrowkeep storingLong, also when they fall back to the row path.The values read back in Python are the same. On disk the engine writes
INTEGERandLONGwith the same variable-length number encoding (BinarySerializer, read from the code), so I expect no difference in record size.Related issues
Closes #445.
Performance changes
None claimed, and I did not time it. The native library now walks the lists and maps of a row once more before it stores them.
Docs
bulk-loads.adocsays which types both packages store, andupgrading.adocstates the changed behaviour.Checklist
tests/test_insert_many_integer_types.py; CI runs it on both wheels)uvx pre-commit run --files <changed files>passes