Class SequenceManager


  • final class SequenceManager
    extends java.lang.Object
    An object that manages the creation and removal of sequence keys, and that offers access to the sequence values (possibly cached). When the sequence table is changed, this opens an optimized transaction on the database and manipulates the SequenceInfo table.
    • Field Detail

      • sequence_key_map

        private java.util.HashMap sequence_key_map
        A hashmap that maps from the TableName of the sequence key to the object that manages this sequence (SequenceGenerator). (TableName) -> (SequenceGenerator)
      • ONE_VAL

        private static final TObject ONE_VAL
        A static TObject that represents numeric 1.
      • TRUE_VAL

        private static final TObject TRUE_VAL
        A static TObject that represents boolean true.
    • Constructor Detail

    • Method Detail

      • getTransaction

        private Transaction getTransaction()
        Returns a new Transaction object for manipulating and querying the system state.
      • updateGeneratorState

        private void updateGeneratorState​(SequenceManager.SequenceGenerator generator)
        Updates the state of the sequence key in the sequence tables in the database. The update occurs on an independant transaction.
      • flushGenerator

        void flushGenerator​(TableName name)
        Flushes a sequence generator from the cache. This should be used when a sequence generator is altered or dropped from the database.
      • addNativeTableGenerator

        static void addNativeTableGenerator​(Transaction transaction,
                                            TableName table_name)
        Static convenience - adds an entry to the Sequence table for a native table in the database. This acts as a gateway between the native sequence table function and the custom sequence generator. Note that some of the system tables and all of the VIEW tables will not have native sequence generators and thus not have an entry in the sequence table.
      • removeNativeTableGenerator

        static void removeNativeTableGenerator​(Transaction transaction,
                                               TableName table_name)
        Static convenience - removes an entry in the Sequence table for a native table in the database.
      • createSequenceGenerator

        static void createSequenceGenerator​(Transaction transaction,
                                            TableName table_name,
                                            long start_value,
                                            long increment_by,
                                            long min_value,
                                            long max_value,
                                            long cache,
                                            boolean cycle)
        Creates a new sequence generator with the given name and details. Note that this method does not check if the generator name clashes with an existing database object.
      • dropSequenceGenerator

        static void dropSequenceGenerator​(Transaction transaction,
                                          TableName table_name)
      • nextValue

        long nextValue​(SimpleTransaction transaction,
                       TableName name)
        Returns the next value from the sequence generator. This will atomically increment the sequence counter.
      • curValue

        long curValue​(SimpleTransaction transaction,
                      TableName name)
        Returns the current value from the sequence generator.
      • setValue

        void setValue​(SimpleTransaction transaction,
                      TableName name,
                      long value)
        Sets the current value of the sequence generator.
      • createInternalTableInfo

        static InternalTableInfo createInternalTableInfo​(Transaction transaction)
        Returns an InternalTableInfo object used to model the list of sequence generators that are accessible within the given Transaction object. This is used to model all sequence generators that have been defined as tables.