Skip to content

Native insert_many: store a whole number that fits an int as an Integer, as the JVM build does - #496

Merged
tae898 merged 5 commits into
mainfrom
fix/445-insert-many-integer-types
Nov 26, 2026
Merged

tae898 merged 5 commits into
mainfrom
fix/445-insert-many-integer-types

Conversation

@tae898

@tae898 tae898 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

The same Python rows loaded with insert_many had other stored types on the two packages. arcadedb-jvm stores a whole number that fits 32 bits as an Integer, which is also how the engine's own JSON reader types it. arcadedb stored every one as a Long: at the top level, inside lists and maps, and with parallel=True. A JSONL export has to say which numbers are Long, so the same documents exported to longer text from a native database. The native build now stores the types of the JVM build.

insert_many value arcadedb-jvm arcadedb before arcadedb after
{"n": 7} INTEGER LONG INTEGER
{"n": 2**40} LONG LONG LONG
{"l": [1, 2**40]} INTEGER, LONG LONG, LONG INTEGER, LONG
{"n": 7, "x": float("nan")} LONG LONG LONG

The "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 Long on both, and insert_columns, insert_dataframe, and insert_arrow keep storing Long, also when they fall back to the row path.

The values read back in Python are the same. On disk the engine writes INTEGER and LONG with 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.adoc says which types both packages store, and upgrading.adoc states the changed behaviour.

Checklist

  • A regression test fails on the old code and passes on the new (tests/test_insert_many_integer_types.py; CI runs it on both wheels)
  • The test suite that the change can affect passes (CI, Linux x86-64: both wheels)
  • uvx pre-commit run --files <changed files> passes

…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.
@tae898 tae898 added bug Something isn't working python Pull requests that update python code native The arcadedb package (native library build) labels Nov 26, 2026
@tae898 tae898 self-assigned this Nov 26, 2026
@tae898
tae898 merged commit c1fcdb8 into main Nov 26, 2026
24 checks passed
@tae898
tae898 deleted the fix/445-insert-many-integer-types branch November 26, 2026 21:56
@github-actions github-actions Bot added this to the 26.12.1 milestone Nov 26, 2026
@tae898 tae898 mentioned this pull request Nov 30, 2026
1 of 10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working native The arcadedb package (native library build) python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parity: the same documents export to 1.27 times the text when insert_many ran on the native package

1 participant