@Override public int length() { return this.db.getInt(this.record + LENGTH); } }
/** * Returns the size of the block (in number of chunks), given the (non-inclusive) address that the block ends at. * The return value is positive if the block is free and negative if the block is allocated. */ private int getBlockFooterForChunkBefore(int chunkNum) { if (chunkNum < 2) { // Don't report the database header as a normal chunk. return 0; } return getInt((long) chunkNum * CHUNK_SIZE - LargeBlock.FOOTER_SIZE); }
@Override public int length() { return this.db.getInt(this.record + LENGTH); } }
/** * Returns the size of the block (in number of chunks) starting at the given address. The return value is positive * if the block is free and negative if the block is allocated. */ private int getBlockHeaderForChunkNum(int firstChunkNum) { if (firstChunkNum >= this.fChunksUsed) { return 0; } return getInt((long) firstChunkNum * CHUNK_SIZE); }
/** * Returns the size of the block (in number of chunks), given the (non-inclusive) address that the block ends at. * The return value is positive if the block is free and negative if the block is allocated. */ private int getBlockFooterForChunkBefore(int chunkNum) { if (chunkNum < 2) { // Don't report the database header as a normal chunk. return 0; } return getInt((long) chunkNum * CHUNK_SIZE - LargeBlock.FOOTER_SIZE); }
/** * Returns the size of the block (in number of chunks) starting at the given address. The return value is positive * if the block is free and negative if the block is allocated. */ private int getBlockHeaderForChunkNum(int firstChunkNum) { if (firstChunkNum >= this.fChunksUsed) { return 0; } return getInt((long) firstChunkNum * CHUNK_SIZE); }
@Override public int length() { return Math.abs(this.db.getInt(this.record + LENGTH)); } }
@Override public int length() { return Math.abs(this.db.getInt(this.record + LENGTH)); } }
/** * Performs a self-test on the free space trie list (used by the large block allocator) to check for corruption */ private void validateFreeSpaceTries() { int currentChunkNum = getInt(FREE_BLOCK_OFFSET); if (currentChunkNum == 0) { return; } Set<Integer> visited = new HashSet<>(); validateFreeSpaceNode(visited, currentChunkNum, 0); }
@Override public Integer create(Nd dom, long address) { return dom.getDB().getInt(address); }
/** * Performs a self-test on the free space trie list (used by the large block allocator) to check for corruption */ private void validateFreeSpaceTries() { int currentChunkNum = getInt(FREE_BLOCK_OFFSET); if (currentChunkNum == 0) { return; } Set<Integer> visited = new HashSet<>(); validateFreeSpaceNode(visited, currentChunkNum, 0); }
public int get(Nd nd, long address) { Database db = nd.getDB(); return db.getInt(address + this.offset); }
public int get(Nd nd, long address) { Database db = nd.getDB(); return db.getInt(address + this.offset); }
@Override public Integer create(Nd dom, long address) { return dom.getDB().getInt(address); }
private int getElementsInBlock(long currentRecord, long ptr, int currentRecordCount) throws IndexException { if (ptr == 0 && currentRecordCount > 0) { return getDB().getInt(getAddressOfElement(currentRecord, currentRecordCount - 1)); } return currentRecordCount; }
public IString getString(long offset) throws IndexException { final int l = getInt(offset); int bytelen= l < 0 ? -l : 2 * l; if (bytelen > ShortString.MAX_BYTE_LENGTH) { return new LongString(this, offset); } return new ShortString(this, offset); }
public IString getString(long offset) throws IndexException { final int l = getInt(offset); int bytelen= l < 0 ? -l : 2 * l; if (bytelen > ShortString.MAX_BYTE_LENGTH) { return new LongString(this, offset); } return new ShortString(this, offset); }
private int getElementsInBlock(long currentRecord, long ptr, int currentRecordCount) throws IndexException { if (ptr == 0 && currentRecordCount > 0) { return getDB().getInt(getAddressOfElement(currentRecord, currentRecordCount - 1)); } return currentRecordCount; }
/** * Link the given unused block into the free block tries. The block does not need to have * its header filled in already. * * @param freeBlockChunkNum chunk number of the start of the block * @param numChunks number of chunks in the block */ private void linkFreeBlockToTrie(int freeBlockChunkNum, int numChunks) { setBlockHeader(freeBlockChunkNum, numChunks); long freeBlockAddress = (long) freeBlockChunkNum * CHUNK_SIZE; Chunk chunk = getChunk(freeBlockAddress); chunk.clear(freeBlockAddress + LargeBlock.HEADER_SIZE, LargeBlock.UNALLOCATED_HEADER_SIZE - LargeBlock.HEADER_SIZE); insertChild(getInt(FREE_BLOCK_OFFSET), freeBlockChunkNum); }
private void verifyNotInLargeBlockFreeSpaceTrie(int targetChunkNum, int chunkNum, int parent) { long chunkStart = (long) chunkNum * CHUNK_SIZE; for (int testPosition = 0; testPosition < LargeBlock.ENTRIES_IN_CHILD_TABLE; testPosition++) { long chunkAddress = chunkStart + LargeBlock.CHILD_TABLE_OFFSET + (testPosition * INT_SIZE); int nextChildChunkNum = getInt(chunkAddress); if (nextChildChunkNum == 0) { continue; } if (nextChildChunkNum == targetChunkNum) { throw describeProblem() .addProblemAddress("trie child address", chunkAddress, INT_SIZE) //$NON-NLS-1$ .build("Chunk number " + nextChildChunkNum //$NON-NLS-1$ + " was found in the free space trie even though it was in use"); //$NON-NLS-1$ } verifyNotInLargeBlockFreeSpaceTrie(targetChunkNum, nextChildChunkNum, chunkNum); } }