fix array type strategy write size tracking#12150
Merged
suneet-s merged 2 commits intoapache:masterfrom Jan 13, 2022
Merged
Conversation
abhishekagarwal87
approved these changes
Jan 13, 2022
suneet-s
approved these changes
Jan 13, 2022
sachinsagare
pushed a commit
to sachinsagare/druid
that referenced
this pull request
Nov 3, 2022
* fix array type strategy write size tracking * fix checkstyle (cherry picked from commit 1dba089)
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.
Description
This PR fixes a bug introduced in #11888 for the ARRAY type strategy write method, where the size tracking of remaining buffer space had a silly math bug that made size tracking go wildly wrong the longer the array was. I was incorrectly subtracting the total so far bytes written for the whole array, rather than only the bytes for each element written, so it "used" up the space far far quicker than the actual number of bytes written 😛
I added a test, which fails prior to the changes in this PR, that writes an array that is nearly the size of the test buffer to ensure that size tracking allows the full use of the buffer.
I also fixed up a couple of spots that mutate buffer position in
NullableTypeStrategythat should've been wrapped in a try..finally, so now they are.This PR has: