Improve Buffer documentation, deprecate Buffer::from_bytes add From<Bytes> and From<bytes::Bytes> impls#6939
Merged
alamb merged 5 commits intoapache:mainfrom Jan 6, 2025
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Buffer::from_bytestakes unexportedBytes#6754Buffer::from_bytes#6920 from @kylebarronByteViewArrayDecoderPlain#6930 from @XiangpengHaoRationale for this change
As described by @tv42 #6754 and @kylebarron in #6930 creating
Buffers in a zero copy way is confusing, I have also been personally confused byBytesandbytes::BytesdifferenceAlso, the fact it is not clear how to make a
Bufferin a zero copy manner lead to unintended copies as described by @XiangpengHao inByteViewArrayfrom parquet by removing an implicit copy #6031At least part of this confusion is that
Bytesis an internal (non pub) struct that is named the same asbytes::Bytesbut appears in the public APII would like to make the whole situation less confusing
What changes are included in this PR?
Bytesmaking it clear it is internal and how it is related tobytes::BytesBufferand add examples of how to constructBufferfromVecandbytes::BytesFromimpls to make it easier to createBufferin zero copy manner (used in examples)from_bytesto close Public API using private types:Buffer::from_bytestakes unexportedBytes#6754Are there any user-facing changes?
Fromimpls forBuffer