Skip to content

GH-3869: Preserve destination state in single-buffer reads - #3870

Open
hutiefang76 wants to merge 1 commit into
apache:masterfrom
hutiefang76:frank/thirty-parquet-audit-20261020
Open

hutiefang76 wants to merge 1 commit into
apache:masterfrom
hutiefang76:frank/thirty-parquet-audit-20261020

Conversation

@hutiefang76

Copy link
Copy Markdown

Rationale for this change

A ByteBufferInputStream selected from one source buffer flips the caller's destination, while the same public API with multiple source buffers advances its position and preserves its limit. This breaks prefilled destinations and subsequent append reads depending on the source layout.

What changes are included in this PR?

Align the single-buffer read with the existing multi-buffer behavior: advance the destination by the copied count, preserve its limit, and leave it unchanged when there is no destination space or the stream is exhausted. Document the contract on the public method.

Are these changes tested?

The baseline has 12 single-buffer failures and 12 passing multi-buffer controls through both public wrap overloads. All 24 cases pass after the fix, covering partial/full copies, successive appends, heap/direct/sliced destinations, zero space and EOF.

Root ./mvnw -B clean verify passed on Microsoft OpenJDK 17.0.18 with Thrift 0.25.0: 2,914 tests, 0 failures/errors, 31 existing disabled or conditional skips (including optional Hadoop bridges and Windows-only checks). Spotless, Apache RAT and API compatibility checks stayed enabled.

Are there any user-facing changes?

Single-buffer reads now leave the destination ready for further writes, matching multi-buffer streams. Callers can flip it once after filling it. EOF returns -1 when the destination has room; a destination with no remaining space returns 0. Public signatures are unchanged.

Closes #3869.

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.

ByteBufferInputStream read flips the destination only for a single source buffer

1 participant