Skip to content

Commit

Permalink
orc_reset_chunk_supplier
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyangfb committed Nov 3, 2024
1 parent fc9131c commit 7cab405
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
package com.facebook.presto.orc;

import com.facebook.airlift.log.Logger;
import io.airlift.slice.Slice;
import io.airlift.slice.SliceOutput;
import io.airlift.slice.Slices;
Expand Down Expand Up @@ -344,6 +345,7 @@ private void closeChunk()
// reusing the buffers.
private static class ChunkSupplier
{
private static final Logger log = Logger.get(ChunkSupplier.class);
private final int maxChunkSize;

private final List<byte[]> bufferPool = new ArrayList<>();
Expand All @@ -363,6 +365,14 @@ public ChunkSupplier(int minChunkSize, int maxChunkSize)

public void reset()
{
if (!bufferPool.isEmpty()) {
log.info("Reset unused buffers, used %d chunks (%d bytes), unused %d chunks (%d bytes)",
usedBuffers.size(),
usedBuffers.stream().mapToInt(b -> b.length).sum(),
bufferPool.size(),
bufferPool.stream().mapToInt(b -> b.length).sum());
bufferPool.clear();
}
bufferPool.addAll(0, usedBuffers);
usedBuffers.clear();
}
Expand Down

0 comments on commit 7cab405

Please sign in to comment.