|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.util.CompoundClosableAllocation net.sf.farrago.catalog.FarragoSequenceAccessor
public class FarragoSequenceAccessor
A FarragoSequenceAccessor optimizes access to sequences. A sequence generates new values on a per-row basis. But a sequence is not updated after every row (because that would be very slow.) Instead, an accessor reserves a large cache of values which it quickly allocates.
The accessor synchronizes access so multiple clients can use the sequence at the same time. However this requires clients to obtain an accessor from the singleton method FarragoRepos.getSequenceAccessor()
To clean up properly after a statement is completed or the database is
shutdown, unreserve()
should be called to release unused values.
Due to the use of singleton sequence accessors, sequence accessors may exist for a long time.
Field Summary | |
---|---|
private boolean |
ascending
|
private boolean |
cycle
|
private long |
increment
|
private long |
lastReservedValue
|
private long |
max
|
private static long |
MAX_RESERVATION_SIZE
|
private long |
min
|
private String |
mofId
|
static String |
NEXT_VALUE_METHOD_NAME
|
private Long |
nextReservedValue
|
private FarragoRepos |
repos
|
private boolean |
reserved
|
Fields inherited from class org.eigenbase.util.CompoundClosableAllocation |
---|
allocations |
Constructor Summary | |
---|---|
protected |
FarragoSequenceAccessor(FarragoRepos repos,
String sequenceMofId)
Constructs a FarragoSequenceAccessor |
Method Summary | |
---|---|
void |
alterSequence(FarragoSequenceOptions options,
RelDataType dataType)
Modifies a sequence and loads updated fields. |
void |
closeAllocation()
Deallocates unused sequence values. |
private String |
getName()
Returns the name of the sequence |
long |
getNext()
Retrieves a value from the sequence, possibly reserving more values in the process. |
private FemSequenceGenerator |
getSequence()
Retrieves the underlying sequence from the catalog |
private void |
loadSequence(FemSequenceGenerator sequence)
Initializes the sequence accessor from a sequence. |
private void |
reserve()
Reserves up to MAX_RESERVATION_SIZE values in the sequence. |
private void |
reserveInternal()
|
private void |
unreserve()
Returns values unused by the sequence accessor to the catalog |
Methods inherited from class org.eigenbase.util.CompoundClosableAllocation |
---|
addAllocation, forgetAllocation, hasAllocations |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static String NEXT_VALUE_METHOD_NAME
private static long MAX_RESERVATION_SIZE
private final FarragoRepos repos
private final String mofId
private long increment
private long min
private long max
private boolean cycle
private boolean ascending
private boolean reserved
private Long nextReservedValue
private long lastReservedValue
Constructor Detail |
---|
protected FarragoSequenceAccessor(FarragoRepos repos, String sequenceMofId)
repos
- the farrago repository containing the sequencesequenceMofId
- the id of the sequence within the repositoryMethod Detail |
---|
private void loadSequence(FemSequenceGenerator sequence)
sequence
- up to date sequencepublic void closeAllocation()
closeAllocation
in interface ClosableAllocation
closeAllocation
in class CompoundClosableAllocation
public long getNext()
EigenbaseException
- if the sequence has no more valuespublic void alterSequence(FarragoSequenceOptions options, RelDataType dataType)
options
- specifies fields to be modifieddataType
- the data type of the sequenceprivate void reserve()
MAX_RESERVATION_SIZE
values in the sequence.
Updates the baseValue of a sequence in the catalog sequence to the first
valid unreserved value.
If the reservation was successful, then nextReservedValue
will be set to a non-null value.
private void reserveInternal()
private void unreserve()
private FemSequenceGenerator getSequence()
private String getName()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |