Skip to content
This repository was archived by the owner on Nov 21, 2026. It is now read-only.

bindings: to_list() ends a batch at 4 MiB of JSON, so wide rows no longer need the whole batch in the heap - #320

Merged
tae898 merged 1 commit into
mainfrom
fix/typed-rows-batch-bytes
Oct 13, 2026
Merged

tae898 merged 1 commit into
mainfrom
fix/typed-rows-batch-bytes

Conversation

@tae898

@tae898 tae898 commented Oct 13, 2026

Copy link
Copy Markdown

Fixes #319.

TypedRows.nextRows now ends a batch once its JSON text reaches 4 MiB of characters (MAX_BATCH_CHARS) and returns a third element, drained. A short batch no longer means a drained result set, so _to_list_typed stops on drained instead of on len(rows) < _TYPED_BATCH_ROWS, and the bridge closes the result set only when it is drained. iter_dicts() reads one row per call and is unchanged.

Checked before the push, on cores 8-9 with the repository's own tests run against a wheel built from this branch's sources plus a bridge jar compiled from them (corretto 25):

  • The two new tests fail on main (the batch is 16 MB for 40 rows of 400 KB, and the old call has no third element) and pass here; test_typed_rows.py, test_resultset.py, test_percall_calls.py, test_core.py, test_resultset_read_errors.py, and test_results_after_close.py pass (140 and 125 tests).
  • The repro of ResultSet.to_list() batches 1,000 rows into one JSON text whatever their size, so wide rows raise OutOfMemoryError that iter_dicts() does not #319 (400 rows of 1 MiB, 1 GiB heap) reads all 400 rows through to_list(); main raises OutOfMemoryError. The existing batch-boundary tests (1, 999, 1000, 1001, 2000, 2500 rows, and the call counts of a short and an exact-batch result) still pass, so narrow rows still cross 1,000 at a time.
  • pre-commit on the changed files and mkdocs build --strict pass.

Swept: to_list() is the only caller of TypedRows.nextRows with a batch; the docs that describe the batch (bridge.md, performance.md, results.md) say what changed, and to_json_list() and iter_json_batches() now say that their batch_size bounds rows and not bytes. to_json_list() itself is not changed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01222vQiEr2wJRo4UhFYo9Fv

…nger need the whole batch in the heap (Fixes #319)

TypedRows.nextRows wrote up to 1,000 rows as one JSON text whatever their size, so 400 rows of 1 MiB raised OutOfMemoryError in a 1 GiB heap where iter_dicts() and the pre-#286 to_list() read them. A batch now ends once its text reaches 4 MiB of characters and the call returns a third element, drained, because a short batch no longer means a drained result set. Python stops on drained.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01222vQiEr2wJRo4UhFYo9Fv
@tae898
tae898 merged commit a9577f7 into main Oct 13, 2026
72 of 74 checks passed
@tae898
tae898 deleted the fix/typed-rows-batch-bytes branch October 13, 2026 20:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ResultSet.to_list() batches 1,000 rows into one JSON text whatever their size, so wide rows raise OutOfMemoryError that iter_dicts() does not

1 participant