@VisibleForTesting static int getMinSizeForReservoirUse(ByteBufferPool pool) { return pool.getBufferSize() / 6; }
private void allocateNewBuffer() { if (this.curBuf != null) { this.curBuf.flip();// On the current buf set limit = pos and pos = 0. } // Get an initial BB to work with from the pool this.curBuf = this.pool.getBuffer(); if (this.curBuf == null) { // No free BB at this moment. Make a new one. The pool returns off heap BBs. Don't make off // heap BB on demand. It is difficult to account for all such and so proper sizing of Max // direct heap size. See HBASE-15525 also for more details. // Make BB with same size of pool's buffer size. this.curBuf = ByteBuffer.allocate(this.pool.getBufferSize()); } else { this.bufsFromPool.add(this.curBuf); } this.allBufs.add(this.curBuf); }
int minSizeForPoolUse, int reqLen) { ByteBuff resultBuf; List<ByteBuffer> bbs = new ArrayList<>((reqLen / pool.getBufferSize()) + 1); int remain = reqLen; ByteBuffer buf = null; while (remain >= minSizeForPoolUse && (buf = pool.getBuffer()) != null) { bbs.add(buf); remain -= pool.getBufferSize();
private void allocateNewBuffer() { if (this.curBuf != null) { this.curBuf.flip();// On the current buf set limit = pos and pos = 0. } // Get an initial BB to work with from the pool this.curBuf = this.pool.getBuffer(); if (this.curBuf == null) { // No free BB at this moment. Make a new one. The pool returns off heap BBs. Don't make off // heap BB on demand. It is difficult to account for all such and so proper sizing of Max // direct heap size. See HBASE-15525 also for more details. // Make BB with same size of pool's buffer size. this.curBuf = ByteBuffer.allocate(this.pool.getBufferSize()); } else { this.bufsFromPool.add(this.curBuf); } this.allBufs.add(this.curBuf); }
private void allocateNewBuffer() { if (this.curBuf != null) { this.curBuf.flip();// On the current buf set limit = pos and pos = 0. } // Get an initial BB to work with from the pool this.curBuf = this.pool.getBuffer(); if (this.curBuf == null) { // No free BB at this moment. Make a new one. The pool returns off heap BBs. Don't make off // heap BB on demand. It is difficult to account for all such and so proper sizing of Max // direct heap size. See HBASE-15525 also for more details. // Make BB with same size of pool's buffer size. this.curBuf = ByteBuffer.allocate(this.pool.getBufferSize()); } else { this.bufsFromPool.add(this.curBuf); } this.allBufs.add(this.curBuf); }