code: private ByteBuffer getBuffer() throws IOException {
          ByteBuffer buffer;
  
          // Get the oldest block that has a buffer
          int bufferCount = 0;
          TableBlock takeFromBlock = null;
          for (TableBlock block : _blocks) {
              if (block.hasBuffer()) {
                  bufferCount++;
                  if (takeFromBlock == null || block.getMostRecentUse() < takeFromBlock.getMostRecentUse()) {
                      takeFromBlock = block;
                  }
              }
          }
          if (bufferCount < _bufferCount || takeFromBlock == null) {
              // We haven't used the maximum number of buffers yet, so allocate a new one
              _log.debug("Allocating new block of size {}", _blockSize);
              buffer = ByteBuffer.allocate(_blockSize);
          } else {
              buffer = takeFromBlock.flushAndReleaseBuffer();
              // Reset the buffer for reuse
              buffer.position(0);
              buffer.limit(_blockSize);
          }
  
          return buffer;
      }
docs: Gets a buffer for assigning to a TableBlock.  If less than {@link #_bufferCount} buffers have been created
  then it will create a new one, otherwise it will take the buffer from the least recently used TableBlock.