Skip to content

feat(read): decouple read batch lifetime from readers - #260

Open
lxy-9602 wants to merge 4 commits into
apache:mainfrom
lxy-9602:decouple-readbatch-batchreader
Open

feat(read): decouple read batch lifetime from readers#260
lxy-9602 wants to merge 4 commits into
apache:mainfrom
lxy-9602:decouple-readbatch-batchreader

Conversation

@lxy-9602

Copy link
Copy Markdown
Member

Purpose

Linked issue: close #259

Arrow and ORC buffers may be allocated from memory-pool adaptors owned by BatchReader. Because these buffers still access their allocator when they are released, Paimon previously required the BatchReader to outlive every ReadBatch returned by it.

This lifetime constraint couples readers with their returned batches and makes integration with downstream engines inconvenient and error-prone, as described in alibaba/paimon-cpp#126.

This PR removes that lifetime constraint for batches represented through the Arrow C Data Interface.
The memory-pool resources used by a batch, including Arrow and ORC pools, are retained by the root ArrowArray. They remain alive until the corresponding ArrowArray::release callback finishes. Therefore, a returned batch can safely outlive its BatchReader.

Consumers must treat the root ArrowArray as a complete ownership unit: keep, move, and release the entire structure through the Arrow C Data Interface. Moving individual child arrays out of the root ArrowArray is unsupported because those children do not independently retain the batch’s memory-pool lifetime.

Tests

API and Format

API impact:

  • TableRead::CreateReader(const std::vector<std::shared_ptr<Split>>&) is now
    pure virtual, so concrete TableRead implementations must implement it.
  • The BatchReader and ReaderBuilder lifetime contracts are explicitly documented.

Documentation

Generative AI tooling

Generated-by: Codex (GPT-5)

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.

[Improvement] Decouple ReadBatch lifetime from BatchReader

1 participant