A 'hilo' algorithm is simply a means for a single value stored in the database to represent a "bucket" of possible, contiguous values. The database value identifies which particular bucket we are on.
This database value must be paired with another value that defines the
size of the bucket; the number of possible values available.
The incrementSize serves this purpose. The
naming here is meant more for consistency in that this value serves the
same purpose as the increment supplied to the PooledOptimizer.
The general algorithms used to determine the bucket are:
upperLimit = (databaseValue * incrementSize) + 1lowerLimit = upperLimit - incrementSizeupperLimit = (1 * 20) + 1 = 21lowerLimit = 21 - 20 = 1upperLimit = (2 * 20) + 1 = 41lowerLimit = 41 - 20 = 21Note, 'value' always (after init) holds the next value to return
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final Logger | |
| private HiLoOptimizer. | |
| private Map |
| Access | Constructor and Description |
|---|---|
| public | HiLoOptimizer(Class<T>
The Java type of the values to be generated returnClass, int The increment size. incrementSize)Constructs a HiLoOptimizer |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | applyIncrementSizeToSourceValues()
Implements org. |
| public synchronized Serializable | generate(AccessCallback
Callback to access the underlying value source. callback)Implements org. |
| public synchronized IntegralDataTypeHolder | |
| public synchronized IntegralDataTypeHolder | getLastSourceValue()
Implements org. |
| public synchronized IntegralDataTypeHolder | |
| private HiLoOptimizer. | |
| private HiLoOptimizer. |
| log | back to summary |
|---|---|
| private static final Logger log | |
| noTenantState | back to summary |
|---|---|
| private HiLoOptimizer. | |
| tenantSpecificState | back to summary |
|---|---|
| private Map<String, HiLoOptimizer. | |
| HiLoOptimizer | back to summary |
|---|---|
| public HiLoOptimizer(Class<T> returnClass, int incrementSize) Constructs a HiLoOptimizer
| |
| applyIncrementSizeToSourceValues | back to summary |
|---|---|
| public boolean applyIncrementSizeToSourceValues() Implements org. Doc from org. Are increments to be applied to the values stored in the underlying value source?
| |
| generate | back to summary |
|---|---|
| public synchronized Serializable generate(AccessCallback callback) Implements org. Doc from org. Generate an identifier value accounting for this specific optimization. All known implementors are synchronized. Consider carefully if a new implementation could drop this requirement.
| |
| getHiValue | back to summary |
|---|---|
| public synchronized IntegralDataTypeHolder getHiValue() Getter for property 'upperLimit'. Exposure intended for testing purposes.
| |
| getLastSourceValue | back to summary |
|---|---|
| public synchronized IntegralDataTypeHolder getLastSourceValue() Implements org. Doc from org. A common means to access the last value obtained from the underlying source. This is intended for testing purposes, since accessing the underlying database source directly is much more difficult.
| |
| getLastValue | back to summary |
|---|---|
| public synchronized IntegralDataTypeHolder getLastValue() Getter for property 'lastValue'. Exposure intended for testing purposes.
| |
| locateGenerationState | back to summary |
|---|---|
| private HiLoOptimizer. | |
| noTenantGenerationState | back to summary |
|---|---|
| private HiLoOptimizer. | |
| Modifier and Type | Field and Description |
|---|---|
| private IntegralDataTypeHolder | |
| private IntegralDataTypeHolder | |
| private IntegralDataTypeHolder |
| Access | Constructor and Description |
|---|---|
| private |
| lastSourceValue | back to summary |
|---|---|
| private IntegralDataTypeHolder lastSourceValue | |
| upperLimit | back to summary |
|---|---|
| private IntegralDataTypeHolder upperLimit | |
| value | back to summary |
|---|---|
| private IntegralDataTypeHolder value | |
| GenerationState | back to summary |
|---|---|
| private GenerationState() | |