Skip to documentation
SLOP

tiny.smg.storage.rows

Reference tiny.smg storage rows

Defined in storage.

API (38)

Actions

Public operations.

Types and contracts

Public types and contracts.

Values and defaults

Public values and defaults.

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

Source

Source: tools/smg/src/storage/rows/types.zig:44

zig
pub const ConceptDocumentPut = struct {    rowid: i64,    name: []const u8,    document: []const u8,};

Source: tools/smg/src/storage/rows/types.zig:28

zig
pub const ConceptDocumentRow = struct {    rowid: i64,    name: []const u8,    document: []const u8,};

Source: tools/smg/src/storage/rows/types.zig:39

zig
pub const EdgePut = struct {    rowid: i64,    edge: model.Edge,};

Source: tools/smg/src/storage/rows/types.zig:23

zig
pub const EdgeRow = struct {    rowid: i64,    edge: model.Edge,};

Source: tools/smg/src/storage/rows/types.zig:50

zig
pub const GraphEdits = struct {    node_puts: []const NodePut = &.{},    node_deletes: []const i64 = &.{},    edge_puts: []const EdgePut = &.{},    edge_deletes: []const i64 = &.{},    concept_document_puts: []const ConceptDocumentPut = &.{},    concept_document_deletes: []const i64 = &.{},    pub fn isEmpty(self: GraphEdits) bool {        return self.node_puts.len == 0 and self.node_deletes.len == 0 and            self.edge_puts.len == 0 and self.edge_deletes.len == 0 and            self.concept_document_puts.len == 0 and self.concept_document_deletes.len == 0;    }};

Source: tools/smg/src/storage/rows/types.zig:34

zig
pub const NodePut = struct {    rowid: i64,    node: model.Node,};

Source: tools/smg/src/storage/rows/read.zig:205

zig
pub fn decodeEdgeRow(allocator: std.mem.Allocator, rowid: i64, bytes: []const u8) Error!types.EdgeRow {    const view = try sql.RowView.init(bytes);    var edge = model.Edge{        .source = try columnText(allocator, view, 0),        .target = &.{},        .rel = &.{},    };    errdefer model.deinitEdge(&edge, allocator);    edge.rel = try columnText(allocator, view, 1);    edge.target = try columnText(allocator, view, 2);    edge.metadata = try decodeMetadata(allocator, view, 3);    return .{ .rowid = rowid, .edge = edge };}
Called byCallsstorage.rowsscanEdgeRowsstorage.rowsscanEdgeRowsIntomodeldeinitEdgeprivate; no linktools.smg.src.storage.rows.readcolumnTextprivate; no linktools.smg.src.storage.rows.readdecodeMetadatastorage.rowsdecodeEdgeRow
Static calls · unresolved targets: 0 · external targets: 1.

Source: tools/smg/src/storage/rows/read.zig:174

zig
pub fn decodeNodeRow(allocator: std.mem.Allocator, rowid: i64, bytes: []const u8) Error!types.NodeRow {    const view = try sql.RowView.init(bytes);    var node = model.Node{        .name = try columnText(allocator, view, 0),        .type = &.{},    };    errdefer model.deinitNode(&node, allocator);    node.type = try columnText(allocator, view, 1);    node.file = try columnOptionalText(allocator, view, 2);    node.line = try columnOptionalInteger(view, 3);    node.end_line = try columnOptionalInteger(view, 4);    node.docstring = try columnOptionalText(allocator, view, 5);    node.metadata = try decodeMetadata(allocator, view, 6);    return .{ .rowid = rowid, .node = node };}
Called byCallsstorage.rowsscanNodeRowsstorage.rowsscanNodeRowsIntomodeldeinitNodeprivate; no linktools.smg.src.storage.rows.readcolumnOptionalIntegerprivate; no linktools.smg.src.storage.rows.readcolumnOptionalTextprivate; no linktools.smg.src.storage.rows.readcolumnTextprivate; no linktools.smg.src.storage.rows.readdecodeMetadatastorage.rowsdecodeNodeRow
Static calls · unresolved targets: 0 · external targets: 1.

Source: tools/smg/src/storage/rows/read.zig:224

zig
pub fn edgeRelView(bytes: []const u8) Error![]const u8 {    const view = try sql.RowView.init(bytes);    return try columnTextView(view, 1);}
Called byCallsNo direct callersprivate; no linktools.smg.src.storage.rows.readcolumnTextViewstorage.rowsedgeRelView
Static calls · unresolved targets: 0 · external targets: 1.

