loadContainerState

abstract suspend fun loadContainerState(userId: String): KarlContainerStateEntity?(source)

Retrieves the persisted container state for a specific user.

This method performs an indexed lookup to efficiently locate and deserialize the container state associated with the provided userId. The operation is optimized for single-user retrieval and returns null if no state exists for the user.

Query Optimization:

  • Primary key index ensures O(log n) lookup performance

  • Single-row limitation minimizes data transfer and memory usage

  • Lazy loading of related entities improves initial response time

Data Integrity:

  • Automatic deserialization validates stored state structure

  • Null-safe return type prevents unexpected runtime exceptions

  • Transactional consistency ensures atomic read operations

Return

The complete container state entity if found, null if no state exists for the user

Parameters

userId

Unique identifier for the user whose container state should be retrieved

See also

Structure of returned state data

Method for persisting container states

Throws

SQLException

If database query execution fails

DataCorruptionException

If stored state data cannot be deserialized