예제 #1
0
  /** Returns the record number for the last record read. */
  int getCurrentRecordNumber() throws DatabaseException {

    if (view.btreeRecNumDb) {
      /* BTREE-RECNO access. */
      if (otherThang == null) {
        otherThang = new DatabaseEntry();
      }
      DbCompat.getCurrentRecordNumber(cursor.getCursor(), otherThang, getLockMode(false));
      return DbCompat.getRecordNumber(otherThang);
    } else {
      /* QUEUE or RECNO database. */
      return DbCompat.getRecordNumber(keyThang);
    }
  }
예제 #2
0
  /** Returns the record number at the given slot position. */
  private int getRecordNumber(int i) {

    if (coll.view.btreeRecNumDb) {
      DataCursor cursor = null;
      try {
        cursor = new DataCursor(coll.view, false);
        if (moveCursor(i, cursor)) {
          return cursor.getCurrentRecordNumber();
        } else {
          throw new IllegalStateException();
        }
      } catch (DatabaseException e) {
        throw StoredContainer.convertException(e);
      } finally {
        closeCursor(cursor);
      }
    } else {
      DatabaseEntry entry = new DatabaseEntry(keys[i]);
      return DbCompat.getRecordNumber(entry);
    }
  }
예제 #3
0
  /** Increments the record number key at the given slot. */
  private void bumpRecordNumber(int i) {

    DatabaseEntry entry = new DatabaseEntry(keys[i]);
    DbCompat.setRecordNumber(entry, DbCompat.getRecordNumber(entry) + 1);
    keys[i] = entry.getData();
  }
예제 #4
0
  /**
   * Utility method for use by bindings to translate a entry buffer to an record number integer.
   *
   * @param entry the entry buffer.
   * @return the record number.
   */
  public static long entryToRecordNumber(DatabaseEntry entry) {

    return DbCompat.getRecordNumber(entry) & 0xFFFFFFFFL;
  }