Ejemplo n.º 1
0
  private static void deleteRecord(final int id) {
    try {
      w.lock();
      DbConnection.markDirty();
      deleteContentAndAttributes(id);

      DbConnection.cleanRecord(id);
      addToFreeRecordsList(id);
    } catch (Throwable e) {
      throw DbConnection.handleError(e);
    } finally {
      w.unlock();
    }
  }
Ejemplo n.º 2
0
  public static int createRecord() {
    try {
      w.lock();
      DbConnection.markDirty();

      final int free = DbConnection.getFreeRecord();
      if (free == 0) {
        final int filelength = (int) getRecords().length();
        LOG.assertTrue(filelength % RECORD_SIZE == 0);
        int newrecord = filelength / RECORD_SIZE;
        DbConnection.cleanRecord(newrecord);
        assert filelength + RECORD_SIZE == getRecords().length();
        return newrecord;
      } else {
        DbConnection.cleanRecord(free);
        return free;
      }
    } catch (Throwable e) {
      throw DbConnection.handleError(e);
    } finally {
      w.unlock();
    }
  }