Skip to documentation
SLOP

tiny.smg.SearchDocumentPlan

Reference tiny.smg SearchDocumentPlan

Defined in search.

API (15)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

No direct callersNo direct callssearchDocumentPlan
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: tools/smg/src/search.zig:46

zig
pub const DocumentPlan = struct {    pub const Limits = struct {        documents: usize,        text_bytes: usize,    };    pub const Capacity = struct {        documents: usize,        text_bytes: usize,        bytes: usize,        pub fn derive(limits: Limits) error{CapacityOverflow}!Capacity {            const document_bytes = try alloc_phase.capacity.mul(                usize,                limits.documents,                @sizeOf(sql.SearchDocument),            );            return .{                .documents = limits.documents,                .text_bytes = limits.text_bytes,                .bytes = try alloc_phase.capacity.add(                    usize,                    document_bytes,                    limits.text_bytes,                ),            };        }    };    pub const InitError = std.mem.Allocator.Error || error{CapacityOverflow};    pub const claim: alloc_phase.capacity.Declaration = .{        .source = .{            .id = "smg.search_document_plan",            .kind = .phase_static,            .limit_source = .caller,            .storage = .{                .covered = &.{                    .{                        .id = "one_search_document_record_per_persisted_node_row",                        .lifetime = .steady,                        .detail = "one search document record per persisted node row",                    },                    .{                        .id = "one_contiguous_bounded_search_text_region_admitted_bf91a1d01c82",                        .lifetime = .steady,                        .detail = "one contiguous bounded search-text region admitted from exact row views",                    },                },                .excluded = &.{                    "persisted graph relation scans and borrowed row bytes",                    "graph database pager catalog and operating-system read storage",                    "SQL search postings keys lengths write staging WAL and cache database",                },            },            .capacity = .{                .inputs = &.{                    alloc_phase.capacity.bindInput(Limits, "documents", "documents"),                    alloc_phase.capacity.bindInput(Limits, "text_bytes", "text_bytes"),                },                .type_selectors = &.{                    alloc_phase.capacity.bindType(sql.SearchDocument, "search_document"),                },                .nodes = &.{                    .{ .input = 0 },                    .{ .scale = .{ .node = 0, .coefficient = .{ .size_of_concrete_type = 0 } } },                    .{ .input = 1 },                    .{ .add = .{ .left = 1, .right = 2 } },                },                .assertions = &.{.{                    .scope = .closure_total,                    .measure = .retained,                    .relation = .upper_bound,                    .expression = 3,                }},            },            .overload = .{                .kind = .reject_before_seal,                .detail = "checked record and rendered-text arithmetic plus exact acquisitions reject overflow or OOM before the second relation pass",            },            .risks = .{                .transitive = .{                    .status = .open,                    .detail = "identifier rendering and row views are sealed in the witness but lack a transitive allocation-closure certificate",                },                .foreign = .{                    .status = .excluded,                    .detail = "graph and search database effects occur outside the plan-owned slices",                },            },            .obligations = &.{                .{ .key = "smg_search_document_plan_capacity_capacity_model", .role = .capacity_model },                .{ .key = "smg_search_document_plan_capacity_overload", .role = .overload },                .{ .key = "smg_search_document_plan_oom", .role = .overload },                .{ .key = "smg_search_document_plan_sealed", .role = .transitive_risk },                .{ .key = "smg_search_document_plan_integration", .role = .foreign_risk },            },        },        .bindings = .{            .owner = @This(),            .seal = .{                .family = alloc_phase.capacity.selector(@This().activate),                .premise = .{                    .class = .checked_semantic_fact,                    .authority = .checker,                },            },            .teardown = .{                .family = alloc_phase.capacity.selector(@This().deinit),                .premise = .{                    .class = .checked_semantic_fact,                    .authority = .checker,                },            },        },    };    phase: alloc_phase.capacity.Phase,    capacity: Capacity,    documents: []sql.SearchDocument,    text: []u8,    documents_filled: usize,    text_filled: usize,    pub fn init(allocator: std.mem.Allocator, limits: Limits) InitError!DocumentPlan {        const capacity = try Capacity.derive(limits);        const documents = try documentAllocSlice(sql.SearchDocument, allocator, capacity.documents);        errdefer documentFreeSlice(sql.SearchDocument, allocator, documents);        return .{            .phase = .initialization,            .capacity = capacity,            .documents = documents,            .text = try documentAllocSlice(u8, allocator, capacity.text_bytes),            .documents_filled = 0,            .text_filled = 0,        };    }    pub fn append(self: *DocumentPlan, rowid: i64, name: []const u8, docstring: ?[]const u8) error{CapacityOverflow}!void {        std.debug.assert(self.phase == .initialization);        if (self.documents_filled == self.documents.len) return error.CapacityOverflow;        const text_bytes = try nodeSearchTextBytes(name, docstring);        const text_end = std.math.add(usize, self.text_filled, text_bytes) catch return error.CapacityOverflow;        if (text_end > self.text.len) return error.CapacityOverflow;        const destination = self.text[self.text_filled..text_end];        fillNodeSearchText(destination, name, docstring);        self.documents[self.documents_filled] = .{ .rowid = rowid, .text = destination };        self.documents_filled += 1;        self.text_filled = text_end;    }    pub fn activate(self: *DocumentPlan) void {        std.debug.assert(self.phase == .initialization);        std.debug.assert(self.documents_filled == self.documents.len);        std.debug.assert(self.text_filled == self.text.len);        self.phase = .steady;    }    pub fn deinit(self: *DocumentPlan, allocator: std.mem.Allocator) void {        std.debug.assert(self.phase != .teardown);        self.phase = .teardown;        documentFreeSlice(sql.SearchDocument, allocator, self.documents);        documentFreeSlice(u8, allocator, self.text);        self.* = undefined;    }};

