You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit fdf98ba
Browse filesBrowse the repository at this point in the historyBrowse files
buffered_table: cursor-into-storage stream finalize; data lives in storage
Replaces the unary buffered_table_finalize RPC with a cursor-driven
stream over the existing init machinery. Deletes the in-process
_buffered_table_finalize_iters dict, _ChainIter, and the entire unary
RPC handler. Also fixes the matching anti-pattern in streaming-shape
TableInOutFinalizeState (which held _batches: Transient that silently
truncated on HTTP).
Both finalize shapes now converge on one ProducerState
``BufferedFinalizeState`` whose entire wire payload is:
``(execution_id, ns, key, cursor, attach_opaque_data)``.
``produce()`` cold-builds BoundedStorage per tick, scans the next page
of the (ns, key) state_log past cursor, emits batches, advances the
cursor. No per-tick user code; no batches in stream state ever.
User contract changes:
* Buffered fixtures (``Meta.buffered_table=True``) now declare which
state_log to drain via a new ``finalize_log_key()`` classmethod.
Default returns ``(b"buf", pack_int_key(state_id))`` — exactly
where ``process()`` already writes via ``state_append``.
* The ``finalize()`` override (yield-based) is GONE for buffered
fixtures. Functions that needed sort or merge (BatchIndexBuffer,
SumAllColumns, LargeState) now do that work in ``combine()`` and
write the consolidated output as a NEW state_log under
``b"buf_sorted"``; ``finalize_log_key()`` points the framework at it.
* CrashOnFinalizeFunction reframes: combine() drops a malformed
payload into the log; the framework's source-phase _decode_ipc_batch
raises (replaces the prior "user finalize raises" path).
Streaming-shape TableInOut finalize (non-buffered):
* ``finalize(params) -> list[batch]`` user API unchanged.
* Worker init handler materializes the returned list into BoundedStorage
via ``state_append(b"streaming_finalize", ...)`` at init time, then
hands ``BufferedFinalizeState`` to vgi-rpc for the source-phase drain.
* Removes the ``_batches: Transient list`` field that was breaking
streaming finalize on HTTP transport.
Storage primitive:
* ``state_log_scan`` extends with ``after_id`` (default -1) and
``limit`` (default None) kwargs; return type widens from
``list[bytes]`` to ``list[tuple[int, bytes]]`` so callers can use
the id as the next cursor. Existing callers updated; new tests
cover paged drain with after_id+limit on all three backends.
Wire/protocol:
* New ``InitRequest.finalize_state_id: int | None`` field; required
when ``phase=BUFFERED_TABLE_FINALIZE``.
* New ``TableInOutFunctionInitPhase.BUFFERED_TABLE_FINALIZE`` enum value.
* ``BufferedTableFinalizeRequest``/``BufferedTableFinalizeResponse``
+ ``VgiProtocol.buffered_table_finalize`` method DELETED.
* MetaWorker dispatcher entry deleted.
Cursor helpers (``vgi.table_in_out_function``):
* ``pack_int_cursor(int) -> bytes`` / ``unpack_int_cursor(bytes) -> int``
— canonical encoding for log-id cursors.
Worker module-level helpers (vgi/worker.py):
* ``_build_bound_storage_from_fields(execution_id, attach, ctx)`` —
cold-build per tick, no func_cls dependency.
* ``_decode_ipc_batch(value)`` — wraps ``pa.ipc.open_stream``.
* ``_FINALIZE_PREFETCH = 8`` and ``_STREAMING_FINALIZE_KEY``.
Tests:
* All 27 buffered_table integration tests pass on the new path.
* All Python storage tests pass (existing + new for after_id/limit).
* mypy clean. ruff clean.
* vgi-python suite: 30 failed / 1657 passed (baseline-equivalent;
+5 net passes from new state_log_scan tests).
C++ side wires up in the next commit (PerformInit kwarg + Source phase
rewire + delete unary RPC).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments