Class DiskBasedAttributeSetLogDatabase
java.lang.Object
modelarium.entities.logging.databases.AttributeSetLogDatabase
modelarium.entities.logging.databases.DiskBasedAttributeSetLogDatabase
Concrete implementation of
AttributeSetLogDatabase that stores results
in an SQLite database file.
This implementation uses a stable row-based schema internally instead of dynamically altering table columns.
Each logical attribute "column" is stored as a named ordered series:
(series_name, position_index, value_json)
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new disk-based attribute set log database backed by a file in the system's temporary directory. -
Method Summary
Modifier and TypeMethodDescription<T> voidaddAttributeValue(String attributeName, T attributeValue) Appends a value to the named attribute's stored series, remembering the value's class for later deserialisation.voidconnect()Establishes an SQLite connection and creates the required table.voidCloses the SQLite connection and deletes the database file.getAttributeColumnAsList(String attributeName) Retrieves the named attribute's stored series, deserialising each value to the attribute's remembered class.voidsetAttributeColumn(String attributeName, List<Object> attributeValues) Replaces the named attribute's stored series with the given values, inferring the attribute's value type from the first non-null value.Methods inherited from class modelarium.entities.logging.databases.AttributeSetLogDatabase
getDatabasePath
-
Constructor Details
-
DiskBasedAttributeSetLogDatabase
public DiskBasedAttributeSetLogDatabase()Constructs a new disk-based attribute set log database backed by a file in the system's temporary directory.The instance is registered for automatic disconnect on JVM shutdown, with the shutdown hook created the first time any instance is constructed.
-
-
Method Details
-
connect
public void connect()Establishes an SQLite connection and creates the required table.- Specified by:
connectin classAttributeSetLogDatabase
-
disconnect
public void disconnect()Closes the SQLite connection and deletes the database file.- Specified by:
disconnectin classAttributeSetLogDatabase
-
addAttributeValue
Appends a value to the named attribute's stored series, remembering the value's class for later deserialisation.- Specified by:
addAttributeValuein classAttributeSetLogDatabase- Type Parameters:
T- the type of the value being appended- Parameters:
attributeName- the name of the attribute the value belongs toattributeValue- the value to append
-
setAttributeColumn
Replaces the named attribute's stored series with the given values, inferring the attribute's value type from the first non-null value.- Specified by:
setAttributeColumnin classAttributeSetLogDatabase- Parameters:
attributeName- the name of the attribute the values belong toattributeValues- the values to store as the attribute's series
-
getAttributeColumnAsList
Retrieves the named attribute's stored series, deserialising each value to the attribute's remembered class.- Specified by:
getAttributeColumnAsListin classAttributeSetLogDatabase- Parameters:
attributeName- the name of the attribute whose series to retrieve- Returns:
- the attribute's stored values in insertion order
-