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 void recordFree(short poolId, long size) { PoolStats toRecord = getPoolStats(poolId); if (toRecord.numAllocations <= 0 || toRecord.totalSize < size) { throw new IndexException("Attempted to free more memory from pool " + poolId + " than was ever allocated"); //$NON-NLS-1$//$NON-NLS-2$ } toRecord.setAllocations(this.db, toRecord.numAllocations - 1); toRecord.setTotalSize(this.db, toRecord.totalSize - size); } }
/** * Debugging method for checking B-tree invariants * @return the empty String if B-tree invariants hold, otherwise * a human readable report * @throws IndexException */ public String getInvariantsErrorReport() throws IndexException { InvariantsChecker checker = new InvariantsChecker(); accept(checker); return checker.isValid() ? "" : checker.getMsg(); //$NON-NLS-1$ }
/** * A Record Pointer is a pointer as returned by Database.malloc(). * This is a pointer to a block + BLOCK_HEADER_SIZE. */ public void putRecPtr(final long offset, final long value) { makeDirty(); int idx = recPtrToIndex(offset); Database.putRecPtr(value, this.fBuffer, idx); recordWrite(offset, 4); }
/** * Writes the key, value mapping to the properties. If a mapping for the * same key already exists, it is overwritten. * @param key a non-null property name * @param value a value to associate with the key. may not be null. * @throws IndexException * @throws NullPointerException if key is null */ public void setProperty(String key, String value) throws IndexException { removeProperty(key); DBProperty newProperty= new DBProperty(this.db, key, value); this.index.insert(newProperty.getRecord()); }
public void recordMalloc(short poolId, long size) { PoolStats toRecord = getPoolStats(poolId); toRecord.setAllocations(this.db, toRecord.numAllocations + 1); toRecord.setTotalSize(this.db, toRecord.totalSize + size); }
private void removeBlock(Chunk chunk, int blocksize, long block) throws IndexException { assert this.fExclusiveLock; long prevblock = chunk.getFreeRecPtr(block + BLOCK_PREV_OFFSET); long nextblock = chunk.getFreeRecPtr(block + BLOCK_NEXT_OFFSET); if (prevblock != 0) { putFreeRecPtr(prevblock + BLOCK_NEXT_OFFSET, nextblock); } else { // We were the head. setFirstBlock(blocksize, nextblock); } if (nextblock != 0) putFreeRecPtr(nextblock + BLOCK_PREV_OFFSET, prevblock); }
@Override public int compareCompatibleWithIgnoreCase(IString string) throws IndexException { return ShortString.compareCompatibleWithIgnoreCase(getChars(), string.getChars()); }
/** * @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)); }
/** * Deletes all properties stored in this object and the record associated with this object * itself. * <br><br> * <b>The behaviour of objects of this class after calling this method is undefined</b> * @throws IndexException */ public void delete() throws IndexException { clear(); this.db.free(this.record, Database.POOL_DB_PROPERTIES); }
public void recordFree(short poolId, long size) { PoolStats toRecord = getPoolStats(poolId); if (toRecord.numAllocations <= 0 || toRecord.totalSize < size) { throw new IndexException("Attempted to free more memory from pool " + poolId + " than was ever allocated"); //$NON-NLS-1$//$NON-NLS-2$ } toRecord.setAllocations(this.db, toRecord.numAllocations - 1); toRecord.setTotalSize(this.db, toRecord.totalSize - size); } }
/** * A Record Pointer is a pointer as returned by Database.malloc(). * This is a pointer to a block + BLOCK_HEADER_SIZE. */ public void putRecPtr(final long offset, final long value) { makeDirty(); int idx = recPtrToIndex(offset); Database.putRecPtr(value, this.fBuffer, idx); recordWrite(offset, 4); }
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); }
/** * @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)); }