Class AttributeSetLogDatabase
java.lang.Object
modelarium.entities.logging.databases.AttributeSetLogDatabase
- Direct Known Subclasses:
DiskBasedAttributeSetLogDatabase,MemoryBasedAttributeSetLogDatabase
Abstract base class representing a database for storing and retrieving simulation results
related to attribute sets, including properties and event values.
Concrete implementations may write to in-memory structures, files, or external systems. Every implementation follows the same observable contract:
connect()must be called before reading or writing;- connecting and disconnecting are idempotent;
- disconnecting discards the stored data, so reconnecting starts with an empty store;
- a missing or cleared series is returned as an empty list;
- null values are preserved but do not establish a series type;
- the first non-null appended value establishes the series type;
- all subsequent appended values must be instances of that type;
- replacing a series establishes a new type from its first non-null value and requires every other non-null value in the replacement to have that type; and
- inputs are copied on write and results are copied on read.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new attribute set log database with no backing file.AttributeSetLogDatabase(String databasePath) Constructs a new attribute set log database backed by a file at the specified path. -
Method Summary
Modifier and TypeMethodDescriptionabstract <T> voidaddAttributeValue(String attributeName, T attributeValue) Appends a value to the named attribute's stored series.abstract voidconnect()Opens the database ready for reading and writing.abstract voidCloses the database, discards all stored data and releases any held resources.getAttributeColumnAsList(String attributeName) Retrieves the named attribute's stored series.Returns the path of the database's backing file.abstract voidsetAttributeColumn(String attributeName, List<Object> propertyValues) Replaces the named attribute's stored series with the given values.
-
Constructor Details
-
AttributeSetLogDatabase
Constructs a new attribute set log database backed by a file at the specified path.- Parameters:
databasePath- the path of the database's backing file
-
AttributeSetLogDatabase
public AttributeSetLogDatabase()Constructs a new attribute set log database with no backing file.
-
-
Method Details
-
getDatabasePath
Returns the path of the database's backing file.- Returns:
- the database's file path, or null if the database has no backing file
-
connect
public abstract void connect()Opens the database ready for reading and writing.Repeated calls while connected must have no effect and must preserve stored values.
-
disconnect
public abstract void disconnect()Closes the database, discards all stored data and releases any held resources.Repeated calls while disconnected must have no effect.
-
addAttributeValue
Appends a value to the named attribute's stored series. Must be implemented by subclasses.- 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. Must be implemented by subclasses.- Parameters:
attributeName- the name of the attribute the values belong topropertyValues- the values to store as the attribute's series
-
getAttributeColumnAsList
Retrieves the named attribute's stored series. Must be implemented by subclasses.- Parameters:
attributeName- the name of the attribute whose series to retrieve- Returns:
- a detached list containing the attribute's stored values in insertion order, or an empty list when the series does not exist
-