public class LoggedCollection
extends java.lang.Object
On incremental conversion, this allows restoration of the collection's state, without the currently parsed and converted ASTs.
All changes are stored in a work table, which has the same name as the main collection's table,
followed by a __work suffix.
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
LoggedCollection.AstKey
A key for a logged change, in a collection.
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.Map<LoggedCollection.AstKey,java.lang.Object> |
changes
The changes made to this collection.
|
private java.util.Map<LoggedCollection.AstKey,java.lang.Object> |
forced
Force certain values to be logged for a source AST.
|
| Constructor and Description |
|---|
LoggedCollection() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear all changes.
|
void |
compact(long fileId,
java.util.function.Consumer<CustomExternalizable> c)
Compact the elements of this collection, to reduce the memory footprint.
|
void |
force(long fileId,
long astId,
java.lang.Object key,
java.lang.Object value)
Force a change to be logged for the specified source AST.
|
void |
log(long fileId,
long astId,
java.lang.Object key)
Log this change being made to the collection.
|
void |
log(long fileId,
long astId,
java.lang.Object key,
java.lang.Object value)
Log this change being made to the collection.
|
void |
persist(java.sql.PreparedStatement ps,
java.util.function.BiFunction<LoggedCollection.AstKey,java.lang.Object,java.lang.Object[]> c)
Persist all changes to the database, using the specified statement.
|
void |
persist(java.lang.String insertSql,
DBHelper helper,
java.util.function.BiFunction<LoggedCollection.AstKey,java.lang.Object,java.lang.Object[]> c)
Persist all changes to the database.
|
void |
remove(java.lang.Object key)
Remove all changes having this key.
|
void |
retainAll(java.util.Set<?> keys)
Given a set of keys, retain from the changes only those for which the key exists in this set.
|
private final java.util.Map<LoggedCollection.AstKey,java.lang.Object> changes
private final java.util.Map<LoggedCollection.AstKey,java.lang.Object> forced
public void log(long fileId,
long astId,
java.lang.Object key,
java.lang.Object value)
fileId - The AST file ID.astId - The source AST ID.key - The collection key.value - The value, which is non-null only for maps.public void log(long fileId,
long astId,
java.lang.Object key)
fileId - The AST file ID.astId - The source AST ID.key - The collection key.public void force(long fileId,
long astId,
java.lang.Object key,
java.lang.Object value)
fileId - The AST file ID.astId - The source AST ID.key - The collection key.value - The value, which is non-null only for maps.public void remove(java.lang.Object key)
key - The key to be removed.public void retainAll(java.util.Set<?> keys)
This allows the changes to be 'in sync' with the main collection, as certain remove operations on the main collection may not have been logged to the collection.
keys - The keys which need to be retained.public void clear()
public void persist(java.lang.String insertSql,
DBHelper helper,
java.util.function.BiFunction<LoggedCollection.AstKey,java.lang.Object,java.lang.Object[]> c)
insertSql - The SQL used to insert into the table.helper - The helper to perform SQL operations.c - A consumer to resolve the arguments for the insert statement.public void persist(java.sql.PreparedStatement ps,
java.util.function.BiFunction<LoggedCollection.AstKey,java.lang.Object,java.lang.Object[]> c)
throws java.sql.SQLException
ps - The prepared insert statement.c - A consumer to resolve the arguments for the insert statement.java.sql.SQLException - For SQL-related errors when setting the statement arguments.public void compact(long fileId,
java.util.function.Consumer<CustomExternalizable> c)
fileId - The AST file ID which has finished processing.c - A consumer to process the values.