Skip to documentation
SLOP

tiny.sql.TreeRoot

Reference tiny.sql TreeRoot

Defined in tree.

API (11)

Actions

Public operations.

Fields and members

Public fields and members.

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

Source

Source: lib/sql/src/tree.zig:147

zig
pub const Root = struct {    allocator: Allocator,    summary: Summary,    hash: Hash,    subtree: Hash,    nodes: []Node,    edges: []usize,    pub fn deinit(self: *Root) void {        for (self.nodes) |node| {            self.allocator.free(node.lower);            if (node.upper) |upper| self.allocator.free(upper);        }        self.allocator.free(self.nodes);        self.allocator.free(self.edges);        self.* = undefined;    }    pub fn clone(self: *const Root, allocator: Allocator) Allocator.Error!Root {        const nodes = try allocator.alloc(Node, self.nodes.len);        var node_count: usize = 0;        errdefer {            for (nodes[0..node_count]) |node| {                allocator.free(node.lower);                if (node.upper) |upper| allocator.free(upper);            }            allocator.free(nodes);        }        for (self.nodes, nodes) |node, *target| {            const lower = try allocator.dupe(u8, node.lower);            errdefer allocator.free(lower);            const upper = if (node.upper) |bytes| try allocator.dupe(u8, bytes) else null;            errdefer if (upper) |bytes| allocator.free(bytes);            target.* = .{                .kind = node.kind,                .lower = lower,                .upper = upper,                .depth = node.depth,                .summary = node.summary,                .hash = node.hash,                .children_start = node.children_start,                .children_len = node.children_len,            };            node_count += 1;        }        const edges = try allocator.dupe(usize, self.edges);        errdefer allocator.free(edges);        return .{            .allocator = allocator,            .summary = self.summary,            .hash = self.hash,            .subtree = self.subtree,            .nodes = nodes,            .edges = edges,        };    }    pub fn rootNode(self: *const Root) *const Node {        return &self.nodes[0];    }    pub fn childIndexes(self: *const Root, node: *const Node) []const usize {        return self.edges[node.children_start..][0..node.children_len];    }    pub fn child(self: *const Root, node: *const Node, index: usize) ?*const Node {        if (index >= node.children_len) return null;        return &self.nodes[self.edges[node.children_start + index]];    }};

Source: lib/sql/src/root.zig:215

zig
pub const TreeRoot = tree.Root;

Also reachable as

version.MapRoot.

Audit

Definitions6
Public names18
Members6
Version26.7.0
Revisiondaab053ee433