-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix CompositeBytesReference#slice to not throw AIOOBE with legal offsets. #35955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ets. CompositeBytesReference#slice has two bugs: - One that makes it fail if the reference is empty and an empty slice is created, this is elastic#35950 and is fixed by special-casing empty-slices. - One performance bug that makes it always create a composite slice when creating a slice that ends on a boundary, this is fixed by computing `limit` as the index of the sub reference that holds the last element rather than the next element after the slice. Closes elastic#35950
|
Pinging @elastic/es-core-infra |
| FutureObjects.checkFromIndexSize(from, length, this.length); | ||
|
|
||
| if (length == 0) { | ||
| return new BytesArray(BytesRef.EMPTY_BYTES); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use BytesArray.EMPTY here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better, thanks for the pointer.
Tim-Brooks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
s1monw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…ets. (#35955) CompositeBytesReference#slice has two bugs: - One that makes it fail if the reference is empty and an empty slice is created, this is #35950 and is fixed by special-casing empty-slices. - One performance bug that makes it always create a composite slice when creating a slice that ends on a boundary, this is fixed by computing `limit` as the index of the sub reference that holds the last element rather than the next element after the slice. Closes #35950
CompositeBytesReference#slice has two bugs:
created, this is [CI] CompositeBytesReferenceTests::testSlice failure #35950 and is fixed by special-casing empty-slices.
creating a slice that ends on a boundary, this is fixed by computing
limitas the index of the sub reference that holds the last element rather than
the next element after the slice.
Closes #35950