Source: tools/smg/src/storage/rows/read.zig:219

zig
pub fn edgeSourceView(bytes: []const u8) Error![]const u8 {    const view = try sql.RowView.init(bytes);    return try columnTextView(view, 0);}
Called byCallsNo direct callersprivate; no linktools.smg.src.storage.rows.readcolumnTextViewstorage.rowsedgeSourceView
Static calls · unresolved targets: 0 · external targets: 1.

Source: tools/smg/src/storage/rows/read.zig:229

zig
pub fn edgeTargetView(bytes: []const u8) Error![]const u8 {    const view = try sql.RowView.init(bytes);    return try columnTextView(view, 2);}
Called byCallsNo direct callersprivate; no linktools.smg.src.storage.rows.readcolumnTextViewstorage.rowsedgeTargetView
Static calls · unresolved targets: 0 · external targets: 1.

Source: tools/smg/src/storage/rows/read.zig:166

zig
pub fn freeConceptDocumentRowSlice(row_allocator: std.mem.Allocator, value_allocator: std.mem.Allocator, row_slice: []types.ConceptDocumentRow) void {    for (row_slice) |row| {        value_allocator.free(row.name);        value_allocator.free(row.document);    }    if (row_slice.len != 0) row_allocator.free(row_slice);}

Source: tools/smg/src/storage/rows/read.zig:161

zig
pub fn freeEdgeRowSlice(row_allocator: std.mem.Allocator, value_allocator: std.mem.Allocator, row_slice: []types.EdgeRow) void {    for (row_slice) |*loaded| model.deinitEdge(&loaded.edge, value_allocator);    if (row_slice.len != 0) row_allocator.free(row_slice);}
Called byCallsNo direct callersmodeldeinitEdgestorage.rowsfreeEdgeRowSlice
Static calls · unresolved targets: 0 · external targets: 1.

Source: tools/smg/src/storage/rows/read.zig:156

zig
pub fn freeNodeRowSlice(row_allocator: std.mem.Allocator, value_allocator: std.mem.Allocator, row_slice: []types.NodeRow) void {    for (row_slice) |*loaded| model.deinitNode(&loaded.node, value_allocator);    if (row_slice.len != 0) row_allocator.free(row_slice);}
Called byCallsNo direct callersmodeldeinitNodestorage.rowsfreeNodeRowSlice
Static calls · unresolved targets: 0 · external targets: 1.

Source: tools/smg/src/storage/rows/read.zig:200

zig
pub fn nodeDocstringView(bytes: []const u8) Error!?[]const u8 {    const view = try sql.RowView.init(bytes);    return try columnOptionalTextView(view, 5);}
Called byCallsNo direct callersprivate; no linktools.smg.src.storage.rows.readcolumnOptionalTextViewstorage.rowsnodeDocstringView
Static calls · unresolved targets: 0 · external targets: 1.

Source: tools/smg/src/storage/rows/read.zig:190

zig
pub fn nodeNameView(bytes: []const u8) Error![]const u8 {    const view = try sql.RowView.init(bytes);    return try columnTextView(view, 0);}
Called byCallsNo direct callersprivate; no linktools.smg.src.storage.rows.readcolumnTextViewstorage.rowsnodeNameView
Static calls · unresolved targets: 0 · external targets: 1.

Source: tools/smg/src/storage/rows/read.zig:195

zig
pub fn nodeTypeView(bytes: []const u8) Error![]const u8 {    const view = try sql.RowView.init(bytes);    return try columnTextView(view, 1);}
Called byCallsNo direct callersprivate; no linktools.smg.src.storage.rows.readcolumnTextViewstorage.rowsnodeTypeView
Static calls · unresolved targets: 0 · external targets: 1.

Source: tools/smg/src/storage/rows/read.zig:71

