-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix an overflow in PinotDataBuffer.readFrom #13152
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #13152 +/- ##
============================================
+ Coverage 61.75% 62.19% +0.44%
+ Complexity 207 198 -9
============================================
Files 2436 2515 +79
Lines 133233 137862 +4629
Branches 20636 21335 +699
============================================
+ Hits 82274 85744 +3470
- Misses 44911 45726 +815
- Partials 6048 6392 +344
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
This will impact the performance of small buffer. Can you override this method in UnsafePinotBuffer
?
No, it won't. This method is already override by PinotByteBuffer. Its implementation is: @Override
public void readFrom(long offset, byte[] buffer, int srcOffset, int size) {
assert offset <= Integer.MAX_VALUE;
int intOffset = (int) offset;
if (size <= BULK_BYTES_PROCESSING_THRESHOLD) {
int end = srcOffset + size;
for (int i = srcOffset; i < end; i++) {
putByte(intOffset++, buffer[i]);
}
} else {
ByteBuffer duplicate = _buffer.duplicate();
((Buffer) duplicate).position(intOffset);
duplicate.put(buffer, srcOffset, size);
}
} |
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.
(Optional) Seems we have all different impl for this method, should we just change it to abstract
and always override? Currently it is quite confusing and very hard to navigate
Actually if we override it in |
Fix an error on PinotDataBuffer when calling
readFrom
with an offset that was larger than Integer.MAX_VALUEIn fact this error only affected
UnsafePinotBuffer
because it was the only buffer using the default implementation. In the previous code the read failed when it wasn't problematic at all.