API, Core: Reuse VariantUtil methods through ByteBuffers#16748
Merged
Conversation
nssalian
reviewed
Jun 9, 2026
nssalian
reviewed
Jun 10, 2026
| return buffer.getLong(buffer.position() + offset); | ||
| } | ||
|
|
||
| static float readFloat(ByteBuffer buffer, int offset) { |
Collaborator
There was a problem hiding this comment.
should readFloat and readDouble be moved as well?
Contributor
Author
There was a problem hiding this comment.
I don't think so because they are only used here. We can always move them later, but these weren't shared originally because we didn't have other parts of the codebase that needed them.
| public void testRead3ByteUnsigned() { | ||
| ByteBuffer buffer = ByteBuffer.wrap(new byte[] {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF}); | ||
| assertThat(ByteBuffers.readLittleEndianUnsigned(buffer, 0, 3)).isEqualTo(16777215); | ||
| } |
Collaborator
There was a problem hiding this comment.
worth adding tests for the other methods too. I think the variant tests would exercise these indirectly but good to have unit tests.
amogh-jahagirdar
left a comment
Contributor
There was a problem hiding this comment.
Change looks fundamentally right to me, but I think the license formatting issue that @nssalian pointed out in TestByteBuffers is legitimate
amogh-jahagirdar
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This refactors some methods in
VariantUtilintoByteBuffersso they can be reused for the new bitmap implementation in #16747.This also removes
VariantUtil.writeBufferAbsolutethat is no longer needed becauseByteBuffernow has a method to write another buffer to an absolute position. All uses of this method have been replaced withByteBuffer.put(int, ByteBuffer, int, int).