An object cached in the data dictionary which manages new values for sequences. Note that this class must be public and have a 0-arg constructor in order to satisfy the Cacheable contract.
This is the abstract superclass of specific implementations for specific sequences. For instance, one subclass handles the ANSI/ISO sequences stored in SYSSEQUENCES. Another subclass could handle the sequences stored in Derby's identity columns.
This class does a couple tricky things:
Here is the algorithm pursued when the caller asks for the next number in a sequence:
| Modifier and Type | Class and Description |
|---|---|
| public static class | SequenceUpdater.
Implementation of SequenceUpdater for use with the bulk-insert optimization used by InsertResultSet. |
| public static class | SequenceUpdater.
Specific implementation of SequenceUpdater for the sequences managed by SYSSEQUENCES. |
| Modifier and Type | Field and Description |
|---|---|
| protected DataDictionaryImpl | |
| protected SequenceGenerator | _sequenceGenerator
This is the object which allocates ranges of sequence values |
| protected String | _uuidString
This is the key used to lookup this generator in the cache. |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | clean(boolean
True if the object will be removed forRemove)Implements org. Clean the object. |
| public void | clearIdentity()
Implements org. Put the object into the No Identity state. |
| public Cacheable | createIdentity(Object
The handle on the cacheable key, Object Creation details createParameter)Implements org. Create a new item. |
| protected abstract SequenceGenerator | |
| public synchronized SequenceUpdater. | getBulkInsertUpdater(boolean
True if the counter should be re-initialized to its start position. restart)Get the SequenceUpdater used for the bulk-insert optimization in InsertResultSet. |
| private static Context | getContextOrNull(final String contextID)
Must be private so that user code can't call this entry point. |
| private static ContextService | |
| public synchronized void | getCurrentValueAndAdvance(NumberDataValue
This value is stuffed with the new sequence number. returnValue)Get the next sequence number managed by this generator and advance the number. |
| public Object | getIdentity()
Implements org. Get the identity of this object. |
| private static LanguageConnectionContext | |
| public boolean | isDirty()
Implements org. Returns true if the object is dirty. |
| private boolean | |
| protected SequencePreallocator | makePreallocator(TransactionController tc)
Make a new range allocator (called when the generator is instantiated) |
| private StandardException | |
| public Long | |
| public synchronized void | |
| public Cacheable | setIdentity(Object
The handle on the cacheable key)Implements org. Set the identity of the object. |
| private StandardException | tooMuchContentionException()
Create an exception to state that there is too much contention on the generator. |
| private StandardException | |
| protected abstract boolean | Returns: Returns true if the value was successfully updated, false if we lost a race with another session.The transaction to use tc, Long Expected value on disk for this sequence oldValue, Long The value to poke into the system table backing this sequence newValue, boolean Whether to wait for a lock wait)Update the sequence value on disk. |
| public synchronized boolean | Returns: Returns true if the value was successfully updated, false if we lost a race with another session.Update the value on disk. |
| _dd | back to summary |
|---|---|
| protected DataDictionaryImpl _dd | |
| _sequenceGenerator | back to summary |
|---|---|
| protected SequenceGenerator _sequenceGenerator This is the object which allocates ranges of sequence values | |
| _uuidString | back to summary |
|---|---|
| protected String _uuidString This is the key used to lookup this generator in the cache. | |
| SequenceUpdater | back to summary |
|---|---|
| public SequenceUpdater() No-arg constructor to satisfy the Cacheable contract | |
| SequenceUpdater | back to summary |
|---|---|
| public SequenceUpdater(DataDictionaryImpl dd) Normal constructor | |
| clean | back to summary |
|---|---|
| public void clean(boolean forRemove) throws StandardException Implements org. Doc from org. Clean the object.
It is up to the object to ensure synchronization of the isDirty()
and clean() method calls.
| |
| clearIdentity | back to summary |
|---|---|
| public void clearIdentity() Implements org. Doc from org. Put the object into the No Identity state.
| |
| createIdentity | back to summary |
|---|---|
| public Cacheable createIdentity(Object key, Object createParameter) throws StandardException Implements org. Doc from org. Create a new item.
Create a new item and set the identity of the object to represent it.
The object will be in the No Identity state,
ie. it will have just been created or clearIdentity() was just called.
| |
| createSequenceGenerator | back to summary |
|---|---|
| protected abstract SequenceGenerator createSequenceGenerator(TransactionController readOnlyTC) throws StandardException Initialize the sequence generator. Work is done inside a read-only subtransaction of the session's execution transaction. | |
| getBulkInsertUpdater | back to summary |
|---|---|
| public synchronized SequenceUpdater. Get the SequenceUpdater used for the bulk-insert optimization in InsertResultSet.
| |
| getContextOrNull | back to summary |
|---|---|
| private static Context getContextOrNull(final String contextID) Must be private so that user code can't call this entry point. | |
| getContextService | back to summary |
|---|---|
| private static ContextService getContextService() Must be private so that user code can't call this entry point. | |
| getCurrentValueAndAdvance | back to summary |
|---|---|
| public synchronized void getCurrentValueAndAdvance(NumberDataValue returnValue) throws StandardException Get the next sequence number managed by this generator and advance the number. Could raise an exception if the legal range is exhausted and wrap-around is not allowed. Only one thread at a time is allowed through here. We do not want a race between the two calls to the sequence generator: getCurrentValueAndAdvance() and allocateNewRange().
| |
| getIdentity | back to summary |
|---|---|
| public Object getIdentity() Implements org. Doc from org. Get the identity of this object.
| |
| getLCC | back to summary |
|---|---|
| private static LanguageConnectionContext getLCC() | |
| isDirty | back to summary |
|---|---|
| public boolean isDirty() Implements org. Doc from org. Returns true if the object is dirty.
May be called when the object is kept or unkept.
| |
| isNumber | back to summary |
|---|---|
| private boolean isNumber(String text) | |
| makePreallocator | back to summary |
|---|---|
| protected SequencePreallocator makePreallocator(TransactionController tc) throws StandardException Make a new range allocator (called when the generator is instantiated) | |
| missingAllocator | back to summary |
|---|---|
| private StandardException missingAllocator(String propertyName, String className, Exception e) | |
| peekAtCurrentValue | back to summary |
|---|---|
| public Long peekAtCurrentValue() throws StandardException Get the current value of the sequence generator without advancing it. May return null if the generator is exhausted. | |
| reset | back to summary |
|---|---|
| public synchronized void reset(Long newValue) throws StandardException Reset the sequence generator to a new start value. This is used by the special bulk-insert optimization in InsertResultSet. | |
| setIdentity | back to summary |
|---|---|
| public Cacheable setIdentity(Object key) throws StandardException Implements org. Doc from org. Set the identity of the object.
Set the identity of the object to represent an item that already exists,
e.g. an existing container.
The object will be in the No Identity state,
ie. it will have just been created or clearIdentity() was just called.
| |
| tooMuchContentionException | back to summary |
|---|---|
| private StandardException tooMuchContentionException() Create an exception to state that there is too much contention on the generator. For backward compatibility reasons, different messages are needed by sequences and identities. See DERBY-5426. | |
| unimplementedFeature | back to summary |
|---|---|
| private StandardException unimplementedFeature() Report an unimplemented feature | |
| updateCurrentValueOnDisk | back to summary |
|---|---|
| protected abstract boolean updateCurrentValueOnDisk(TransactionController tc, Long oldValue, Long newValue, boolean wait) throws StandardException Update the sequence value on disk. This method does its work in a subtransaction of the user's execution transaction.
| |
| updateCurrentValueOnDisk | back to summary |
|---|---|
| public synchronized boolean updateCurrentValueOnDisk(Long oldValue, Long newValue) throws StandardException Update the value on disk. Does its work in a subtransaction of the user's execution transaction. If that fails, raises a TOO MUCH CONTENTION exception.
| |
Implementation of SequenceUpdater for use with the bulk-insert optimization used by InsertResultSet. This BulkInsertUpdater doesn't really write to disk. It is assumed that the BulkInsertUpdater will only be used by the bulk-insert code, where the user has exclusive write-access on the table whose identity column is backed by the original SequenceUpdater. At the end of bulk-insert, the current value of the BulkInsertUpdater is written to disk by other code.
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected SequenceGenerator | createSequenceGenerator(TransactionController readOnlyTC)
Implements abstract org. Initialize the sequence generator. |
| protected boolean | updateCurrentValueOnDisk(TransactionController
The transaction to use tc, Long Expected value on disk for this sequence oldValue, Long The value to poke into the system table backing this sequence newValue, boolean Whether to wait for a lock wait)Implements abstract org. Update the sequence value on disk. |
| BulkInsertUpdater | back to summary |
|---|---|
| public BulkInsertUpdater() | |
| BulkInsertUpdater | back to summary |
|---|---|
| public BulkInsertUpdater(SequenceUpdater originalUpdater, boolean restart) | |
| createSequenceGenerator | back to summary |
|---|---|
| protected SequenceGenerator createSequenceGenerator(TransactionController readOnlyTC) throws StandardException Implements abstract org. Doc from org. Initialize the sequence generator. Work is done inside a read-only subtransaction of the session's execution transaction. | |
| updateCurrentValueOnDisk | back to summary |
|---|---|
| protected boolean updateCurrentValueOnDisk(TransactionController tc, Long oldValue, Long newValue, boolean wait) throws StandardException Implements abstract org. Doc from org. Update the sequence value on disk. This method does its work in a subtransaction of the user's execution transaction.
| |
Specific implementation of SequenceUpdater for the sequences managed by SYSSEQUENCES.
| Modifier and Type | Field and Description |
|---|---|
| private RowLocation |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected SequenceGenerator | createSequenceGenerator(TransactionController readOnlyTC)
Implements abstract org. Initialize the sequence generator. |
| protected boolean | updateCurrentValueOnDisk(TransactionController
The transaction to use tc, Long Expected value on disk for this sequence oldValue, Long The value to poke into the system table backing this sequence newValue, boolean Whether to wait for a lock wait)Implements abstract org. Update the sequence value on disk. |
| _sequenceRowLocation | back to summary |
|---|---|
| private RowLocation _sequenceRowLocation | |
| SyssequenceUpdater | back to summary |
|---|---|
| public SyssequenceUpdater() | |
| SyssequenceUpdater | back to summary |
|---|---|
| public SyssequenceUpdater(DataDictionaryImpl dd) | |
| createSequenceGenerator | back to summary |
|---|---|
| protected SequenceGenerator createSequenceGenerator(TransactionController readOnlyTC) throws StandardException Implements abstract org. Doc from org. Initialize the sequence generator. Work is done inside a read-only subtransaction of the session's execution transaction. | |
| updateCurrentValueOnDisk | back to summary |
|---|---|
| protected boolean updateCurrentValueOnDisk(TransactionController tc, Long oldValue, Long newValue, boolean wait) throws StandardException Implements abstract org. Doc from org. Update the sequence value on disk. This method does its work in a subtransaction of the user's execution transaction.
| |