SSequence (Oracle - Berkeley DB Client-Server API)
Date: 2018-05-29

com.sleepycat.client

## Class SSequence

- java.lang.Object
- - com.sleepycat.client.SSequence

- All Implemented Interfaces:
    java.lang.AutoCloseable

      public class SSequence
      extends java.lang.Object
      implements java.lang.AutoCloseable

  A SSequence handle is used to manipulate a sequence record in a database. SSequence handles are opened using the `SDatabase.openSequence(com.sleepycat.client.STransaction, com.sleepycat.client.SDatabaseEntry, com.sleepycat.client.SSequenceConfig)` method.

- - ### Method Summary

    All Methods Instance Methods Concrete Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Close a sequence.
    `long` | `get(STransaction txn, int delta)` Return the next available element in the sequence and changes the sequence value by delta.
    `SDatabase` | `getDatabase()` Return the SDatabase handle associated with this sequence.
    `SDatabaseEntry` | `getKey()` Return the SDatabaseEntry used to open this sequence.
    `default <V> V` | `handleRuntimeExceptions(com.sleepycat.client.RemoteServiceCallable<V> remote)`
    `default <V> V` | `remoteCall(com.sleepycat.client.RemoteServiceCallable<V> remote)`
    `default <V> V` | `remoteCallWithIOException(com.sleepycat.client.RemoteServiceCallable<V> remote)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getDatabase

          public SDatabase getDatabase()

      Return the SDatabase handle associated with this sequence.
      Returns:
        the SDatabase handle associated with this sequence

    - #### getKey

          public SDatabaseEntry getKey()

      Return the SDatabaseEntry used to open this sequence.
      Returns:
        the SDatabaseEntry used to open this sequence

    - #### close

          public void close()
                     throws SDatabaseException

      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.

      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Throws:
        `SDatabaseException` - if any error occurs

    - #### get

          public long get(STransaction txn,
                          int delta)
                   throws SDatabaseException

      Return the next available element in the sequence and changes the sequence value by delta. The value of delta must 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 the delta and the next batch of cached values.

      The txn handle 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 txn handle should be null, and `SSequenceConfig.setAutoCommitNoSync(boolean)` should be called to disable log flushes.

      Parameters:
        `txn` - an explicit transaction may be specified, or null may be specified to use auto-commit
        `delta` - the amount by which to increment or decrement the sequence
      Returns:
        the next available element in the sequence
      Throws:
        `SDatabaseException` - if any error occurs

    - #### remoteCallWithIOException

          public <V> V remoteCallWithIOException(com.sleepycat.client.RemoteServiceCallable<V> remote)
                                          throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### remoteCall

          public <V> V remoteCall(com.sleepycat.client.RemoteServiceCallable<V> remote)

    - #### handleRuntimeExceptions

          public <V> V handleRuntimeExceptions(com.sleepycat.client.RemoteServiceCallable<V> remote)
                                        throws org.apache.thrift.TException

      Throws:
        `org.apache.thrift.TException`

Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved.