row

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package row provides row serialization for XxSql storage engine.

Index

Constants

View Source
const (
	// RowHeaderSize is the size of the row header in bytes.
	// RowID (8 bytes) + ColumnCount (2 bytes) = 10 bytes
	RowHeaderSize = 10

	// MaxRowSize is the maximum size of a row.
	// Limit to fit within a page with some overhead
	MaxRowSize = 3500
)

Variables

This section is empty.

Functions

func DeserializeValues

func DeserializeValues(data []byte, types_ []types.TypeID) ([]types.Value, error)

DeserializeValues deserializes bytes to values (without row ID).

func SerializeRow

func SerializeRow(id RowID, values []types.Value) ([]byte, error)

SerializeRow serializes a slice of values with row ID.

Types

type Row

type Row struct {
	ID         RowID
	Values     []types.Value
	ColumnDefs []*types.ColumnInfo
}

Row represents a table row.

func DeserializeRow

func DeserializeRow(data []byte, defs []*types.ColumnInfo) (*Row, error)

DeserializeRow deserializes bytes to a row. It handles the case where columns have been added after the row was created by filling missing columns with NULL values.

func NewRow

func NewRow(id RowID, defs []*types.ColumnInfo) *Row

NewRow creates a new row with the given column definitions.

func (*Row) GetValue

func (r *Row) GetValue(index int) (types.Value, error)

GetValue returns the value at the given column index.

func (*Row) GetValueByName

func (r *Row) GetValueByName(name string) (types.Value, error)

GetValueByName returns the value for the given column name.

func (*Row) Serialize

func (r *Row) Serialize() ([]byte, error)

Serialize serializes the row to bytes.

func (*Row) SetValue

func (r *Row) SetValue(index int, v types.Value) error

SetValue sets the value at the given column index.

func (*Row) Size

func (r *Row) Size() int

Size returns the serialized size of the row.

func (*Row) String

func (r *Row) String() string

String returns a string representation of the row.

type RowBuilder

type RowBuilder struct {
	// contains filtered or unexported fields
}

RowBuilder provides a fluent interface for building rows.

func NewRowBuilder

func NewRowBuilder(id RowID, defs []*types.ColumnInfo) *RowBuilder

NewRowBuilder creates a new row builder.

func (*RowBuilder) Build

func (b *RowBuilder) Build() (*Row, error)

Build returns the built row or an error.

func (*RowBuilder) Set

func (b *RowBuilder) Set(index int, v types.Value) *RowBuilder

Set sets a value directly.

func (*RowBuilder) SetBool

func (b *RowBuilder) SetBool(index int, v bool) *RowBuilder

SetBool sets a boolean value.

func (*RowBuilder) SetFloat

func (b *RowBuilder) SetFloat(index int, v float64) *RowBuilder

SetFloat sets a float value.

func (*RowBuilder) SetInt

func (b *RowBuilder) SetInt(index int, v int64) *RowBuilder

SetInt sets an integer value.

func (*RowBuilder) SetNull

func (b *RowBuilder) SetNull(index int) *RowBuilder

SetNull sets a null value.

func (*RowBuilder) SetString

func (b *RowBuilder) SetString(index int, v string, typ types.TypeID) *RowBuilder

SetString sets a string value.

type RowID

type RowID uint64

RowID represents a unique row identifier.

const InvalidRowID RowID = 0

InvalidRowID represents an invalid row ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL