recordset

package
v0.41.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2025 License: MIT Imports: 4 Imported by: 0

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

func ColDbType added in v0.39.0

func ColDbType(dbType string) func(o *ColumnOptions)

func Format added in v0.35.0

func Format(format func(value any) string) func(o *ColumnOptions)

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)
	DbType() string
	ValueType() reflect.Type
	IsBitmap() bool
	Add(value T) error
	Values() []T
}

func NewBitmapColumn added in v0.32.0

func NewBitmapColumn[T comparable](name string, initialCapacity int, getDefaultVal func() T, options ...ColumnOption) Column[T]

func NewBoolColumn added in v0.32.0

func NewBoolColumn(name string, options ...ColumnOption) Column[bool]

func NewColumn

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

func NewTypedColumn added in v0.35.0

func NewTypedColumn[T any](name string, defaultValue T, options ...ColumnOption) Column[T]

func UntypedCol added in v0.35.0

func UntypedCol[T any](c Column[T]) Column[any]

type ColumnAccessor

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

type ColumnOption added in v0.35.0

type ColumnOption = func(o *ColumnOptions)

type ColumnOptions added in v0.35.0

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

type ColumnarRecordset

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

func NewColumnarRecordset

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

func (*ColumnarRecordset) Columns added in v0.35.0

func (c *ColumnarRecordset) Columns() (columns []Column[any])

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 Option added in v0.39.1

type Option func(o *options)

func WithName added in v0.39.1

func WithName(name string) Option

type Options added in v0.39.1

type Options interface {
	Name() string
}

func NewOptions added in v0.39.1

func NewOptions(opts ...Option) Options

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

type UntypedColWrapper added in v0.35.0

type UntypedColWrapper[T any] struct {
	// contains filtered or unexported fields
}

func (UntypedColWrapper[T]) Add added in v0.35.0

func (c UntypedColWrapper[T]) Add(value any) error

func (UntypedColWrapper[T]) DbType added in v0.39.0

func (c UntypedColWrapper[T]) DbType() string

func (UntypedColWrapper[T]) DefaultValue added in v0.35.0

func (c UntypedColWrapper[T]) DefaultValue() (value any)

func (UntypedColWrapper[T]) GetValue added in v0.35.0

func (c UntypedColWrapper[T]) GetValue(row int) (value any, err error)

func (UntypedColWrapper[T]) IsBitmap added in v0.35.0

func (c UntypedColWrapper[T]) IsBitmap() bool

func (UntypedColWrapper[T]) Name added in v0.35.0

func (c UntypedColWrapper[T]) Name() string

func (UntypedColWrapper[T]) SetValue added in v0.35.0

func (c UntypedColWrapper[T]) SetValue(row int, value any) (err error)

func (UntypedColWrapper[T]) TypedColumn added in v0.35.0

func (c UntypedColWrapper[T]) TypedColumn() Column[T]

func (UntypedColWrapper[T]) ValueType added in v0.35.0

func (c UntypedColWrapper[T]) ValueType() reflect.Type

func (UntypedColWrapper[T]) Values added in v0.35.0

func (c UntypedColWrapper[T]) Values() []any

Jump to

Keyboard shortcuts

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