Source: tools/smg/src/root.zig:119

zig
pub const SearchDocumentPlan = @import("search.zig").DocumentPlan;
Called byCallsNo direct callsSearchDocumentPlaninitprivate; no linktools.smg.src.searchstoredDocumentLimitstest; no linktools.smg.src.searchtest: search document plan capacity m...SearchDocumentPlan.Capacityderive
Static calls · unresolved targets: 1 · external targets: 1.
Called byCallsNo direct callsprivate; no linktools.smg.src.searchchangedDocumentsprivate; no linktools.smg.src.searchstoredDocumentstest; no linktools.smg.src.searchtest: search document plan fills exac...test; no linktools.smg.src.searchtest: search document plan initializa...SearchDocumentPlanactivate
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate; no linktools.smg.src.searchchangedDocumentstest; no linktools.smg.src.searchtest: search document plan fills exac...test; no linktools.smg.src.searchtest: search document plan initializa...private; no linktools.smg.src.searchfillNodeSearchTextprivate; no linktools.smg.src.searchnodeSearchTextBytesSearchDocumentPlanappend
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate; no linktools.smg.src.searchchangedDocumentsprivate; no linktools.smg.src.searchcheckDocumentPlanInitAllocationFailur...private; no linktools.smg.src.searchstoredDocumentstest; no linktools.smg.src.searchtest: search document plan fills exac...test; no linktools.smg.src.searchtest: search document plan initializa...private; no linktools.smg.src.searchdocumentFreeSliceSearchDocumentPlandeinit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate; no linktools.smg.src.searchchangedDocumentsprivate; no linktools.smg.src.searchcheckDocumentPlanInitAllocationFailur...private; no linktools.smg.src.searchstoredDocumentstest; no linktools.smg.src.searchtest: search document plan fills exac...test; no linktools.smg.src.searchtest: search document plan initializa...SearchDocumentPlan.Capacityderiveprivate; no linktools.smg.src.searchdocumentAllocSliceprivate; no linktools.smg.src.searchdocumentFreeSliceSearchDocumentPlaninit
Static calls · unresolved targets: 0 · external targets: 0.

Audit

Definitions10
Public names20
Members11
Version26.7.0
Revisiondaab053ee433