Class MemoryBasedAttributeSetLogDatabase

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

public class MemoryBasedAttributeSetLogDatabase extends AttributeSetLogDatabase
An in-memory implementation of AttributeSetLogDatabase.

This class stores all simulation results directly in RAM, using Java collections. It is useful for lightweight simulations, unit tests, or post-processing before output.

Unlike DiskBasedAttributeSetLogDatabase, this class does not persist results to disk.

  • Constructor Details

    • MemoryBasedAttributeSetLogDatabase

      public MemoryBasedAttributeSetLogDatabase()
      Constructs a new in-memory attribute set log database.
  • Method Details

    • connect

      public void connect()
      Opens this database for reading and writing.
      Specified by:
      connect in class AttributeSetLogDatabase
    • disconnect

      public void disconnect()
      Clears all stored series and recorded value types.
      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, checking that it matches the type of the values already stored.
      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 a copy of 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.
      Specified by:
      getAttributeColumnAsList in class AttributeSetLogDatabase
      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