Skip to content

Column frames: rid and list-of-number columns travel in binary kinds, not JSON - #394

Merged
tae898 merged 3 commits into
mainfrom
perf/388-frame-rid-list-kinds
Nov 22, 2026
Merged

tae898 merged 3 commits into
mainfrom
perf/388-frame-rid-list-kinds

Conversation

@tae898

@tae898 tae898 commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

A column of record links or of lists of numbers inside a binary column frame was one tagged JSON array of the column (the json kind), parsed per cell in Python. This is rank 10 of #388. The JVM writer (ColumnBatcher of the bridge jar) now writes two more column kinds, and the one shared decoder arcadedb/_columnar.py reads them. The native writer (ColumnFrames of the native image) is in #450, stacked on this pull request, so this one changes no native code:

  • rid: two int64 per row, the bucket and the position of a record link. to_arrow gives a string column of #bucket:position, as the column of RID objects degraded to before. to_columns and to_dataframe give the wheel's own RID object: the native wheel builds its RID from the pair, and the JVM bridge puts the engine's RID objects into the side array in row order (the header names where they start, side), so the JVM wheel still hands out the engine's own RID, which a bucket and a position cannot be turned back into on the Python side without the database. to_arrow never touches the side array.
  • li8 and lf8: a list of int64 or of float64 per row. The buffer is int32 offsets (rows + 1), a bitmap with one bit per element of the flat array for a null element, then the flat int64 or float64 array of every list's elements. A null row is the frame's null bit, an empty list is two equal offsets, None inside a list is a bit of the bitmap. NaN, the infinities and -0.0 are float64 values. to_columns gives Python lists of exact int or float, to_arrow gives list<int64> or list<double> over the frame's own offsets and flat array.

What keeps the json kind: maps, nested lists, lists of strings, booleans or RIDs, a list that mixes ints and floats (each element keeps its own type there), a list of nothing but nulls or empty lists (Arrow types it list<null>, an element type cannot be read from it), embedded records, a RID that is not valid (negative bucket or position), a column that mixes kinds (a column of int lists in one row and float lists in another is json), Set, primitive arrays, and a column with more than 2**27 list elements in one frame (int32 offsets). The decoder keeps reading json for RID and list columns, so a frame of an older writer still decodes. The first 256 rows of a native result are written as a frame in Python from the JSON reply (the values themselves, json kind); that code is unchanged, and the decoder gives the same values and the same Arrow types for both forms.

Related issues

Refs #388 and #315.

Performance changes

Measured with a paired A/B on the mini: arcadedb-jvm 26.11.1.post4 with the Python files of src/arcadedb and the bridge jar swapped per arm (the jar compiled from each arm's src/java against the wheel's own jars): A is the tip of main 076d6d5674, B is this PR f1ec4a3c6c, and C is A again as the control. 16 rounds, one JVM and one fresh database per arm and round, interleaved cycles, the trimmed mean of the timed reads per case, a bootstrap 95% interval over the rounds, and the rule of #317, read row by row: a row counts only when its own control is inside 0.97 to 1.03. The process was confined to the two cores of one compare lane of the mini (Cpus_allowed_list: 0,2), no other study ran, and the host worker recorded 0 ms of thermal throttle.

