/** * @param blockSize (must be a multiple of BLOCK_SIZE_DELTA) */ private long getFirstBlock(int blockSize) throws IndexException { assert this.fLocked; return this.fHeaderChunk.getFreeRecPtr(getAddressOfFirstBlockPointer(blockSize)); }
private void setFirstBlock(int blockSize, long block) throws IndexException { assert this.fExclusiveLock; this.fHeaderChunk.putFreeRecPtr(getAddressOfFirstBlockPointer(blockSize), block); }
/** * @param blockSize (must be a multiple of BLOCK_SIZE_DELTA) */ private long getFirstBlock(int blockSize) throws IndexException { assert this.fLocked; return this.fHeaderChunk.getFreeRecPtr(getAddressOfFirstBlockPointer(blockSize)); }
private void setFirstBlock(int blockSize, long block) throws IndexException { assert this.fExclusiveLock; this.fHeaderChunk.putFreeRecPtr(getAddressOfFirstBlockPointer(blockSize), block); }
private void verifyNotInFreeSpaceList(long result) { int useDeltas; for (useDeltas = MIN_BLOCK_DELTAS; useDeltas <= MAX_BLOCK_DELTAS; useDeltas++) { int correctSize = useDeltas * BLOCK_SIZE_DELTA; long block = getFirstBlock(correctSize); long addressOfPrevBlockPointer = getAddressOfFirstBlockPointer(correctSize); while (block != 0) { if (block == result) { throw describeProblem() .addProblemAddress("incoming pointer", addressOfPrevBlockPointer, PTR_SIZE) //$NON-NLS-1$ .build("Block " + result //$NON-NLS-1$ + " was found in the free space list, even though it wasn't free"); //$NON-NLS-1$ } addressOfPrevBlockPointer = block + BLOCK_NEXT_OFFSET; long followingBlock = getFreeRecPtr(addressOfPrevBlockPointer); block = followingBlock; } } int currentChunkNum = getInt(FREE_BLOCK_OFFSET); if (currentChunkNum == 0) { return; } int targetChunkNum = (int) (result / CHUNK_SIZE); if (currentChunkNum == targetChunkNum) { throw describeProblem().build("Block " + result //$NON-NLS-1$ + " was not supposed to be in the free space list, but was linked as the root of the list"); //$NON-NLS-1$ } verifyNotInLargeBlockFreeSpaceTrie(targetChunkNum, currentChunkNum, 0); }
private void verifyNotInFreeSpaceList(long result) { int useDeltas; for (useDeltas = MIN_BLOCK_DELTAS; useDeltas <= MAX_BLOCK_DELTAS; useDeltas++) { int correctSize = useDeltas * BLOCK_SIZE_DELTA; long block = getFirstBlock(correctSize); long addressOfPrevBlockPointer = getAddressOfFirstBlockPointer(correctSize); while (block != 0) { if (block == result) { throw describeProblem() .addProblemAddress("incoming pointer", addressOfPrevBlockPointer, PTR_SIZE) //$NON-NLS-1$ .build("Block " + result //$NON-NLS-1$ + " was found in the free space list, even though it wasn't free"); //$NON-NLS-1$ } addressOfPrevBlockPointer = block + BLOCK_NEXT_OFFSET; long followingBlock = getFreeRecPtr(addressOfPrevBlockPointer); block = followingBlock; } } int currentChunkNum = getInt(FREE_BLOCK_OFFSET); if (currentChunkNum == 0) { return; } int targetChunkNum = (int) (result / CHUNK_SIZE); if (currentChunkNum == targetChunkNum) { throw describeProblem().build("Block " + result //$NON-NLS-1$ + " was not supposed to be in the free space list, but was linked as the root of the list"); //$NON-NLS-1$ } verifyNotInLargeBlockFreeSpaceTrie(targetChunkNum, currentChunkNum, 0); }
private void validateFreeBlocksFor(int numberOfDeltas) { int correctSize = numberOfDeltas * BLOCK_SIZE_DELTA; long lastBlock = 0; long block = getFirstBlock(correctSize); long addressOfPrevBlockPointer = getAddressOfFirstBlockPointer(correctSize); while (block != 0) { long measuredLastBlock = getFreeRecPtr(block + BLOCK_PREV_OFFSET); int blockReportedSize = getShort(block); long followingBlock = getFreeRecPtr(block + BLOCK_NEXT_OFFSET); if (measuredLastBlock != lastBlock) { throw describeProblem() .addProblemAddress("last block", block + BLOCK_PREV_OFFSET, PTR_SIZE) //$NON-NLS-1$ .addProblemAddress("incoming pointer", addressOfPrevBlockPointer, PTR_SIZE) //$NON-NLS-1$ .build("The free space block (" + block //$NON-NLS-1$ + ") of size " + correctSize + " had an incorrect prev pointer to " //$NON-NLS-1$//$NON-NLS-2$ + measuredLastBlock + ", but it should have been pointing to " //$NON-NLS-1$ + lastBlock); } if (blockReportedSize != correctSize) { throw describeProblem() .addProblemAddress("block size", block, SHORT_SIZE) //$NON-NLS-1$ .addProblemAddress("incoming pointer", addressOfPrevBlockPointer, PTR_SIZE) //$NON-NLS-1$ .build("A block (" + block + ") of size " + measuredLastBlock //$NON-NLS-1$ //$NON-NLS-2$ + " was in the free space list for blocks of size " + correctSize); //$NON-NLS-1$ } addressOfPrevBlockPointer = block + BLOCK_NEXT_OFFSET; lastBlock = block; block = followingBlock; } }
private void validateFreeBlocksFor(int numberOfDeltas) { int correctSize = numberOfDeltas * BLOCK_SIZE_DELTA; long lastBlock = 0; long block = getFirstBlock(correctSize); long addressOfPrevBlockPointer = getAddressOfFirstBlockPointer(correctSize); while (block != 0) { long measuredLastBlock = getFreeRecPtr(block + BLOCK_PREV_OFFSET); int blockReportedSize = getShort(block); long followingBlock = getFreeRecPtr(block + BLOCK_NEXT_OFFSET); if (measuredLastBlock != lastBlock) { throw describeProblem() .addProblemAddress("last block", block + BLOCK_PREV_OFFSET, PTR_SIZE) //$NON-NLS-1$ .addProblemAddress("incoming pointer", addressOfPrevBlockPointer, PTR_SIZE) //$NON-NLS-1$ .build("The free space block (" + block //$NON-NLS-1$ + ") of size " + correctSize + " had an incorrect prev pointer to " //$NON-NLS-1$//$NON-NLS-2$ + measuredLastBlock + ", but it should have been pointing to " //$NON-NLS-1$ + lastBlock); } if (blockReportedSize != correctSize) { throw describeProblem() .addProblemAddress("block size", block, SHORT_SIZE) //$NON-NLS-1$ .addProblemAddress("incoming pointer", addressOfPrevBlockPointer, PTR_SIZE) //$NON-NLS-1$ .build("A block (" + block + ") of size " + measuredLastBlock //$NON-NLS-1$ //$NON-NLS-2$ + " was in the free space list for blocks of size " + correctSize); //$NON-NLS-1$ } addressOfPrevBlockPointer = block + BLOCK_NEXT_OFFSET; lastBlock = block; block = followingBlock; } }