zig
pub fn scanConceptDocumentRows(    opened_catalog: anytype,    scratch_allocator: std.mem.Allocator,    row_allocator: std.mem.Allocator,    value_allocator: std.mem.Allocator,) Error![]types.ConceptDocumentRow {    var handle = opened_catalog.openRelation(scratch_allocator, types.concept_documents_relation) catch |err| switch (err) {        error.RelationNotFound => return &.{},        else => return err,    };    defer handle.deinit();    var scan: sql.TableScan = undefined;    try handle.relation.scan(&scan, scratch_allocator, null, null);    defer scan.deinit();    const count = try handle.relation.table.count();    var loaded: std.ArrayList(types.ConceptDocumentRow) = .empty;    errdefer freeConceptDocumentRows(row_allocator, value_allocator, &loaded);    try loaded.ensureTotalCapacityPrecise(row_allocator, count);    while (try scan.next()) |entry| {        const view = try sql.RowView.init(entry.bytes);        const name = try columnText(value_allocator, view, 0);        errdefer value_allocator.free(name);        const document = try columnText(value_allocator, view, 1);        if (loaded.items.len == count) {            value_allocator.free(document);            return error.MalformedRow;        }        loaded.appendAssumeCapacity(.{            .rowid = entry.rowid,            .name = name,            .document = document,        });    }    if (loaded.items.len != count) return error.MalformedRow;    return try loaded.toOwnedSlice(row_allocator);}
Called byCallsNo direct callersprivate; no linktools.smg.src.storage.rows.readcolumnTextprivate; no linktools.smg.src.storage.rows.readfreeConceptDocumentRowsstorage.rowsscanConceptDocumentRows
Static calls · unresolved targets: 0 · external targets: 11.

Source: tools/smg/src/storage/rows/read.zig:40

zig
pub fn scanEdgeRows(    opened_catalog: anytype,    scratch_allocator: std.mem.Allocator,    row_allocator: std.mem.Allocator,    value_allocator: std.mem.Allocator,) Error![]types.EdgeRow {    var handle = opened_catalog.openRelation(scratch_allocator, types.edges_relation) catch |err| switch (err) {        error.RelationNotFound => return &.{},        else => return err,    };    defer handle.deinit();    var scan: sql.TableScan = undefined;    try handle.relation.scan(&scan, scratch_allocator, null, null);    defer scan.deinit();    const count = try handle.relation.table.count();    var loaded: std.ArrayList(types.EdgeRow) = .empty;    errdefer freeEdgeRows(row_allocator, value_allocator, &loaded);    try loaded.ensureTotalCapacityPrecise(row_allocator, count);    while (try scan.next()) |entry| {        const decoded = try decodeEdgeRow(value_allocator, entry.rowid, entry.bytes);        if (loaded.items.len == count) {            var rejected = decoded;            model.deinitEdge(&rejected.edge, value_allocator);            return error.MalformedRow;        }        loaded.appendAssumeCapacity(decoded);    }    if (loaded.items.len != count) return error.MalformedRow;    return try loaded.toOwnedSlice(row_allocator);}
Called byCallsNo direct callersmodeldeinitEdgestorage.rowsdecodeEdgeRowprivate; no linktools.smg.src.storage.rows.readfreeEdgeRowsstorage.rowsscanEdgeRows
Static calls · unresolved targets: 0 · external targets: 9.

Source: tools/smg/src/storage/rows/read.zig:132

zig
pub fn scanEdgeRowsInto(    opened_catalog: anytype,    scratch_allocator: std.mem.Allocator,    value_allocator: std.mem.Allocator,    out: []types.EdgeRow,) Error!void {    var handle = opened_catalog.openRelation(scratch_allocator, types.edges_relation) catch |err| switch (err) {        error.RelationNotFound => if (out.len == 0) return else return error.MalformedRow,        else => return err,    };    defer handle.deinit();    var scan: sql.TableScan = undefined;    try handle.relation.scan(&scan, scratch_allocator, null, null);    defer scan.deinit();    var filled: usize = 0;    errdefer for (out[0..filled]) |*loaded| model.deinitEdge(&loaded.edge, value_allocator);    while (try scan.next()) |entry| {        if (filled == out.len) return error.MalformedRow;        out[filled] = try decodeEdgeRow(value_allocator, entry.rowid, entry.bytes);        filled += 1;    }    if (filled != out.len) return error.MalformedRow;}
Called byCallsNo direct callersmodeldeinitEdgestorage.rowsdecodeEdgeRowstorage.rowsscanEdgeRowsInto
Static calls · unresolved targets: 0 · external targets: 5.

Source: tools/smg/src/storage/rows/read.zig:9

