Skip to main content
Version: 0.0.5 (stable)

agrag.common.data_models.graph_record.DeferredWrites

DeferredWrites(entries:list[tuple[str, dict[str, Any]]] = list()) -> None

Writes over committed rows, held until the job's commit transaction.

A job may write only rows it created. A write that reaches a committed row is not applied. The store records it here, and the commit transaction runs it after the job flips to committed, so a committed row changes together with the commit and never before. The list lives in the worker process. A crash before the commit transaction rolls the job back, which needs nothing from this list, and the commit transaction is atomic.

Attributes:

  • entries (list[tuple[str, dict[str, Any]]]) – Each deferred (query, parameters) in write order. Order matters: a survivor's text replays before its embedding.

Functions:

  • add – Defer one statement whose parameters already carry no job id.
  • add_unwritten – Defer the records whose result row says written is false.

add​

add(query:str, parameters:Mapping[str, Any]) -> None

Defer one statement whose parameters already carry no job id.

add_unwritten​

add_unwritten(query:str, records:Sequence[Mapping[str, Any]], rows:Sequence[Mapping[str, Any]], *, require_all:bool = True) -> int

Defer the records whose result row says written is false.

Parameters:

  • query (str) – The batched write query that produced rows.
  • records (Sequence[Mapping[str, Any]]) – The $records the query ran with.
  • rows (Sequence[Mapping[str, Any]]) – The rows it returned, each with id and written.
  • require_all (bool) – Whether replay must return one row per record. False for writes guarded by a text match, where a missing row means the guard failed.

Returns:

  • int – How many records were deferred.

entries​

entries: list[tuple[str, dict[str, Any]]] = field(default_factory=list)