Class TableSerialExpirationBacklog

java.lang.Object
org.tentackle.dbms.TableSerialExpirationBacklog

public class TableSerialExpirationBacklog extends Object
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 Details

    • TableSerialExpirationBacklog

      public TableSerialExpirationBacklog(String name, int size)
      Creates a backlog.
      Parameters:
      name - the name of the backlog
      size - the size of the backlog
    • TableSerialExpirationBacklog

      public TableSerialExpirationBacklog(String name)
      Creates a backlog with a default size.
      Parameters:
      name - the name of the backlog
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • 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 the TableSerialHistory
    • getExpiration

      public TreeSet<IdSerialTuple> 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.
      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