Documentation
¶
Index ¶
- Constants
- Variables
- type BIter
- type BNode
- type BTree
- type CombinedIter
- type CommittedTX
- type DB
- type DBTX
- func (tx *DBTX) Delete(table string, rec Record) (bool, error)
- func (tx *DBTX) Get(table string, rec *Record) (bool, error)
- func (tx *DBTX) Insert(table string, rec Record) (bool, error)
- func (tx *DBTX) Revert(save *TXSave)
- func (tx *DBTX) Save(save *TXSave)
- func (tx *DBTX) Scan(table string, req *Scanner) error
- func (tx *DBTX) Set(table string, dbreq *DBUpdateReq) (bool, error)
- func (tx *DBTX) TableNew(tdef *TableDef) error
- func (tx *DBTX) Update(table string, rec Record) (bool, error)
- func (tx *DBTX) Upsert(table string, rec Record) (bool, error)
- type DBUpdateReq
- type DeleteReq
- type FreeList
- type KV
- type KVIter
- type KVTX
- func (tx *KVTX) Del(req *DeleteReq) bool
- func (tx *KVTX) Get(key []byte) ([]byte, bool)
- func (tx *KVTX) Revert(save *TXSave)
- func (tx *KVTX) Save(save *TXSave)
- func (tx *KVTX) Seek(key1 []byte, cmp1 int, key2 []byte, cmp2 int) KVIter
- func (tx *KVTX) Set(key []byte, val []byte) bool
- func (tx *KVTX) Update(req *UpdateReq) bool
- type KeyRange
- type LNode
- type Parser
- type QLCreateTable
- type QLDelete
- type QLEvalContex
- type QLInsert
- type QLNode
- type QLResult
- type QLScan
- type QLSelect
- type QLUpdate
- type Record
- type RecordIter
- type Scanner
- type StmtSplitter
- type TXSave
- type TableDef
- type UpdateReq
- type Value
Constants ¶
View Source
const ( BNODE_NODE = 1 // internal nodes without values BNODE_LEAF = 2 // leaf nodes with values )
View Source
const ( MODE_UPSERT = 0 // insert or replace MODE_UPDATE_ONLY = 1 // update existing keys MODE_INSERT_ONLY = 2 // only add new keys )
update modes
View Source
const ( CMP_GE = +3 // >= CMP_GT = +2 // > CMP_LT = -2 // < CMP_LE = -3 // <= )
View Source
const ( QL_UNINIT = 0 // scalar QL_STR = TYPE_BYTES QL_I64 = TYPE_INT64 // binary ops QL_CMP_GE = 10 // >= QL_CMP_GT = 11 // > QL_CMP_LT = 12 // < QL_CMP_LE = 13 // <= QL_CMP_EQ = 14 // == QL_CMP_NE = 15 // != QL_ADD = 20 QL_SUB = 21 QL_MUL = 22 QL_DIV = 23 QL_MOD = 24 QL_AND = 30 QL_OR = 31 // QL_IN = 32 // unary ops QL_NOT = 50 QL_NEG = 51 // others QL_SYM = 100 // column QL_TUP = 101 // tuple QL_STAR = 102 // select * QL_ERR = 200 // error; from parsing or evaluation )
syntax tree node types
View Source
const ( TYPE_ERROR = 0 // uninitialized TYPE_BYTES = 1 TYPE_INT64 = 2 TYPE_INF = 0xff // do not use )
View Source
const ( INDEX_ADD = 1 INDEX_DEL = 2 )
View Source
const ( FLAG_DELETED = byte(1) FLAG_UPDATED = byte(2) )
a prefix for values in KVTX.pending
View Source
const BTREE_MAX_KEY_SIZE = 1000
View Source
const BTREE_MAX_VAL_SIZE = 3000
View Source
const BTREE_PAGE_SIZE = 4096
View Source
const DB_SIG = "BuildYourOwnDB13"
View Source
const FREE_LIST_CAP = (BTREE_PAGE_SIZE - FREE_LIST_HEADER) / 16
View Source
const FREE_LIST_HEADER = 8
View Source
const HEADER = 4
View Source
const TABLE_PREFIX_MIN = 100
Variables ¶
View Source
var ErrorConflict = errors.New("cannot commit due to conflict")
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"}, Indexes: [][]string{{"key"}}, Prefixes: []uint32{1}, }
internal table: metadata
View Source
var TDEF_TABLE = &TableDef{ Name: "@table", Types: []uint32{TYPE_BYTES, TYPE_BYTES}, Cols: []string{"name", "def"}, Indexes: [][]string{{"name"}}, Prefixes: []uint32{2}, }
internal table: table schemas
Functions ¶
This section is empty.
Types ¶
type BTree ¶
type BTree struct {
// contains filtered or unexported fields
}
type CombinedIter ¶
type CombinedIter struct {
// contains filtered or unexported fields
}
an iterator that combines pending updates and the snapshot
func (*CombinedIter) Deref ¶
func (iter *CombinedIter) Deref() ([]byte, []byte)
func (*CombinedIter) Next ¶
func (iter *CombinedIter) Next()
func (*CombinedIter) Valid ¶
func (iter *CombinedIter) Valid() bool
type CommittedTX ¶
type CommittedTX struct {
// contains filtered or unexported fields
}
type DBTX ¶
type DBTX struct {
// contains filtered or unexported fields
}
DB transaction
type DBUpdateReq ¶
type FreeList ¶
type FreeList struct {
// contains filtered or unexported fields
}
type KV ¶
type KVTX ¶
type KVTX struct {
// contains filtered or unexported fields
}
KV transaction
type KeyRange ¶
type KeyRange struct {
// contains filtered or unexported fields
}
start <= key <= stop
type LNode ¶
type LNode []byte
node format: | next | pointer + version | unused | | 8B | n*(8B+8B) | ... |
type QLEvalContex ¶
type QLEvalContex struct {
// contains filtered or unexported fields
}
for evaluating expressions
type QLInsert ¶
type QLInsert struct { Table string Mode int // insert | upsert | replace Names []string Values [][]QLNode }
stmt: insert
type QLResult ¶
type QLResult struct { Records RecordIter Added uint64 Updated uint64 Deleted uint64 }
type QLScan ¶
type QLScan struct { Table string // table name Key1 QLNode // index by Key2 QLNode Filter QLNode // filter Offset int64 // limit Limit int64 }
common structure for queries: `INDEX BY`, `FILTER`, `LIMIT`
type RecordIter ¶
type Scanner ¶
type Scanner struct { // the range, from Key1 to Key2 Cmp1 int // CMP_?? Cmp2 int Key1 Record Key2 Record // contains filtered or unexported fields }
the iterator for range queries
type StmtSplitter ¶
type StmtSplitter struct {
// contains filtered or unexported fields
}
func (*StmtSplitter) Feed ¶
func (self *StmtSplitter) Feed(line string)
func (*StmtSplitter) Pop ¶
func (self *StmtSplitter) Pop() ([]byte, bool)
type TXSave ¶
type TXSave struct {
// contains filtered or unexported fields
}
for reverting updates inside a TX
type TableDef ¶
type TableDef struct { // user defined Name string Types []uint32 // column types Cols []string // column names Indexes [][]string // the first index is the primary key // auto-assigned B-tree key prefixes for different tables and indexes Prefixes []uint32 }
table schema
Click to show internal directories.
Click to hide internal directories.