/** * Releases the current tail buffer. After releasing, the tail buffer is made * invalid. * */ private void releaseTailBlock() { if (tailBlock != null) { tailBlock.release(); tailBlock = null; } }
/** * Tells the file that this block is no longer in use and can be recycled. This is * accomplished by putting it on the free list for the file. * * @throws IOException There was an error writing to the free list. */ public void free() throws IOException { blockFile.freeBlock(blockId); release(); }
/** * Releases the current reallocate buffer. After releasing, the reallocate * buffer is made invalid. If the buffer is dirty and valid then it is written * to the blockFile first. * * @throws IOException if an I/O error occurs. */ private void releaseReallocateBlock() throws IOException { if (reallocateBlock != null) { if (reallocateBlockDirty) { writeReallocateBlock(); } reallocateBlock.release(); reallocateBlock = null; } }
/** * Releases the current head buffer. After releasing, the head buffer is made * invalid. If the buffer is dirty and valid then it is written to the * blockFile first. * * @throws IOException if an I/O error occurs. */ private void releaseHeadBlock() throws IOException { if (headBlock != null) { if (headBlockDirty) { writeHeadBlock(); } headBlock.release(); headBlock = null; } }
/** * Reads data from the specified block into the ByteBuffer starting at the * current position. The number of bytes read is the number of remaining * bytes in the ByteBuffer. */ private ByteBuffer retrieveRemainingBytes( ObjectPool objectPool, ByteBuffer data, long blockId ) throws IOException { int dataSize = data.remaining(); if (dataSize > 0) { // Determine the block file to use. int fileIndex = XAUtils.log2( (dataSize - 1) >> (LOG2_MIN_BLOCK_SIZE - 1) ); ManagedBlockFile.Phase blockFilePhase = blockFilePhases[fileIndex]; Block block = blockFilePhase.readBlock(objectPool, blockId); try { block.get(0, data); } finally { block.release(); } } return data; }
avlNode.block.release(); avlNode.block = null;
return blockId; } finally { block.release();