Class DiskBasedAttributeSetLogDatabase

java.lang.Object
modelarium.entities.logging.databases.AttributeSetLogDatabase
modelarium.entities.logging.databases.DiskBasedAttributeSetLogDatabase

public class DiskBasedAttributeSetLogDatabase extends AttributeSetLogDatabase
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 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:
      connect in class AttributeSetLogDatabase
    • disconnect

      public void disconnect()
      Closes the SQLite connection and deletes the database file.
      Specified by:
      disconnect in class AttributeSetLogDatabase
    • addAttributeValue

      public <T> void addAttributeValue(String attributeName, T attributeValue)
      Appends a value to the named attribute's stored series, remembering the value's class for later deserialisation.
      Specified by:
      addAttributeValue in class AttributeSetLogDatabase
      Type Parameters:
      T - the type of the value being appended
      Parameters:
      attributeName - the name of the attribute the value belongs to
      attributeValue - the value to append
    • setAttributeColumn

      public void setAttributeColumn(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.
      Specified by:
      setAttributeColumn in class AttributeSetLogDatabase
      Parameters:
      attributeName - the name of the attribute the values belong to
      attributeValues - the values to store as the attribute's series
    • getAttributeColumnAsList

      public List<Object> getAttributeColumnAsList(String attributeName)
      Retrieves the named attribute's stored series, deserialising each value to the attribute's remembered class.
      Specified by:
      getAttributeColumnAsList in class AttributeSetLogDatabase
      Parameters:
      attributeName - the name of the attribute whose series to retrieve
      Returns:
      the attribute's stored values in insertion order