recordset

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 4 Imported by: 8

README

recordset package

Provides interfaces and implementation for effective work with a columnized set of data rows.

The base interface is Recordset and there is 3 implementations:

  • recordset.NewColumnarRecordset(...) - the most memory efficient
  • recordset.NewMappedRecordset(...) - could be efficient for CSV files
  • recordset.NewSlicedRecordset(...) - TODO: Needs justification

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column[T any] interface {
	Name() string
	DefaultValue() T
	GetValue(row int) (value T, err error)
	SetValue(row int, value T) (err error)
	ValueType() reflect.Type
	IsBitmap() bool
	Add(value T) error
}

func NewBitmapColumn added in v0.32.0

func NewBitmapColumn[T comparable](name string, initialCapacity int) Column[T]

func NewBoolColumn added in v0.32.0

func NewBoolColumn(name string) Column[bool]

func NewColumn

func NewColumn[T any](name string, defaultValue T, values ...T) Column[any]

type ColumnAccessor

type ColumnAccessor interface {
	ColumnsCount() int
	GetColumnByIndex(i int) Column[any]
	GetColumnByName(name string) Column[any]
	GetColumnIndex(name string) int
}

type ColumnarRecordset

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

func NewColumnarRecordset

func NewColumnarRecordset(cols ...Column[any]) *ColumnarRecordset

func (*ColumnarRecordset) ColumnsCount

func (c *ColumnarRecordset) ColumnsCount() int

func (*ColumnarRecordset) GetColumnByIndex

func (c *ColumnarRecordset) GetColumnByIndex(i int) Column[any]

func (*ColumnarRecordset) GetColumnByName

func (c *ColumnarRecordset) GetColumnByName(name string) Column[any]

func (*ColumnarRecordset) GetColumnIndex

func (c *ColumnarRecordset) GetColumnIndex(name string) int

func (*ColumnarRecordset) GetRow

func (rs *ColumnarRecordset) GetRow(i int) Row

func (*ColumnarRecordset) Name

func (rs *ColumnarRecordset) Name() string

func (*ColumnarRecordset) NewRow

func (rs *ColumnarRecordset) NewRow() Row

func (*ColumnarRecordset) RowsCount

func (rs *ColumnarRecordset) RowsCount() int

type Recordset

type Recordset interface {
	ColumnAccessor
	Name() string // Can be useful for debugging purpose (or for joining?)
	NewRow() Row

	// GetRow returns nil if out of range
	GetRow(i int) Row

	RowsCount() int
}

Recordset provides interface for working with a set of row/column based data

type Row

type Row interface {
	GetValueByName(name string, rs Recordset) (any, error)
	SetValueByName(name string, value any, rs Recordset) error
	GetValueByIndex(i int, rs Recordset) (any, error)
	SetValueByIndex(i int, value any, rs Recordset) error
	Data(rs Recordset) (data []any, err error)
}

Row defines an interface for storing recordset row data. We intentionally pass cols information to functions of the interface so we do not need to allocate memory for cols pointer in each row.

type Type added in v0.33.0

type Type int
const (
	UnknownType Type = iota
	Table
	View
	StoredProcedure
)

func (Type) String added in v0.33.0

func (t Type) String() string

Jump to

Keyboard shortcuts

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