saveContainerState

abstract suspend fun saveContainerState(stateEntity: KarlContainerStateEntity)(source)

Persists the complete container state for a specific user to the database.

This method provides atomic storage of all KARL container state data, including neural network weights, learned patterns, user preferences, and performance metrics. The operation uses optimized serialization to ensure data integrity and supports both initial storage and subsequent updates through the primary key constraint.

Performance Considerations:

  • State data is compressed before storage to optimize disk usage

  • Uses database transactions to ensure atomicity of complex state operations

  • Supports concurrent access through proper isolation levels

Data Integrity:

  • Validates state structure before persistence

  • Maintains referential integrity with related user data

  • Supports rollback operations in case of corruption

Parameters

stateEntity

The complete container state to persist, including all learning models, configuration parameters, and temporal metadata

See also

Entity structure and validation requirements

Corresponding retrieval operation

Throws

SQLException

If database constraints are violated or connection fails

IllegalArgumentException

If stateEntity contains invalid data structures