/** * Retrieves the key/data pair with the given key. If the matching key has duplicate values, the * first data item in the set of duplicates is returned. Retrieval of duplicates requires the use * of {@link Cursor} operations. * * <p> * * @param txn For a transactional database, an explicit transaction may be specified to * transaction-protect the operation, or null may be specified to perform the operation * without transaction protection. For a non-transactional database, null must be specified. * <p> * @param key the secondary key used as input. It must be initialized with a non-null byte array * by the caller. * <p> * @param pKey the primary key returned as output. Its byte array does not need to be initialized * by the caller. * <p> * @param data the primary data returned as output. Its byte array does not need to be initialized * by the caller. * <p> * @param lockMode the locking attributes; if null, default attributes are used. * <p> * @return {@link com.sleepycat.db.OperationStatus#NOTFOUND OperationStatus.NOTFOUND} if no * matching key/data pair is found; {@link com.sleepycat.db.OperationStatus#KEYEMPTY * OperationStatus.KEYEMPTY} if the database is a Queue or Recno database and the specified * key exists, but was never explicitly created by the application or was later deleted; * otherwise, {@link com.sleepycat.db.OperationStatus#SUCCESS OperationStatus.SUCCESS}. * <p> * <p> * @throws DeadlockException if the operation was selected to resolve a deadlock. * <p> * @throws IllegalArgumentException if an invalid parameter was specified. * <p> * @throws DatabaseException if a failure occurs. */ public OperationStatus get( final Transaction txn, final DatabaseEntry key, final DatabaseEntry pKey, final DatabaseEntry data, final LockMode lockMode) throws DatabaseException { return OperationStatus.fromInt( db.pget( (txn == null) ? null : txn.txn, key, pKey, data, LockMode.getFlag(lockMode) | ((data == null) ? 0 : data.getMultiFlag()))); }
/** * Retrieves the key/data pair associated with the specific numbered record of the database. * * <p>The data field of the specified key must be a byte array containing a record number, as * described in {@link com.sleepycat.db.DatabaseEntry DatabaseEntry}. This determines the record * to be retrieved. * * <p>For this method to be called, the underlying database must be of type Btree, and it must * have been configured to support record numbers. * * <p>If this method fails for any reason, the position of the cursor will be unchanged. * * @throws NullPointerException if a DatabaseEntry parameter is null or does not contain a * required non-null byte array. * <p> * @throws DeadlockException if the operation was selected to resolve a deadlock. * <p> * @throws IllegalArgumentException if an invalid parameter was specified. * <p> * @throws DatabaseException if a failure occurs. * <p> * @param key the secondary key returned as output. Its byte array does not need to be initialized * by the caller. * @param pKey the primary key returned as output. Its byte array does not need to be initialized * by the caller. * @param data the primary data returned as output. Multiple results can be retrieved by passing * an object that is a subclass of {@link com.sleepycat.db.MultipleEntry MultipleEntry}, * otherwise its byte array does not need to be initialized by the caller. * @param lockMode the locking attributes; if null, default attributes are used. * @return {@link com.sleepycat.db.OperationStatus#NOTFOUND OperationStatus.NOTFOUND} if no * matching key/data pair is found; {@link com.sleepycat.db.OperationStatus#KEYEMPTY * OperationStatus.KEYEMPTY} if the database is a Queue or Recno database and the specified * key exists, but was never explicitly created by the application or was later deleted; * otherwise, {@link com.sleepycat.db.OperationStatus#SUCCESS OperationStatus.SUCCESS}. */ public OperationStatus getSearchRecordNumber( final Transaction txn, final DatabaseEntry key, final DatabaseEntry pKey, final DatabaseEntry data, final LockMode lockMode) throws DatabaseException { return OperationStatus.fromInt( db.pget( (txn == null) ? null : txn.txn, key, pKey, data, DbConstants.DB_SET_RECNO | LockMode.getFlag(lockMode) | ((data == null) ? 0 : data.getMultiFlag()))); }
/** * Return the next LogSequenceNumber and log record. * * <p>The current log position is advanced to the next record in the log, and its * LogSequenceNumber and data are returned. If the cursor has not been initialized, the first * available log record in the log will be returned. * * <p> * * @param lsn The returned LogSequenceNumber. * <p> * @param data The returned log record. * <p> * @return The status of the operation; a return of NOTFOUND indicates the last log record has * already been returned or the log is empty. * <p> * <p> * @throws DatabaseException if a failure occurs. */ public OperationStatus getNext(final LogSequenceNumber lsn, final DatabaseEntry data) throws DatabaseException { return OperationStatus.fromInt(logc.get(lsn, data, DbConstants.DB_NEXT)); }