ByteBuffer release(ByteBuffer buffer) { if (buffer != null) { allocator.release(buffer); } return null; }
ByteBuffer release(ByteBuffer buffer) { if (buffer != null) { allocator.release(buffer); } return null; }
/** * When re-using an instance with reset, it will adjust slab size based on previous data size. * The intent is to reuse the same instance for the same type of data (for example, the same column). * The assumption is that the size in the buffer will be consistent. */ public void reset() { // readjust slab size. // 7 = 2^3 - 1 so that doubling the initial size 3 times will get to the same size this.initialSlabSize = max(bytesUsed / 7, initialSlabSize); LOG.debug("initial slab of size {}", initialSlabSize); for (ByteBuffer slab : slabs) { allocator.release(slab); } this.slabs.clear(); this.bytesAllocated = 0; this.bytesUsed = 0; this.currentSlab = EMPTY_SLAB; this.currentSlabIndex = 0; }
/** * When re-using an instance with reset, it will adjust slab size based on previous data size. * The intent is to reuse the same instance for the same type of data (for example, the same column). * The assumption is that the size in the buffer will be consistent. */ public void reset() { // readjust slab size. // 7 = 2^3 - 1 so that doubling the initial size 3 times will get to the same size this.initialSlabSize = max(bytesUsed / 7, initialSlabSize); LOG.debug("initial slab of size {}", initialSlabSize); for (ByteBuffer slab : slabs) { allocator.release(slab); } this.slabs.clear(); this.bytesAllocated = 0; this.bytesUsed = 0; this.currentSlab = EMPTY_SLAB; this.currentSlabIndex = 0; }
@Override public void close() { for (ByteBuffer slab : slabs) { allocator.release(slab); } try { super.close(); }catch(IOException e){ throw new OutputStreamCloseException(e); } } }
@Override public void close() { for (ByteBuffer slab : slabs) { allocator.release(slab); } try { super.close(); }catch(IOException e){ throw new OutputStreamCloseException(e); } } }