コード例 #1
0
  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;
  }
コード例 #2
0
  public void add(CachedObject object) {

    int size = object.getRealSize(cache.rowOut);

    size = cache.rowOut.getStorageSize(size);

    object.setStorageSize(size);
    cache.add(object);
  }
コード例 #3
0
  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) {
      }
    }
  }
コード例 #4
0
  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();
  }
コード例 #5
0
  public CachedObject getKeep(int key) {

    CachedObject object = cache.get(key, this, true);

    return object;
  }
コード例 #6
0
  public CachedObject get(int key) {

    CachedObject object = cache.get(key, this, false);

    return object;
  }
コード例 #7
0
 public int getAccessCount() {
   return cache.getAccessCount();
 }
コード例 #8
0
 public void release(int i) {
   cache.release(i);
 }
コード例 #9
0
 public void remove(int i) {
   cache.remove(i, this);
 }
コード例 #10
0
 public int getStorageSize(int i) {
   return cache.get(i, this, false).getStorageSize();
 }
コード例 #11
0
  public CachedObject get(CachedObject object, boolean keep) {

    object = cache.get(object, this, keep);

    return object;
  }
コード例 #12
0
  public CachedObject get(int key, boolean keep) {

    CachedObject object = cache.get(key, this, keep);

    return object;
  }