-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Reduce overhead from Slice#getInt in PlainByteArrayDecoders #24284
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -159,7 +159,7 @@ public void read(BinaryBuffer values, int offset, int length) | |
| currentInputOffset += positionLength + Integer.BYTES; | ||
| } | ||
|
|
||
| createOutputBuffer(values, offset, length, inputSlice, outputBufferSize); | ||
| values.addChunk(createOutputBuffer(values.getOffsets(), offset, length, inputSlice, outputBufferSize)); | ||
| input.skip(currentInputOffset); | ||
| } | ||
|
|
||
|
|
@@ -168,6 +168,36 @@ public void skip(int n) | |
| { | ||
| skipPlainValues(input, n); | ||
| } | ||
|
|
||
| /** | ||
| * Create one big slice of data and add it to the output buffer since buffer size is known. | ||
| * Specialized for the case of strings with no truncation | ||
| */ | ||
| private static Slice createOutputBuffer(int[] offsets, int offset, int length, Slice inputSlice, int outputBufferSize) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so |
||
| { | ||
| byte[] outputBuffer = new byte[outputBufferSize]; | ||
| int currentInputOffset = 0; | ||
| int currentOutputOffset = 0; | ||
|
|
||
| byte[] inputArray; | ||
| int inputArrayOffset; | ||
| if (length != 0) { | ||
| inputArray = inputSlice.byteArray(); | ||
| inputArrayOffset = inputSlice.byteArrayOffset(); | ||
| } | ||
| else { | ||
| inputArray = new byte[0]; | ||
| inputArrayOffset = 0; | ||
| } | ||
| for (int i = 0; i < length; i++) { | ||
| int positionLength = offsets[offset + i + 1]; | ||
| arraycopy(inputArray, inputArrayOffset + currentInputOffset + Integer.BYTES, outputBuffer, currentOutputOffset, positionLength); | ||
| offsets[offset + i + 1] = offsets[offset + i] + positionLength; | ||
| currentInputOffset += positionLength + Integer.BYTES; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why add |
||
| currentOutputOffset += positionLength; | ||
| } | ||
| return Slices.wrappedBuffer(outputBuffer); | ||
| } | ||
| } | ||
|
|
||
| private static void skipPlainValues(SimpleSliceInputStream input, int n) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.