Skip to documentation
SLOP

tiny.sql.Store

Reference tiny.sql Store

Defined in store.

API (13)

Actions

Public operations.

Fields and members

Public fields and members.

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

Source

Source: lib/sql/src/store.zig:42

zig
pub const Store = struct {    allocator: Allocator,    versions: std.ArrayList(Version) = .empty,    generation: u64 = 0,    pub fn init(allocator: Allocator) Store {        return .{ .allocator = allocator };    }    pub fn deinit(self: *Store) void {        for (self.versions.items) |*version| {            freeOwned(self.allocator, version.key);            if (!version.deleted) freeOwned(self.allocator, version.value);        }        self.versions.deinit(self.allocator);        self.* = .{ .allocator = self.allocator };    }    pub fn currentGeneration(self: *const Store) u64 {        return self.generation;    }    pub fn beginRead(self: *const Store) Snapshot {        return .{ .store = self, .generation = self.generation };    }    pub fn beginWrite(self: *Store) Write {        return .{ .store = self, .snapshot_generation = self.generation };    }    pub fn get(self: *const Store, key: []const u8) ?[]const u8 {        const phase = trace.scope("store.get");        defer phase.end();        return valueFromIndex(self, latestVisibleIndex(self, key, self.generation));    }    pub fn getAt(self: *const Store, key: []const u8, generation: u64) ?[]const u8 {        return valueFromIndex(self, latestVisibleIndex(self, key, generation));    }    pub fn range(self: *const Store, start: ?[]const u8, end: ?[]const u8) Error!Range {        return rangeAt(self, start, end, self.generation);    }    pub fn rangeAt(self: *const Store, start: ?[]const u8, end: ?[]const u8, generation: u64) Error!Range {        if (start) |lower| {            if (end) |upper| {                if (simd.order(Bytes, lower, upper) == .gt) return error.InvalidRange;            }        }        return .{            .store = self,            .start = start,            .end = end,            .generation = generation,            .index = if (start) |lower| lowerBoundKey(self.versions.items, lower) else 0,        };    }    pub fn compact(self: *Store, oldest_visible_generation: u64) void {        const phase = trace.scope("store.compact");        defer phase.end();        var read_index: usize = 0;        var write_index: usize = 0;        while (read_index < self.versions.items.len) {            const key = self.versions.items[read_index].key;            var group_end = read_index;            var has_oldest_version = false;            while (group_end < self.versions.items.len and eqlKey(self.versions.items[group_end].key, key)) : (group_end += 1) {                const version = self.versions.items[group_end];                if (version.generation == oldest_visible_generation) has_oldest_version = true;            }            var keep_floor: ?usize = null;            var scan = read_index;            while (scan < group_end) : (scan += 1) {                const version = self.versions.items[scan];                if (version.generation < oldest_visible_generation) {                    if (keep_floor == null or self.versions.items[keep_floor.?].generation < version.generation) {                        keep_floor = scan;                    }                }            }            scan = read_index;            while (scan < group_end) : (scan += 1) {                const keep =                    (!has_oldest_version and keep_floor != null and scan == keep_floor.?) or                    self.versions.items[scan].generation >= oldest_visible_generation;                if (keep) {                    self.versions.items[write_index] = self.versions.items[scan];                    write_index += 1;                } else {                    freeOwned(self.allocator, self.versions.items[scan].key);                    if (!self.versions.items[scan].deleted) freeOwned(self.allocator, self.versions.items[scan].value);                }            }            read_index = group_end;        }        self.versions.shrinkRetainingCapacity(write_index);    }};

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

zig
pub const Store = store.Store;
Called byCallsNo direct callstest sourcelib.sql.src.storetest: delete creates a tombstone for ...test sourcelib.sql.src.storetest: snapshots preserve old values a...StorebeginRead
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsprivate sourcelib.sql.src.properties.store.StatePropertypropertytest sourcelib.sql.src.storetest: multi key commits preserve cano...test sourcelib.sql.src.storetest: write transactions allow disjoi...test sourcelib.sql.src.storetest: write transactions detect same ...StorebeginWrite
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.sql.src.storetest: compaction drops obsolete floor...test sourcelib.sql.src.storetest: compaction keeps floor when old...private sourcelib.sql.src.storeeqlKeyprivate sourcelib.sql.src.storefreeOwnedStorecompact
Static calls · unresolved targets: 0 · external targets: 3.
Called byCallsNo direct callsprivate sourcelib.sql.src.properties.store.StatePropertypropertyStorecurrentGeneration
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.sql.src.storetest: committed writes are visible in...test sourcelib.sql.src.storetest: compaction drops obsolete floor...test sourcelib.sql.src.storetest: compaction keeps floor when old...test sourcelib.sql.src.storetest: delete creates a tombstone for ...test sourcelib.sql.src.storetest: multi key commits preserve cano...+4 moreprivate sourcelib.sql.src.storefreeOwnedStoredeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallstest sourcelib.sql.src.storetest: committed writes are visible in...test sourcelib.sql.src.storetest: compaction drops obsolete floor...test sourcelib.sql.src.storetest: compaction keeps floor when old...test sourcelib.sql.src.storetest: delete creates a tombstone for ...test sourcelib.sql.src.storetest: snapshots preserve old values a...test sourcelib.sql.src.storetest: write transactions allow disjoi...private sourcelib.sql.src.storelatestVisibleIndexprivate sourcelib.sql.src.storevalueFromIndexStoreget
Static calls · unresolved targets: 0 · external targets: 2.
Called byCallsSnapshotgetWritegettest sourcelib.sql.src.storetest: compaction drops obsolete floor...test sourcelib.sql.src.storetest: compaction keeps floor when old...private sourcelib.sql.src.storelatestVisibleIndexprivate sourcelib.sql.src.storevalueFromIndexStoregetAt
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.sql.src.storetest: committed writes are visible in...test sourcelib.sql.src.storetest: compaction drops obsolete floor...test sourcelib.sql.src.storetest: compaction keeps floor when old...test sourcelib.sql.src.storetest: delete creates a tombstone for ...test sourcelib.sql.src.storetest: multi key commits preserve cano...+4 moreStoreinit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.sql.src.storetest: committed writes are visible in...test sourcelib.sql.src.storetest: range scan honors half open bou...StorerangeAtStorerange
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsSnapshotrangeStorerangeprivate sourcelib.sql.src.storelowerBoundKeyStorerangeAt
Static calls · unresolved targets: 0 · external targets: 1.

Complete caller list for Store.deinit

9 direct callers.

Complete caller list for Store.init

9 direct callers.

Audit

Definitions11
Public names22
Members3
Version26.7.0
Revisiondaab053ee433