zig
pub fn scanNodeRows(    opened_catalog: anytype,    scratch_allocator: std.mem.Allocator,    row_allocator: std.mem.Allocator,    value_allocator: std.mem.Allocator,) Error![]types.NodeRow {    var handle = opened_catalog.openRelation(scratch_allocator, types.nodes_relation) catch |err| switch (err) {        error.RelationNotFound => return &.{},        else => return err,    };    defer handle.deinit();    var scan: sql.TableScan = undefined;    try handle.relation.scan(&scan, scratch_allocator, null, null);    defer scan.deinit();    const count = try handle.relation.table.count();    var loaded: std.ArrayList(types.NodeRow) = .empty;    errdefer freeNodeRows(row_allocator, value_allocator, &loaded);    try loaded.ensureTotalCapacityPrecise(row_allocator, count);    while (try scan.next()) |entry| {        const decoded = try decodeNodeRow(value_allocator, entry.rowid, entry.bytes);        if (loaded.items.len == count) {            var rejected = decoded;            model.deinitNode(&rejected.node, value_allocator);            return error.MalformedRow;        }        loaded.appendAssumeCapacity(decoded);    }    if (loaded.items.len != count) return error.MalformedRow;    return try loaded.toOwnedSlice(row_allocator);}
Called byCallsNo direct callersmodeldeinitNodestorage.rowsdecodeNodeRowprivate; no linktools.smg.src.storage.rows.readfreeNodeRowsstorage.rowsscanNodeRows
Static calls · unresolved targets: 0 · external targets: 9.

Source: tools/smg/src/storage/rows/read.zig:108

zig
pub fn scanNodeRowsInto(    opened_catalog: anytype,    scratch_allocator: std.mem.Allocator,    value_allocator: std.mem.Allocator,    out: []types.NodeRow,) Error!void {    var handle = opened_catalog.openRelation(scratch_allocator, types.nodes_relation) catch |err| switch (err) {        error.RelationNotFound => if (out.len == 0) return else return error.MalformedRow,        else => return err,    };    defer handle.deinit();    var scan: sql.TableScan = undefined;    try handle.relation.scan(&scan, scratch_allocator, null, null);    defer scan.deinit();    var filled: usize = 0;    errdefer for (out[0..filled]) |*loaded| model.deinitNode(&loaded.node, value_allocator);    while (try scan.next()) |entry| {        if (filled == out.len) return error.MalformedRow;        out[filled] = try decodeNodeRow(value_allocator, entry.rowid, entry.bytes);        filled += 1;    }    if (filled != out.len) return error.MalformedRow;}
Called byCallsNo direct callersmodeldeinitNodestorage.rowsdecodeNodeRowstorage.rowsscanNodeRowsInto
Static calls · unresolved targets: 0 · external targets: 5.

Source: tools/smg/src/storage/rows/types.zig:5

zig
pub const Error = error{ MalformedRow, InvalidMetadata, OutOfMemory } || sql.statement.Error || sql.catalog.Error;

Source: tools/smg/src/storage/rows/types.zig:16

zig
pub const concept_document_columns = "name, document, INDEX " ++ concept_name_index ++ " (name)";

Source: tools/smg/src/storage/rows/types.zig:9

zig
pub const concept_documents_relation = "concepts";

Source: tools/smg/src/storage/rows/types.zig:13

zig
pub const concept_name_index = "concepts_name";

Source: tools/smg/src/storage/rows/types.zig:15

zig
pub const edge_columns = "source, rel, target, metadata, INDEX " ++ edge_source_index ++ " (source), INDEX " ++ edge_target_index ++ " (target)";

Source: tools/smg/src/storage/rows/types.zig:11

zig
pub const edge_source_index = "edges_source";

Source: tools/smg/src/storage/rows/types.zig:12

zig
pub const edge_target_index = "edges_target";

Source: tools/smg/src/storage/rows/types.zig:8

zig
pub const edges_relation = "edges";

Source: tools/smg/src/storage/rows/types.zig:14

zig
pub const node_columns = "name, type, file, line, end_line, docstring, metadata, INDEX " ++ node_name_index ++ " (name)";

Source: tools/smg/src/storage/rows/types.zig:10

zig
pub const node_name_index = "nodes_name";

Source: tools/smg/src/storage/rows/types.zig:7

zig
pub const nodes_relation = "nodes";

Source: tools/smg/src/storage/rows/write.zig:36

