public Cache(DataFileCache dfc) { dataFileCache = dfc; capacity = dfc.capacity(); bytesCapacity = dfc.bytesCapacity(); rowComparator = new CachedObjectComparator(); rowTable = new CachedObject[capacity]; cacheMap = new ObjectCacheHashMap(capacity); cacheBytesLength = 0; }
public void add(CachedObject object) { int size = object.getRealSize(cache.rowOut); size = cache.rowOut.getStorageSize(size); object.setStorageSize(size); cache.add(object); }
void writeTransactionRows() { for (int i = 0, size = transactionRowLookup.size(); i < size; i++) { if (transactionRowLookup.getValue(i) != 0) { continue; } int key = transactionRowLookup.getKey(i); try { transactionRowLookup.setValue(i, (int) (fileOffset / scale)); RowInputInterface rowIn = cache.readObject(key); fileStreamOut.write(rowIn.getBuffer(), 0, rowIn.getSize()); fileOffset += rowIn.getSize(); } catch (HsqlException e) { } catch (IOException e) { } } }
synchronized void saveRows(int count) throws IOException { if (count == 0) { return; } rowComparator.setType(rowComparator.COMPARE_POSITION); sortTimer.start(); Sort.sort(rowTable, rowComparator, 0, count - 1); sortTimer.stop(); saveAllTimer.start(); dataFileCache.saveRows(rowTable, 0, count); saveRowCount += count; /* // not necessary if the full storage size of each object is written out try { dataFile.file.seek(fileFreePosition); } catch (IOException e){} */ saveAllTimer.stop(); }
public CachedObject getKeep(int key) { CachedObject object = cache.get(key, this, true); return object; }
public CachedObject get(int key) { CachedObject object = cache.get(key, this, false); return object; }
public int getAccessCount() { return cache.getAccessCount(); }
public void release(int i) { cache.release(i); }
public void remove(int i) { cache.remove(i, this); }
public int getStorageSize(int i) { return cache.get(i, this, false).getStorageSize(); }
public CachedObject get(CachedObject object, boolean keep) { object = cache.get(object, this, keep); return object; }
public CachedObject get(int key, boolean keep) { CachedObject object = cache.get(key, this, keep); return object; }