Sha256: 9b0fef7edcba177c571683be6551385a4b1d597aa72157e05dff46ad2221838a
Contents?: true
Size: 1.43 KB
Versions: 19
Compression:
Stored size: 1.43 KB
Contents
package org.embulk.exec; import io.netty.buffer.PooledByteBufAllocator; import io.netty.buffer.ByteBuf; import io.netty.util.ResourceLeakDetector; import org.embulk.spi.Buffer; import org.embulk.spi.BufferAllocator; public class PooledBufferAllocator implements BufferAllocator { private PooledByteBufAllocator nettyBuffer; public PooledBufferAllocator() { // TODO configure parameters this.nettyBuffer = new PooledByteBufAllocator(false); } public Buffer allocate() { return new NettyByteBufBuffer(nettyBuffer.buffer()); } public Buffer allocate(int minimumCapacity) { int size = 32*1024; while (size < minimumCapacity) { size *= 2; } return new NettyByteBufBuffer(nettyBuffer.buffer(size)); } private static class NettyByteBufBuffer extends Buffer { private ByteBuf buf; private Exception doubleFreeCheck; public NettyByteBufBuffer(ByteBuf buf) { super(buf.array(), buf.arrayOffset(), buf.capacity()); this.buf = buf; } public void release() { if (doubleFreeCheck != null) { doubleFreeCheck.printStackTrace(); } if (buf != null) { buf.release(); buf = null; doubleFreeCheck = new NullPointerException(); } } } }
Version data entries
19 entries across 19 versions & 1 rubygems