Skip to content

refactor: de-duplicate the streaming write_lance commit path#5197

Open
LuciferYang wants to merge 1 commit into
lance-format:mainfrom
LuciferYang:refactor/streaming-write-dedup
Open

refactor: de-duplicate the streaming write_lance commit path#5197
LuciferYang wants to merge 1 commit into
lance-format:mainfrom
LuciferYang:refactor/streaming-write-dedup

Conversation

@LuciferYang

Copy link
Copy Markdown

The streaming write_lance path (one fragment committed per batch) had grown repetitive: the "reopen the dataset to read its new version" block was copy-pasted four times, the create-mode initial_bases expression appeared twice, and the first-commit branch had a third arm that was unreachable for any valid mode.

This pulls the reopen logic into two helpers — _open_lance_version, and _refresh_version which keeps the previous version if the reopen fails — computes the overwrite bases once, and collapses the first-commit handling into "append onto an existing dataset, otherwise overwrite". The local import lance goes away since the top-level LanceDataset is already used everywhere.

Behavior is unchanged for create, append, and overwrite — I diffed the streaming output and version progression against the old code across create / append / overwrite / overwrite-into-a-new-path / resume and they match exactly. Added a streaming create-then-append test alongside the existing blob streaming coverage.

The streaming path repeated the open-dataset-to-read-version block four
times and the create-mode initial_bases expression twice. Extract
_open_lance_version / _refresh_version helpers, compute the overwrite
initial bases once, and collapse the first-commit branches (the old
three-way branch had an unreachable overwrite fallback for valid modes).
Behavior is unchanged for create/append/overwrite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant