byte array has better performance than ByteBuffer
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 1.6k
- Avg merge
- 3d 12h
- Merged PRs (30d)
- 33
Description
The BytePacker should add the following method
public abstract void unpack8Values(final byte[] input, final int inPos, final int[] output, final int outPos);
to replace method
@Deprecated
public void unpack8Values(final byte[] input, final int inPos, final int[] output, final int outPos) {
unpack8Values(ByteBuffer.wrap(input), inPos, output, outPos);
}
Tested by me byte array has better performance than ByteBuffer,
The test result is:
[Unpack8ValuesByteArray spent time] 80 ms
[Unpack8ValuesByteBuffer spent time] 133 ms
The test code is:
package org.apache.parquet.column.values.bitpacking;
import java.nio.ByteBuffer;
public class ByteBufferTest {
private static final BytePacker bytePacker = Packer.LITTLE_ENDIAN.newBytePacker(7);
private static final int COUNT = 100000;
public static void main(String[] args) {
byte [] in = new byte[1008];
int [] out = new int[1152];
int [] out1 = new int[1152];
int [] out2 = new int[1152];
int res = 0;
for(int i = 0; i < in.length; i++) {
in[i] = (byte) i;
}
for(int i = 0; i < COUNT; i++) {
res += unpack8ValuesBytes(in, out, i % out.length);
}
res = 0;
long t1 = System.currentTimeMillis();
for(int i = 0; i < COUNT; i++) {
res += unpack8ValuesBytes(in, out1, i % out.length);
}
long t2 = System.currentTimeMillis();
System.out.println("[Unpack8ValuesByteArray spent time] " + (t2-t1) + " ms");
ByteBuffer byteBuffer = ByteBuffer.wrap(in);
for(int i = 0; i < COUNT; i++) {
res += unpack8ValuesByteBuffer(byteBuffer, out, i % out.length);
}
res = 0;
long t3 = System.currentTimeMillis();
for(int i = 0; i < COUNT; i++) {
res += unpack8ValuesByteBuffer(byteBuffer, out2, i % out.length);
}
long t4 = System.currentTimeMillis();
System.out.println("[Unpack8ValuesByteBuffer spent time] " + (t4-t3) + " ms");
for (int i=0; i**Note**: *This issue was originally created as [PARQUET-2190](https://issues.apache.org/jira/browse/PARQUET-2190). Please see the [migration documentation](https://issues.apache.org/jira/browse/PARQUET-2502) for further details.*
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at BytePacker.unpack8Values and the Packer.LITTLE_ENDIAN.newBytePacker(7) entry point, then inspect the concrete packer implementations that provide the current ByteBuffer path. Use the ByteBufferTest example to compare equivalent byte-array and ByteBuffer results and performance; done means the byte-array API works across implementations without changing unpacked values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- data-engineering, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100