tiny.smg.storage.database.read
Defined in storage.database.
API (11)
Actions
Public operations.
databaseConceptDocumentsdatabaseEdgesdatabaseNodesgraphCountsreaderConceptDocumentsreaderEdgesreaderEdgesIntoreaderGraphCountsreaderNodesreaderNodesInto
Types and contracts
Public types and contracts.
Source
Source: tools/smg/src/storage/database/read.zig
zig
const std = @import("std");const storage = @import("../root.zig");const database = @import("root.zig");const rows = storage.rows;pub const GraphCounts = struct { nodes: usize, edges: usize,};pub fn graphCounts(opened: *database.Database) database.Error!GraphCounts { return try catalogGraphCounts(&opened.connection.catalog, opened.allocator);}pub fn readerGraphCounts(reader: *database.Reader) database.Error!GraphCounts { return try catalogGraphCounts(&reader.catalog, reader.allocator);}pub fn databaseNodes(opened: *database.Database, row_allocator: std.mem.Allocator, value_allocator: std.mem.Allocator) database.Error![]rows.NodeRow { return try rows.scanNodeRows(&opened.connection.catalog, opened.allocator, row_allocator, value_allocator);}pub fn databaseEdges(opened: *database.Database, row_allocator: std.mem.Allocator, value_allocator: std.mem.Allocator) database.Error![]rows.EdgeRow { return try rows.scanEdgeRows(&opened.connection.catalog, opened.allocator, row_allocator, value_allocator);}pub fn databaseConceptDocuments(opened: *database.Database, row_allocator: std.mem.Allocator, value_allocator: std.mem.Allocator) database.Error![]rows.ConceptDocumentRow { return try rows.scanConceptDocumentRows(&opened.connection.catalog, opened.allocator, row_allocator, value_allocator);}pub fn readerNodes(reader: *database.Reader, row_allocator: std.mem.Allocator, value_allocator: std.mem.Allocator) database.Error![]rows.NodeRow { return try rows.scanNodeRows(&reader.catalog, reader.allocator, row_allocator, value_allocator);}pub fn readerEdges(reader: *database.Reader, row_allocator: std.mem.Allocator, value_allocator: std.mem.Allocator) database.Error![]rows.EdgeRow { return try rows.scanEdgeRows(&reader.catalog, reader.allocator, row_allocator, value_allocator);}pub fn readerConceptDocuments(reader: *database.Reader, row_allocator: std.mem.Allocator, value_allocator: std.mem.Allocator) database.Error![]rows.ConceptDocumentRow { return try rows.scanConceptDocumentRows(&reader.catalog, reader.allocator, row_allocator, value_allocator);}pub fn readerNodesInto(reader: *database.Reader, value_allocator: std.mem.Allocator, out: []rows.NodeRow) database.Error!void { try rows.scanNodeRowsInto(&reader.catalog, reader.allocator, value_allocator, out);}pub fn readerEdgesInto(reader: *database.Reader, value_allocator: std.mem.Allocator, out: []rows.EdgeRow) database.Error!void { try rows.scanEdgeRowsInto(&reader.catalog, reader.allocator, value_allocator, out);}fn catalogGraphCounts(catalog: anytype, allocator: std.mem.Allocator) database.Error!GraphCounts { return .{ .nodes = try relationCount( catalog, allocator, rows.nodes_relation, ), .edges = try relationCount( catalog, allocator, rows.edges_relation, ), };}fn relationCount( catalog: anytype, allocator: std.mem.Allocator, name: []const u8,) database.Error!usize { var handle = catalog.openRelation(allocator, name) catch |err| switch (err) { error.RelationNotFound => return 0, else => return err, }; defer handle.deinit(); return try handle.relation.table.count();}Source: tools/smg/src/storage/database/root.zig:3
zig
pub const read = @import("read.zig");Audit
| Definitions | 12 |
|---|---|
| Public names | 12 |
| Members | 2 |
| Version | 26.7.0 |
| Revision | daab053ee433 |