Skip to content

MINOR: Respect ByteBuffer offset in Binary equality - #3701

Open
fallintoplace wants to merge 1 commit into
apache:masterfrom
fallintoplace:fix-binary-bytebuffer-equality-offset
Open

MINOR: Respect ByteBuffer offset in Binary equality#3701
fallintoplace wants to merge 1 commit into
apache:masterfrom
fallintoplace:fix-binary-bytebuffer-equality-offset

Conversation

@fallintoplace

Copy link
Copy Markdown

Rationale for this change

ByteBufferBackedBinary.equals(ByteBuffer, int, int) compares from index 0 instead of the binary’s stored offset. For direct buffers with a non-zero position, this can make equal values compare unequal and can also make different values compare equal when prefix bytes happen to match.

What changes are included in this PR?

Use the stored offset when comparing a ByteBufferBackedBinary with another ByteBuffer. Add regression coverage for equality symmetry, matching hash codes, and unequal values whose prefix bytes match.

Are these changes tested?

Yes. TestBinary passes with 16 tests, and the Spotless check passes.

Are there any user-facing changes?

Equality for direct ByteBuffer-backed binaries now uses the bytes represented by the binary slice.

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