to_arrow and to_polars Shape Rows Rows read B/A, rows read (lowest to highest) B/A, every row incl. not read (lowest to highest)
rid 1 1 of 2 0.784 to 0.784 0.784 to 0.869
rid 100 to 100,000 4 of 6 0.209 to 0.439 0.209 to 0.571
link 1 0 of 2 none 0.789 to 0.883
link 100 to 100,000 5 of 6 0.218 to 0.447 0.218 to 0.563
intlist 1 1 of 2 0.960 to 0.960 0.957 to 0.960
intlist 100 to 100,000 1 of 6 0.629 to 0.629 0.321 to 0.762
floatlist 1 0 of 2 none 0.915 to 0.922
floatlist 100 to 100,000 0 of 6 none 0.224 to 0.550
to_columns and to_dataframe Shape Rows Rows read B/A, rows read (lowest to highest) B/A, every row incl. not read (lowest to highest)
rid 1 1 of 2 0.971 to 0.971 0.964 to 0.971
rid 100 to 100,000 2 of 5 0.800 to 0.875 0.782 to 0.875
link 1 2 of 2 0.950 to 0.979 0.950 to 0.979
link 100 to 100,000 2 of 5 0.811 to 0.872 0.789 to 0.872
intlist 1 2 of 2 0.981 to 0.987 0.981 to 0.987
intlist 100 to 100,000 2 of 5 0.871 to 0.930 0.871 to 1.019
floatlist 1 0 of 2 none 0.958 to 0.977
floatlist 100 to 100,000 0 of 5 none 0.483 to 0.650
  • Not a result by the rule for most rows. 71 of the 105 rows have a control outside 0.97 to 1.03, among them 34 of the 45 rows that must not move. A read of 100,000 rows takes tens to hundreds of milliseconds and the interval of its control is often wider than the band. The study's own exit status is 3 for that reason. I show every row because the effect is many times the control's spread.
  • to_arrow and to_polars, record links and RIDs: at 100 rows B/A is 0.439 to 0.571 over 4 rows (2 readable: 0.439 to 0.447); at 100,000 rows 0.209 to 0.239 over 8 rows (7 readable: 0.209 to 0.239).
  • to_arrow and to_polars, lists of integers and of floats: at 100,000 rows B/A is 0.321 to 0.361 over 4 rows (none readable) for integers and 0.224 to 0.228 over 4 rows (none readable) for floats.
  • to_columns and to_dataframe, record links and RIDs: at 100 rows and more B/A is 0.782 to 0.875 over 10 rows (4 readable: 0.800 to 0.875).
  • to_columns and to_dataframe, lists: floats 0.483 to 0.650 over 5 rows (none readable); integers at 100,000 rows 0.939 to 1.019 over 3 rows (none readable). Integer lists are the one shape that does not gain at 100,000 rows in the objects family, which I expected from reading the decoder (it slices per row in Python and json.loads is C), not from a measurement of the decoder.
  • Reads of 1 row: B/A is 0.950 to 0.987 over 8 rows (5 readable: 0.950 to 0.987) in the objects family and 0.784 to 0.960 over 8 rows (2 readable: 0.784 to 0.960) in the Arrow family: the gain is small or absent at that size.
  • The controls (a map, a nested list and a scalar-only result, which keep the json kind): B/A is 0.941 to 1.056 over 45 rows (11 readable: 0.976 to 0.999). No row points to a regression.
  • The frame kinds were counted, not timed: A and C get json frames, B gets rid, li8 and lf8 where this PR writes them, and the values and Arrow types every reader returns are equal in all arms.

