table

package
v0.0.0-...-a414206 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TYPE_ERROR = 0
	TYPE_BYTES = 1
	TYPE_INT64 = 2
	TYPE_INF   = 0xff
)
View Source
const (
	INDEX_ADD = 1
	INDEX_DEL = 2
)
View Source
const TABLE_PREFIX_MIN = 100

Variables

View Source
var INTERNAL_TABLES map[string]*TableDef = map[string]*TableDef{
	"@meta":  TDEF_META,
	"@table": TDEF_TABLE,
}
View Source
var TDEF_META = &TableDef{
	Name:     "@meta",
	Types:    []uint32{TYPE_BYTES, TYPE_BYTES},
	Cols:     []string{"key", "val"},
	Prefixes: []uint32{1},
	Indexes:  [][]string{{"key"}},
}

INTERNAL TABLES store metadata

View Source
var TDEF_TABLE = &TableDef{
	Name:     "@table",
	Types:    []uint32{TYPE_BYTES, TYPE_BYTES},
	Cols:     []string{"name", "def"},
	Prefixes: []uint32{2},
	Indexes:  [][]string{{"name"}},
}

store table schemas

Functions

This section is empty.

Types

type DB

type DB struct {
	Path string
	// contains filtered or unexported fields
}

func (*DB) Abort

func (db *DB) Abort(tx *DBTX)

func (*DB) Begin

func (db *DB) Begin(tx *DBTX)

func (*DB) Close

func (db *DB) Close()

func (*DB) Commit

func (db *DB) Commit(tx *DBTX) error

func (*DB) Open

func (db *DB) Open() error

type DBTX

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

func (*DBTX) Delete

func (tx *DBTX) Delete(table string, rec Record) (bool, error)

func (*DBTX) Get

func (tx *DBTX) Get(table string, rec *Record) (bool, error)

func (*DBTX) Insert

func (tx *DBTX) Insert(table string, rec Record) (bool, error)

func (*DBTX) Revert

func (tx *DBTX) Revert(save *transactions.TXSave)

func (*DBTX) Save

func (tx *DBTX) Save(save *transactions.TXSave)

func (*DBTX) Scan

func (tx *DBTX) Scan(table string, req *Scanner) error

func (*DBTX) Set

func (tx *DBTX) Set(table string, dbreq *DBUpdateReq) (bool, error)

addin a record

func (*DBTX) TableNew

func (tx *DBTX) TableNew(tdef *TableDef) error

func (*DBTX) Update

func (tx *DBTX) Update(table string, rec Record) (bool, error)

func (*DBTX) Upsert

func (tx *DBTX) Upsert(table string, rec Record) (bool, error)

type DBUpdateReq

type DBUpdateReq struct {
	Record  Record
	Mode    int
	Updated bool
	Added   bool
}

type Record

type Record struct {
	Cols []string
	Vals []Value
}

represents a list of col names and values

func (*Record) AddInt64

func (rec *Record) AddInt64(col string, val int64) *Record

func (*Record) AddStr

func (rec *Record) AddStr(col string, val []byte) *Record

func (*Record) Get

func (rec *Record) Get(key string) *Value

type Scanner

type Scanner struct {
	Cmp1 int
	Cmp2 int

	// range from Key 1 to key2
	Key1 Record
	Key2 Record
	// contains filtered or unexported fields
}

scanner decodes KV's into rows iterator for range queries Scanner is a wrapper for B+ Tree iterator

func (*Scanner) Deref

func (sc *Scanner) Deref(rec *Record)

return current row

func (*Scanner) Next

func (sc *Scanner) Next()

movin underlying B+ tree iterator

func (*Scanner) Valid

func (sc *Scanner) Valid() bool

within range or not

type TableDef

type TableDef struct {
	Name     string
	Types    []uint32 //col type
	Cols     []string //col name
	Prefixes []uint32
	Indexes  [][]string
}

type Value

type Value struct {
	Type uint32
	I64  int64
	Str  []byte
}

table cell

Jump to

Keyboard shortcuts

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