pub struct ConnTable { /* private fields */ }Expand description
A source’s connection registry: the Connections plus a generational
free-list, so a torn-down connection’s slot is RECYCLED rather than leaked under
query churn (the source-side analogue of the graph arena’s node/storage reuse).
Shared by both Source backends (the memory BTree leaf
and the SQLite TableSource) so the reuse logic — and its stale-ConnId
fail-fast — lives in exactly one place and the two backends cannot drift apart.
The push fan-out iterates borrow directly (no ConnId), so it
is unaffected by the generation; a slot freed but not yet reused has
output == None and is skipped by the fan-out exactly as before.
Implementations§
Source§impl ConnTable
impl ConnTable
pub fn new() -> ConnTable
Sourcepub fn connect(&self, conn: Connection) -> ConnId
pub fn connect(&self, conn: Connection) -> ConnId
Register conn, reusing a freed slot if one is available — its generation was
bumped at free time, so the returned ConnId is distinct from the slot’s prior
tenant; otherwise grow the table with a fresh generation-0 slot.
Sourcepub fn destroy(&self, conn: ConnId)
pub fn destroy(&self, conn: ConnId)
Disconnect a connection — null its output edge so the push fan-out skips it — and free its slot for reuse (bump generation + add to the free-list). Idempotent and stale-safe: a non-matching generation (a double teardown / already-freed slot) is a no-op, never a panic, since teardown must be forgiving.
Sourcepub fn live_ix(&self, conn: ConnId) -> usize
pub fn live_ix(&self, conn: ConnId) -> usize
The slot index for conn, fail-fasting on a stale generation (the connection
analogue of Graph::node/storage). Release-checked.
Sourcepub fn set_output(&self, conn: ConnId, edge: OutEdge)
pub fn set_output(&self, conn: ConnId, edge: OutEdge)
Set a connection’s downstream output edge (gen-checked).
Sourcepub fn borrow(&self) -> Ref<'_, Vec<Connection>>
pub fn borrow(&self) -> Ref<'_, Vec<Connection>>
Borrow the connection vector — for the push fan-out and per-connection reads
(callers that already hold a live_ix).
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Total connection slots, including freed (recyclable) ones. With slot reuse this stays bounded by the peak live-connection count across a source’s life — it does NOT grow per teardown. (The push fan-out’s per-change cost is proportional to this, so keeping it bounded is the point of the free-list.)
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the table has no slots yet (clippy’s len-without-is_empty companion).
Sourcepub fn live_conn_count(&self) -> usize
pub fn live_conn_count(&self) -> usize
Number of connections with a live downstream edge (current readers). A destroyed slot
has its output nulled (destroy), so this counts only live
pipelines — used by Graph::remove_source to refuse removing a
source a query still reads.
Sourcepub fn push_candidates(&self, change: &SourceChange) -> Vec<u32>
pub fn push_candidates(&self, change: &SourceChange) -> Vec<u32>
The slots that may satisfy change — a superset by construction
(designs/205-GUARDED-PUSH-FANOUT-DESIGN.md §safety). Sorted ascending and
deduped, so the push fan-out visits in slot order exactly as the full-scan
loop did. Takes a short immutable borrow of the index that is released before
it returns, so the drain can hold the conns borrow without index contention.
Sourcepub fn split_edit_keys(&self) -> Vec<ColId> ⓘ
pub fn split_edit_keys(&self) -> Vec<ColId> ⓘ
The distinct split-edit keys across all connections (refcounted union). Drives
the gen_push_and_write_with_split_edit trigger check at O(distinct keys)
instead of O(N·keys).
Sourcepub fn has_split_edit_keys(&self) -> bool
pub fn has_split_edit_keys(&self) -> bool
true iff some connection lists a split-edit key — lets the edit-split path
skip the value-comparison check entirely when no connection needs it.
Sourcepub fn add_guard_value(&self, conn: ConnId, value: OwnedValue)
pub fn add_guard_value(&self, conn: ConnId, value: OwnedValue)
Add a dynamic guard value to conn’s push-index registration (design 310
§4.1 — a family root’s binding set growing): the connection becomes a push
candidate for writes whose guard column carries value. The column is the
connection’s own static PushGuard::col (the family builder registers the
root with an empty-valued guard on the first parameter column). Gen-checked;
only between pushes (asserted). A connection with no guard column is in the
always-visited scan list already, so there is nothing to add.
Sourcepub fn remove_guard_value(&self, conn: ConnId, value: &OwnedValue)
pub fn remove_guard_value(&self, conn: ConnId, value: &OwnedValue)
Remove one dynamic guard value previously added with
add_guard_value. Gen-checked; only between pushes.
Sourcepub fn push_index_size(&self) -> usize
pub fn push_index_size(&self) -> usize
The push index’s entry count (bucket memberships + scan slots + dynamic values) — a churn/leak probe’s size signal.