paimon
paimon copied to clipboard
[enhancement ] Reusing the lengths array in ArrowFieldWrites$ArrayWriter's doWrite method
Search before asking
- [x] I searched in the issues and found nothing similar.
Motivation
ArrowFieldWriters$ArrayWriter#doWrite
Solution
Implementation Steps
-
Reusable Buffer Declaration
Define a reusable buffer field inArrayWriterclass:private int[] reusedLengthsBuffer; // Reusable array buffer for length storage -
Lazy Initialization & Dynamic Expansion
IndoWritemethod, initialize or expand buffer based on runtimelenSizerequirements:if (reusedLengthsBuffer == null || reusedLengthsBuffer.length < lenSize) { int newCapacity = lenSize; // Apply 1.5x growth factor if reallocating from existing buffer if (reusedLengthsBuffer != null) { newCapacity = Math.max(lenSize, (int)(reusedLengthsBuffer.length * 1.5)); } reusedLengthsBuffer = new int[newCapacity]; // Allocate or expand buffer } // Reset buffer segment before reuse Arrays.fill(reusedLengthsBuffer, 0, lenSize, 0);
Let me know if you have any questions. thanks
Anything else?
No response
Are you willing to submit a PR?
- [x] I'm willing to submit a PR!