Skip to documentation
SLOP

tiny.sql.Index

Reference tiny.sql Index

Defined in index.

API (17)

Actions

Public operations.

Fields and members

Public fields and members.

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

Source

Source: lib/sql/src/index.zig:167

zig
pub const Index = struct {    entries: tree.Tree,    columns: []const row.Column,    pub fn open(database: *file.Database, options: Options) Error!Index {        return .{            .entries = try tree.Tree.open(database, options.tree),            .columns = options.columns,        };    }    pub fn reader(self: *const Index, snapshot: file.Snapshot) Error!Reader {        return .{            .entries = try self.entries.reader(snapshot),            .columns = self.columns,        };    }    pub fn put(self: *Index, rowid: i64, values: []const row.Value, options: file.CommitOptions) Error!file.Commit {        const phase = trace.scope("index.put");        defer phase.end();        var write = try tree.Write.beginTree(&self.entries);        defer write.deinit();        try self.putPayloadIn(&write, rowid, values, "");        return try write.commit(options);    }    pub fn putIn(self: *Index, write: *tree.Write, rowid: i64, values: []const row.Value) Error!void {        try self.putPayloadIn(write, rowid, values, "");    }    pub fn putPayload(self: *Index, rowid: i64, values: []const row.Value, payload: []const u8, options: file.CommitOptions) Error!file.Commit {        const phase = trace.scope("index.put_payload");        defer phase.end();        var write = try tree.Write.beginTree(&self.entries);        defer write.deinit();        try self.putPayloadIn(&write, rowid, values, payload);        return try write.commit(options);    }    pub fn putPayloadIn(self: *Index, write: *tree.Write, rowid: i64, values: []const row.Value, payload: []const u8) Error!void {        var key_bytes: [page.size]u8 = undefined;        const encoded = key.encodeIndex(&key_bytes, values, self.columns, rowid) catch |err| switch (err) {            error.OutputTooSmall => return error.KeyTooLarge,            else => return err,        };        try write.put(&self.entries, encoded, payload);    }    pub fn delete(self: *Index, rowid: i64, values: []const row.Value, options: file.CommitOptions) Error!file.Commit {        const phase = trace.scope("index.delete");        defer phase.end();        var write = try tree.Write.beginTree(&self.entries);        defer write.deinit();        try self.deleteIn(&write, rowid, values);        return try write.commit(options);    }    pub fn deleteIn(self: *Index, write: *tree.Write, rowid: i64, values: []const row.Value) Error!void {        var key_bytes: [page.size]u8 = undefined;        const encoded = key.encodeIndex(&key_bytes, values, self.columns, rowid) catch |err| switch (err) {            error.OutputTooSmall => return error.KeyTooLarge,            else => return err,        };        try write.delete(&self.entries, encoded);    }    pub fn scan(        self: *const Index,        target: *Scan,        allocator: Allocator,        start: ?[]const row.Value,        end: ?[]const row.Value,    ) Error!void {        var read = try self.entries.database.beginRead();        defer read.deinit();        const opened = try self.reader(read.snapshot());        try opened.scan(target, allocator, start, end);    }    pub fn range(        self: *const Index,        target: *Scan,        allocator: Allocator,        start: ?Bound,        end: ?Bound,    ) Error!void {        var read = try self.entries.database.beginRead();        defer read.deinit();        const opened = try self.reader(read.snapshot());        try opened.range(target, allocator, start, end);    }    pub fn scanPayloads(        self: *const Index,        target: *Scan,        allocator: Allocator,        start: ?[]const row.Value,        end: ?[]const row.Value,    ) Error!void {        var read = try self.entries.database.beginRead();        defer read.deinit();        const opened = try self.reader(read.snapshot());        try opened.scanPayloads(target, allocator, start, end);    }    pub fn lookup(        self: *const Index,        target: *Scan,        allocator: Allocator,        prefix: []const row.Value,    ) Error!void {        var read = try self.entries.database.beginRead();        defer read.deinit();        const opened = try self.reader(read.snapshot());        try opened.lookup(target, allocator, prefix);    }    pub fn lookupPayloads(        self: *const Index,        target: *Scan,        allocator: Allocator,        prefix: []const row.Value,    ) Error!void {        var read = try self.entries.database.beginRead();        defer read.deinit();        const opened = try self.reader(read.snapshot());        try opened.lookupPayloads(target, allocator, prefix);    }    pub fn summarize(self: *const Index) Error!tree.Summary {        var read = try self.entries.database.beginRead();        defer read.deinit();        const opened = try self.reader(read.snapshot());        return try opened.summarize();    }    pub fn summarizeIn(self: *const Index, write: *const tree.Write) Error!tree.Summary {        const phase = trace.scope("index.summarize_in");        defer phase.end();        return try self.entries.summarizeIn(write);    }};

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

zig
pub const Index = index.Index;
Called byCallsNo direct callersIndexdeleteIntracescopeTreeWritebeginTreeIndexdelete
Static calls · unresolved targets: 0 · external targets: 3.
Called byCallsIndexdeletekeyencodeIndexIndexdeleteIn
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callersIndexreaderIndexlookup
Static calls · unresolved targets: 0 · external targets: 4.
Called byCallsNo direct callersIndexreaderIndexlookupPayloads
Static calls · unresolved targets: 0 · external targets: 4.
Called byCallsprivate sourcelib.sql.src.properties.SecondaryPropertypropertytest sourcelib.sql.srctest: secondary index honors configur...test sourcelib.sql.srctest: secondary index range scan uses...test sourcelib.sql.srctest: secondary index stores duplicat...test sourcelib.sql.srctest: secondary index stores payloads...TreeopenIndexopen
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersIndexputPayloadIntracescopeTreeWritebeginTreeIndexput
Static calls · unresolved targets: 0 · external targets: 3.
Called byCallsNo direct callersIndexputPayloadInIndexputIn
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersIndexputPayloadIntracescopeTreeWritebeginTreeIndexputPayload
Static calls · unresolved targets: 0 · external targets: 3.
Called byCallsIndexputIndexputInIndexputPayloadkeyencodeIndexIndexputPayloadIn
Static calls · unresolved targets: 1 · external targets: 0.
Called byCallsNo direct callersIndexreaderIndexrange
Static calls · unresolved targets: 0 · external targets: 4.
Called byCallsIndexlookupIndexlookupPayloadsIndexrangeIndexscanIndexscanPayloadsIndexsummarizeTreereaderIndexreader
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersIndexreaderIndexscan
Static calls · unresolved targets: 0 · external targets: 4.
Called byCallsNo direct callersIndexreaderIndexscanPayloads
Static calls · unresolved targets: 0 · external targets: 4.
Called byCallsNo direct callersIndexreaderIndexsummarize
Static calls · unresolved targets: 0 · external targets: 4.
Called byCallsNo direct callerstracescopeTreesummarizeInIndexsummarizeIn
Static calls · unresolved targets: 0 · external targets: 1.

Audit

Definitions16
Public names32
Members2
Version26.7.0
Revisiondaab053ee433