Skip to documentation
SLOP

tiny.sql.RowView

Reference tiny.sql RowView

Defined in row.

API (10)

Actions

Public operations.

Fields and members

Public fields and members.

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

Source

Source: lib/sql/src/row.zig:331

zig
pub const View = struct {    bytes: []const u8,    header_len: usize,    header_start: usize,    count: usize,    pub fn init(bytes: []const u8) Error!View {        const header = try readVarint(bytes);        if (header.value > std.math.maxInt(usize)) return error.RowTooLarge;        const header_len: usize = @intCast(header.value);        if (header_len < header.len or header_len > bytes.len) return error.InvalidRow;        var header_cursor = header.len;        var body_len: usize = 0;        var count: usize = 0;        while (header_cursor < header_len) {            const serial = try readVarint(bytes[header_cursor..header_len]);            const size = try serialBodySize(serial.value);            body_len = try checkedAdd(body_len, size);            header_cursor += serial.len;            count += 1;        }        if (header_cursor != header_len) return error.InvalidRow;        if (body_len > bytes.len - header_len) return error.InvalidRow;        return .{            .bytes = bytes,            .header_len = header_len,            .header_start = header.len,            .count = count,        };    }    pub fn columnCount(self: View) usize {        return self.count;    }    /// Returns a cursor that opens a traversal of this row at its first column,    /// so a caller reading more than one column of the row walks the header    /// once. The cursor carries the two offsets the traversal needs and calls    /// no allocator. The cursor reads the row's borrowed bytes as it goes, so    /// those bytes stay unchanged while the cursor is in use.    pub fn cursor(self: View) Cursor {        return .{            .view = self,            .header_offset = self.header_start,            .body_offset = self.header_len,        };    }    pub fn column(self: View, index: usize) Error!Value {        var reader = self.cursor();        return reader.column(index);    }    pub fn project(self: View, indexes: []const usize, target: []Value) Error![]Value {        if (target.len < indexes.len) return error.OutputTooSmall;        var reader = self.cursor();        for (indexes, 0..) |index, ordinal| {            target[ordinal] = try reader.column(index);        }        return target[0..indexes.len];    }    pub fn compare(self: View, other: View, columns: []const Column) Error!std.math.Order {        const count = @max(self.count, other.count);        var left_cursor = self.cursor();        var right_cursor = other.cursor();        var index: usize = 0;        while (index < count) : (index += 1) {            const left: Value = if (index < self.count) try left_cursor.column(index) else .nil;            const right: Value = if (index < other.count) try right_cursor.column(index) else .nil;            const collation = if (index < columns.len) columns[index].collation else Collation.binary;            const order = compareValues(left, right, collation);            if (order != .eq) return order;        }        return .eq;    }};

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

zig
pub const RowView = row.View;
Called byCallsprivate sourcelib.sql.src.catalogcatalogEntryprivate sourcelib.sql.src.catalogdefaultValuetest sourcelib.sql.src.catalogtest: catalog allocates distinct root...test sourcelib.sql.src.catalogtest: catalog persists relation metad...test sourcelib.sql.src.catalogtest: catalog reader exposes one snap...+70 moreRowViewcursorRowViewcolumn
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callsprivate sourcelib.sql.src.catalogdefaultValuerelationapplyUpdatetest sourcelib.sql.src.rowtest: row encodes typed values and pr...RowViewcolumnCount
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersRowViewcursorrowcompareValuesRowViewcompare
Static calls · unresolved targets: 0 · external targets: 3.
Called byCallsNo direct callsrelationapplyUpdaterow.CursorcolumnRowViewcolumnRowViewcompareRowViewproject+2 moreRowViewcursor
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsCatalogprepareRelationStatsprivate sourcelib.sql.src.catalogcatalogEntryprivate sourcelib.sql.src.catalogdefaultValueprivate sourcelib.sql.src.catalogprepareDistributionKeystest sourcelib.sql.src.catalogtest: catalog allocates distinct root...+88 moreprivate sourcelib.sql.src.rowcheckedAddprivate sourcelib.sql.src.rowreadVarintprivate sourcelib.sql.src.rowserialBodySizeRowViewinit
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsprivate sourcelib.sql.src.catalogprepareDistributionKeystest sourcelib.sql.src.rowtest: row cursor preserves forward ba...test sourcelib.sql.src.rowtest: row cursor preserves noncanonic...test sourcelib.sql.src.rowtest: row encodes typed values and pr...test sourcelib.sql.src.rowtest: row rejects invalid and truncat...private sourcelib.sql.src.versionindexRootFromRowsRowViewcursorRowViewproject
Static calls · unresolved targets: 0 · external targets: 1.

Complete caller list for RowView.column

75 direct callers.

Complete caller list for RowView.cursor

7 direct callers.

Complete caller list for RowView.init

93 direct callers.

Audit

Definitions7
Public names14
Members4
Version26.7.0
Revisiondaab053ee433