Class TableSerialExpirationBacklog
java.lang.Object
org.tentackle.dbms.TableSerialExpirationBacklog
Keeps a backlog of expiration sets.
An expiration set holds the id/tableserial tuples of the objects modified within a range of tableserials. The sets are kept round-robin, so that caches asking for the same range repeatedly do not have to query the database. If a range is requested that is older than the oldest set, the backlog is enlarged (up to a maximum size) and the caller must query the database.
In the server connected to the database, the sets are merged with the TableSerialHistory
to fill the gaps caused by deletions, rollbacks, and multiple updates.
- Author:
- harald
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a backlog with a default size.TableSerialExpirationBacklog(String name, int size) Creates a backlog. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExpiration(long minSerial, long maxSerial, Collection<IdSerialTuple> tuples, boolean mergeHistory) Adds an expiration set to the backlog.protected intenlargeSize(int size) Computes the enlarged size.
Invoked when there is an outdated query.getExpiration(long minSerial, long maxSerial) Gets the expiration backlog for a given range of table-serials.
An id of 0 indicates a rolled back insert or update.
A negative tableserial indicates a deletion.toString()
-
Constructor Details
-
TableSerialExpirationBacklog
Creates a backlog.- Parameters:
name- the name of the backlogsize- the size of the backlog
-
TableSerialExpirationBacklog
Creates a backlog with a default size.- Parameters:
name- the name of the backlog
-
-
Method Details
-
toString
-
addExpiration
public void addExpiration(long minSerial, long maxSerial, Collection<IdSerialTuple> tuples, boolean mergeHistory) Adds an expiration set to the backlog.- Parameters:
minSerial- the lower serial bound of the query (minSerial < tableSerial)maxSerial- the upper serial bound of the query (tableSerial ≤ maxSerial)tuples- the expiration info as pairs of id/tableserial.mergeHistory- true to merge theTableSerialHistory
-
getExpiration
Gets the expiration backlog for a given range of table-serials.
An id of 0 indicates a rolled back insert or update.
A negative tableserial indicates a deletion.- Parameters:
minSerial- the lower serial bound of the query (minSerial < tableSerial)maxSerial- the upper serial bound of the query (tableSerial ≤ maxSerial)- Returns:
- the expiration set as tuples of id/tableserial, ordered by abs(tableserial), null if the given range was not found in the backlog
-
enlargeSize
protected int enlargeSize(int size) Computes the enlarged size.
Invoked when there is an outdated query.- Parameters:
size- the current size- Returns:
- the enlarged size, same if no more enlargement possible
-