zig
pub fn putConceptDocumentRow(session: *sql.RelationSession, put: types.ConceptDocumentPut) Error!void {    try session.put(put.rowid, &.{        .{ .text = put.name },        .{ .text = put.document },    });}

Source: tools/smg/src/storage/rows/write.zig:24

zig
pub fn putEdgeRow(allocator: std.mem.Allocator, session: *sql.RelationSession, rowid: i64, edge: model.Edge) Error!void {    const metadata = try renderMetadata(allocator, edge.metadata);    defer if (metadata) |rendered| allocator.free(rendered);    const values = [_]sql.row.Value{        .{ .text = edge.source },        .{ .text = edge.rel },        .{ .text = edge.target },        optionalText(metadata),    };    try session.put(rowid, &values);}
Called byCallsNo direct callersprivate; no linktools.smg.src.storage.rows.writeoptionalTextprivate; no linktools.smg.src.storage.rows.writerenderMetadatastorage.rowsputEdgeRow
Static calls · unresolved targets: 1 · external targets: 1.

Source: tools/smg/src/storage/rows/write.zig:9

zig
pub fn putNodeRow(allocator: std.mem.Allocator, session: *sql.RelationSession, rowid: i64, node: model.Node) Error!void {    const metadata = try renderMetadata(allocator, node.metadata);    defer if (metadata) |rendered| allocator.free(rendered);    const values = [_]sql.row.Value{        .{ .text = node.name },        .{ .text = node.type },        optionalText(node.file),        optionalInteger(node.line),        optionalInteger(node.end_line),        optionalText(node.docstring),        optionalText(metadata),    };    try session.put(rowid, &values);}
Called byCallsNo direct callersprivate; no linktools.smg.src.storage.rows.writeoptionalIntegerprivate; no linktools.smg.src.storage.rows.writeoptionalTextprivate; no linktools.smg.src.storage.rows.writerenderMetadatastorage.rowsputNodeRow
Static calls · unresolved targets: 1 · external targets: 1.

Source: tools/smg/src/storage/root.zig:9

zig
pub const rows = @import("rows/root.zig");

Source: tools/smg/src/storage/rows/root.zig

zig
const read = @import("read.zig");const types = @import("types.zig");const write = @import("write.zig");pub const Error = types.Error;pub const node_columns = types.node_columns;pub const edge_columns = types.edge_columns;pub const concept_document_columns = types.concept_document_columns;pub const nodes_relation = types.nodes_relation;pub const edges_relation = types.edges_relation;pub const concept_documents_relation = types.concept_documents_relation;pub const node_name_index = types.node_name_index;pub const edge_source_index = types.edge_source_index;pub const edge_target_index = types.edge_target_index;pub const concept_name_index = types.concept_name_index;pub const NodeRow = types.NodeRow;pub const EdgeRow = types.EdgeRow;pub const ConceptDocumentRow = types.ConceptDocumentRow;pub const NodePut = types.NodePut;pub const EdgePut = types.EdgePut;pub const ConceptDocumentPut = types.ConceptDocumentPut;pub const GraphEdits = types.GraphEdits;pub const freeNodeRowSlice = read.freeNodeRowSlice;pub const freeEdgeRowSlice = read.freeEdgeRowSlice;pub const freeConceptDocumentRowSlice = read.freeConceptDocumentRowSlice;pub const scanNodeRows = read.scanNodeRows;pub const scanEdgeRows = read.scanEdgeRows;pub const scanConceptDocumentRows = read.scanConceptDocumentRows;pub const scanNodeRowsInto = read.scanNodeRowsInto;pub const scanEdgeRowsInto = read.scanEdgeRowsInto;pub const decodeNodeRow = read.decodeNodeRow;pub const decodeEdgeRow = read.decodeEdgeRow;pub const nodeNameView = read.nodeNameView;pub const nodeTypeView = read.nodeTypeView;pub const nodeDocstringView = read.nodeDocstringView;pub const edgeSourceView = read.edgeSourceView;pub const edgeRelView = read.edgeRelView;pub const edgeTargetView = read.edgeTargetView;pub const putNodeRow = write.putNodeRow;pub const putEdgeRow = write.putEdgeRow;pub const putConceptDocumentRow = write.putConceptDocumentRow;

Audit

Definitions38
Public names38
Members18
Version26.7.0
Revisiondaab053ee433