Class Sequence
Database.openSequence method.-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close a sequence.longget(Transaction txn, int delta) Return the next available element in the sequence and changes the sequence value bydelta.Return the Database handle associated with this sequence.getKey()Return the DatabaseEntry used to open this sequence.getStats(StatsConfig config) Return statistical information about the sequence.
-
Method Details
-
close
Close a sequence. Any unused cached values are lost.The sequence handle may not be used again after this method has been called, regardless of the method's success or failure.
- Throws:
DatabaseException- if a failure occurs.
-
get
Return the next available element in the sequence and changes the sequence value bydelta. The value ofdeltamust be greater than zero. If there are enough cached values in the sequence handle then they will be returned. Otherwise the next value will be fetched from the database and incremented (decremented) by enough to cover thedeltaand the next batch of cached values.The
txnhandle must be null if the sequence handle was opened with a non-zero cache size.For maximum concurrency, a non-zero cache size should be specified prior to opening the sequence handle, the
txnhandle should benull, andSequenceConfig.setAutoCommitNoSyncshould be called to disable log flushes.- Parameters:
txn- For a transactional database, an explicit transaction may be specified, or null may be specified to use auto-commit. For a non-transactional database, null must be specified.delta- the amount by which to increment or decrement the sequence- Returns:
- the next available element in the sequence
- Throws:
DatabaseException
-
getDatabase
Return the Database handle associated with this sequence.- Returns:
- The Database handle associated with this sequence.
- Throws:
DatabaseException
-
getKey
Return the DatabaseEntry used to open this sequence.- Returns:
- The DatabaseEntry used to open this sequence.
- Throws:
DatabaseException
-
getStats
Return statistical information about the sequence.In the presence of multiple threads or processes accessing an active sequence, the information returned by this method may be out-of-date.
The getStats method cannot be transaction-protected. For this reason, it should be called in a thread of control that has no open cursors or active transactions.
- Parameters:
config- The statistics returned; if null, default statistics are returned.- Returns:
- Sequence statistics.
- Throws:
DatabaseException
-