final class RepositionCache
extends java.lang.Object
For fast lookup, entries are actually stored in a tree structure, where each node in the tree stores a single primary key ID and a result set row number. An individual node represents a record within a single table. Its children represent associated records in joined tables, and so on.
Modifier and Type | Class and Description |
---|---|
private static class |
RepositionCache.Node
Internal data structure which represents a single record ID and an
associated result set row index for the virtual, composite row
containing that record.
|
Modifier and Type | Field and Description |
---|---|
private RepositionCache.Node |
root
Root node which does not actually represent a record
|
private int |
size
Number of virtual record entries stored in the cache
|
Constructor and Description |
---|
RepositionCache()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
(package private) void |
add(java.io.Serializable[] ids,
int row)
Add a single entry to the cache.
|
(package private) void |
clear()
Clear all entries from the cache.
|
private void |
decrementRowIndexes(RepositionCache.Node node,
int lowerLimit)
Decrement by 1 row indexes for all entries stored under the specified node which have row
index greater than the specified lower limit.
|
private void |
dumpNode(int indent,
RepositionCache.Node node,
java.lang.StringBuilder buf)
Dump a string representation of the node into the given string builder.
|
(package private) int |
getRow(java.io.Serializable[] ids)
Retrieve the row number associated with the given array of primary key
IDs.
|
(package private) boolean |
remove(java.io.Serializable[] ids)
Remove the single entry from the cache.
|
(package private) int |
size()
Return the number of entries currently stored in the cache.
|
java.lang.String |
toString()
Produce a string representation of the cache, which dumps each node in
the tree.
|
private RepositionCache.Node root
private int size
public java.lang.String toString()
toString
in class java.lang.Object
private void dumpNode(int indent, RepositionCache.Node node, java.lang.StringBuilder buf)
indent
- Number of characters to indent the current node's information
in the string builder.node
- Node being visited and dumped.buf
- Target string builder.void add(java.io.Serializable[] ids, int row)
ids
- Array of primary keys which represent a virtual, joined row of
results in the associated query's result set.row
- Zero-based index of the virtual row in the result set.boolean remove(java.io.Serializable[] ids)
ids
- Array of primary keys which represent a virtual, joined row of results in the
associated query's result set that should be deleted.true
if the entry was deleted, false
if there is no entry
associated with the given IDs.int getRow(java.io.Serializable[] ids)
ids
- Array of primary keys which represent a virtual, joined row of
results in the associated query's result set. This array may
contain fewer elements than there are records represented by a
virtual row in the result set; however, it may not be
null
.int size()
void clear()
private void decrementRowIndexes(RepositionCache.Node node, int lowerLimit)
node
- Root node to be processed.lowerLimit
- Row numbers greater than this number will be decremented.