pub struct Writer<'s> { /* private fields */ }Expand description
The exclusive write handle; holds the store’s writer mutex for its
lifetime. Stage mutations, then Writer::commit to make them durable
and visible.
Implementations§
Source§impl<'s> Writer<'s>
impl<'s> Writer<'s>
Sourcepub fn upsert_node(&mut self, doc: &DocRecord<'_>) -> Result<()>
pub fn upsert_node(&mut self, doc: &DocRecord<'_>) -> Result<()>
Stage a node create/replace.
Sourcepub fn set_segments(
&mut self,
key: UrlKey,
segs: &[SegmentRecord<'_>],
) -> Result<()>
pub fn set_segments( &mut self, key: UrlKey, segs: &[SegmentRecord<'_>], ) -> Result<()>
Stage a whole-set segment replacement for key.
Sourcepub fn set_edges(&mut self, key: UrlKey, edges: &[(UrlKey, EdgeType, u16)])
pub fn set_edges(&mut self, key: UrlKey, edges: &[(UrlKey, EdgeType, u16)])
Stage a whole-set outbound-edge replacement for key. Edges are
deduplicated by destination (first occurrence wins — document order is
salience order) and stored sorted by destination key.
Sourcepub fn set_edges_with_flags(
&mut self,
key: UrlKey,
edges: &[(UrlKey, EdgeType, u16, u8)],
)
pub fn set_edges_with_flags( &mut self, key: UrlKey, edges: &[(UrlKey, EdgeType, u16, u8)], )
Writer::set_edges with per-edge flags; only caller-settable ones
are kept (eflags::EXACT: an unchanged copy along Derives).
Sourcepub fn set_attrs(&mut self, key: UrlKey, attrs: &[(u8, &str)]) -> Result<()>
pub fn set_attrs(&mut self, key: UrlKey, attrs: &[(u8, &str)]) -> Result<()>
Stage a whole-set replacement of key’s attributes: small keyed
values beside the node (a column’s type, a table’s producing SQL, a
description’s provenance). Keys are the caller’s; a later key wins
over an earlier duplicate. Values longer than MAX_ATTR_LEN, more
than MAX_ATTRS keys, or a set whose encoding would not fit one log
frame (MAX_ATTR_BYTES in total) are refused.
Sourcepub fn set_named_attrs(
&mut self,
key: UrlKey,
attrs: &[(&str, &str)],
) -> Result<()>
pub fn set_named_attrs( &mut self, key: UrlKey, attrs: &[(&str, &str)], ) -> Result<()>
Writer::set_attrs with string names: a whole-set replacement of
key’s attributes as name → value. Each record is stored as
name NUL value under keys 0..n in name order, so
crate::Snapshot::named_attrs reads names and values back as
borrowed slices and any producer (Rust or a binding) agrees on the
encoding. A later duplicate name wins. Names must be non-empty, at
most MAX_ATTR_NAME bytes and free of NUL; each name NUL value
must fit MAX_ATTR_LEN, and the whole set MAX_ATTR_BYTES.
Sourcepub fn touch(&mut self, key: UrlKey, t: Touch<'_>) -> Result<bool>
pub fn touch(&mut self, key: UrlKey, t: Touch<'_>) -> Result<bool>
Record a revalidation outcome. Freshness policy (interval growth/cut,
counters) is computed here from the node’s current state and the store’s
crate::TtlConfig, and the resulting op carries the node’s full
effective state so replay never re-derives policy.
Returns false, staging nothing, when key is not a committed node.
That is the important word: the state is read through a snapshot, which
sees committed ops only, so a node staged earlier in this same batch is
not yet visible. Commit the upsert before touching it — the link-r bridge
already does.
The same rule means two touches of one key inside a single uncommitted
batch do not accumulate: both are computed from the pre-batch state and
the second wins under last-wins overlay folding. Commit between
observations of the same document. Pinned by touch_requires_a_committed_node
in tests/regression.rs.
Sourcepub fn set_pinned(&mut self, key: UrlKey, pinned: bool) -> Result<bool>
pub fn set_pinned(&mut self, key: UrlKey, pinned: bool) -> Result<bool>
Stage a pin/unpin. Returns false (staging nothing) when key is
neither committed nor upserted earlier in this same batch — a pin on a
document that does not exist must not lie in wait for a future upsert.
Sourcepub fn commit(&mut self) -> Result<u64>
pub fn commit(&mut self) -> Result<u64>
Make staged ops durable and visible: encode frames, append to the
WAL, fsync per the configured Durability, publish to the overlay,
then auto-compact past thresholds. Returns the last committed
sequence number.