Limits: one host and one run of 16 rounds; the JVM wheel only (the native writer is a separate pull request, #450, stacked on this one); a small result table of one @rid or link column, an 8-element list, or a scalar column, per shape.

The figure as registered before the run: the operation is a columnar read of one query through to_columns(), to_arrow(), to_dataframe() and to_polars(), one read of the whole result per operation, at 1, 100 and 100,000 rows plus a batch_size that splits 100,000 rows into 10 frames, for a SELECT @rid column, a link property, an int list column and a float list column, with the shapes that keep json (a map, a nested list, a scalar-only result) as controls.

Docs

No page under docs/ or README.md describes the frame kinds; the module docstrings of arcadedb/_columnar.py, ColumnFrames.java and ColumnBatcher.java and the one of arcadedb/_native/colframes.py are updated.

How I checked it

  • tests/test_column_frames.py (hand-built frames, no database): rid, li8 and lf8 with nulls, empty lists, None inside, NaN, the infinities, -0.0 and integers beyond 2**53; the decoder against the JSON form of the same column (values, Python types, Arrow type); the hook that makes the RID objects; and a json frame of RIDs, lists and maps still reads. Six of the seven fail on the decoder of the tag.
  • tests/test_frame_rid_list_kinds.py (both wheels, no branch on the backend except the stored output): which kind each shape gets, read from the frame headers (this fails while a writer still writes json), the four readers against the row route (to_list) cell by cell including the type and text of every RID, and against the stored output of the released wheels.
  • The Java was not compiled on my machine (no local build, per the bench rules): the two CI runs below are the first compile.

Checklist

  • A regression test fails on the old code and passes on the new (decoder tests: checked against the tag's decoder; writer tests: by their construction, they read the frame kinds the tag's writers do not write)
  • The test suite that the change can affect passes (CI: native and JVM runs dispatched on this branch)
  • uvx pre-commit run --files <changed files> passes

@tae898 tae898 added jvm The arcadedb-jvm package (JPype build) native The arcadedb package (native library build) performance Speed or memory of the bindings, with a measurement python Pull requests that update python code labels Nov 14, 2026
@tae898 tae898 self-assigned this Nov 14, 2026
@tae898
tae898 force-pushed the perf/388-frame-rid-list-kinds branch from 54cf84a to b04e107 Compare November 14, 2026 07:04
@tae898
tae898 force-pushed the perf/388-frame-rid-list-kinds branch from 3a341c5 to 6ab2265 Compare November 22, 2026 18:48
…#388, #315)

A RID, a list, a map or a mixed column was one tagged JSON array of the column (the json kind), parsed per cell in Python. The decoder now also reads rid (bucket and position, two int64 per row) and li8 or lf8 (int32 offsets, a bitmap of null elements, one flat int64 or float64 array) and still reads json for those columns, so a frame of an older writer decodes as before.

to_columns gives Python lists of exact int or float and, for a rid column, the wheel's own RID object (the native wheel builds its RID from the pair; the JVM bridge puts the engine's RID objects into a side array in row order, so the JVM wheel still hands out the engine's own RID). to_arrow gives a string column of #bucket:position for RIDs, as the column of RID objects degraded to before, and list<int64> or list<double> over the frame's own offsets and flat array for the lists, with no per-element Python object. The head frame the native wheel writes in Python for the first reply is unchanged (json, the values themselves).

tests/test_column_frames.py builds frames by hand (no database) and decodes them: rid, li8 and lf8 with nulls, empty lists, None inside, NaN, the infinities, -0.0 and integers beyond 2**53, against the JSON form of the same column, and a json frame of RIDs, lists and maps still reads.
The bridge jar wrote a column of record links and a column of lists as one tagged JSON array (json). It now writes rid for a column of valid RIDs (two int64 per row, and the engine's RID objects go into the side array in row order from the index the column header names as side) and li8 or lf8 for a column of lists of integers or of floats (int32 offsets, a bitmap of null elements, one flat int64 or float64 array). Maps, nested lists, lists of strings, booleans or RIDs, lists that mix ints and floats, a list of nothing but nulls, an invalid RID (negative bucket or position), a column that mixes kinds and a column with more than 2**27 list elements in one frame stay json.

The decoder of the commit before reads both forms. The native library's writer is not part of this change.
… output of the released wheels (refs #388, #315)

tests/test_frame_rid_list_kinds.py reads the kind of each column from the frame headers (KINDS says per writer what it writes: the JVM bridge the new kinds, the native library json), compares the four columnar readers with the row route (to_list) cell by cell including the type and text of every RID, and with the stored output of the released wheels. A binary column has to show its kind in at least one frame and be json or that kind in all, because a read ends with an empty frame and the native wheel decodes its Python-written head frame (always json) after the library's frames.

tests/fixtures/frame_kinds_post3.json is the output of the released 26.11.1.post3 wheels (JSON route, one entry per wheel) for the tables of the test, dumped before the change by a throwaway run on a branch cut from the tag and never generated from this code. It holds the type, the row count and the sha256 of the exact values per column: the first dump also had a 24-value sample per column, which a script deleted (a key removed, nothing recomputed), and the file is formatted with prettier as the pre-commit check of main requires.
@tae898

tae898 commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

I rebased this onto main, trimmed its test fixture from 25,750 to 1,540 lines (the sample values are gone, the type, count and checksum of every column stay), split the native writer out into #450, and timed it. Setup: arcadedb-jvm 26.11.1.post4 with the Python files of src/arcadedb and the bridge jar swapped per arm (the jar compiled from each arm's src/java against the wheel's own jars): A is the tip of main 076d6d5674, B is this PR f1ec4a3c6c, and C is A again as the control. 16 rounds, one JVM and one fresh database per arm and round, interleaved cycles, the trimmed mean of the timed reads per case, a bootstrap 95% interval over the rounds, and the rule of #317, read row by row: a row counts only when its own control is inside 0.97 to 1.03. The process was confined to the two cores of one compare lane of the mini (Cpus_allowed_list: 0,2), no other study ran, and the host worker recorded 0 ms of thermal throttle.

to_arrow and to_polars Shape Rows Rows read B/A, rows read (lowest to highest) B/A, every row incl. not read (lowest to highest)
rid 1 1 of 2 0.784 to 0.784 0.784 to 0.869
rid 100 to 100,000 4 of 6 0.209 to 0.439 0.209 to 0.571
link 1 0 of 2 none 0.789 to 0.883
link 100 to 100,000 5 of 6 0.218 to 0.447 0.218 to 0.563
intlist 1 1 of 2 0.960 to 0.960 0.957 to 0.960
intlist 100 to 100,000 1 of 6 0.629 to 0.629 0.321 to 0.762
floatlist 1 0 of 2 none 0.915 to 0.922
floatlist 100 to 100,000 0 of 6 none 0.224 to 0.550
to_columns and to_dataframe Shape Rows Rows read B/A, rows read (lowest to highest) B/A, every row incl. not read (lowest to highest)
rid 1 1 of 2 0.971 to 0.971 0.964 to 0.971
rid 100 to 100,000 2 of 5 0.800 to 0.875 0.782 to 0.875
link 1 2 of 2 0.950 to 0.979 0.950 to 0.979
link 100 to 100,000 2 of 5 0.811 to 0.872 0.789 to 0.872
intlist 1 2 of 2 0.981 to 0.987 0.981 to 0.987
intlist 100 to 100,000 2 of 5 0.871 to 0.930 0.871 to 1.019
floatlist 1 0 of 2 none 0.958 to 0.977
floatlist 100 to 100,000 0 of 5 none 0.483 to 0.650
  • Not a result by the rule for most rows. 71 of the 105 rows have a control outside 0.97 to 1.03, among them 34 of the 45 rows that must not move. A read of 100,000 rows takes tens to hundreds of milliseconds and the interval of its control is often wider than the band. The study's own exit status is 3 for that reason. I show every row because the effect is many times the control's spread.
  • to_arrow and to_polars, record links and RIDs: at 100 rows B/A is 0.439 to 0.571 over 4 rows (2 readable: 0.439 to 0.447); at 100,000 rows 0.209 to 0.239 over 8 rows (7 readable: 0.209 to 0.239).
  • to_arrow and to_polars, lists of integers and of floats: at 100,000 rows B/A is 0.321 to 0.361 over 4 rows (none readable) for integers and 0.224 to 0.228 over 4 rows (none readable) for floats.
  • to_columns and to_dataframe, record links and RIDs: at 100 rows and more B/A is 0.782 to 0.875 over 10 rows (4 readable: 0.800 to 0.875).
  • to_columns and to_dataframe, lists: floats 0.483 to 0.650 over 5 rows (none readable); integers at 100,000 rows 0.939 to 1.019 over 3 rows (none readable). Integer lists are the one shape that does not gain at 100,000 rows in the objects family, which I expected from reading the decoder (it slices per row in Python and json.loads is C), not from a measurement of the decoder.
  • Reads of 1 row: B/A is 0.950 to 0.987 over 8 rows (5 readable: 0.950 to 0.987) in the objects family and 0.784 to 0.960 over 8 rows (2 readable: 0.784 to 0.960) in the Arrow family: the gain is small or absent at that size.
  • The controls (a map, a nested list and a scalar-only result, which keep the json kind): B/A is 0.941 to 1.056 over 45 rows (11 readable: 0.976 to 0.999). No row points to a regression.
  • The frame kinds were counted, not timed: A and C get json frames, B gets rid, li8 and lf8 where this PR writes them, and the values and Arrow types every reader returns are equal in all arms.

Limits: one host and one run of 16 rounds; the JVM wheel only (the native writer is a separate pull request, #450, stacked on this one); a small result table of one @rid or link column, an 8-element list, or a scalar column, per shape.

I am updating the description with this and taking the PR out of draft so CI runs on it.

@tae898 tae898 added this to the 26.12.1 milestone Nov 22, 2026
@tae898
tae898 marked this pull request as ready for review November 22, 2026 20:11
@tae898
tae898 merged commit 7eb22cc into main Nov 22, 2026
40 checks passed
@tae898
tae898 deleted the perf/388-frame-rid-list-kinds branch November 22, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jvm The arcadedb-jvm package (JPype build) native The arcadedb package (native library build) performance Speed or memory of the bindings, with a measurement python Pull requests that update python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant