Documentation ¶
Overview ¶
Package edb implements a document database on top of a key-value store (in this case, on top of Bolt).
We implement:
1. Tables, collection of arbitrary documents marshaled from the given struct.
2. Indices, allowing quick lookup of table data by custom values.
3. Maps, exposing raw key-value buckets with string keys and untyped values.
4. Singleton Keys, allowing to store a typed value for a given key within a map (say, a “config” value in a “globals” map).
Technical Details ¶
**Buckets.** We rely on scoped namespaces for keys called buckets. Bolt supports them natively. A flat database like Redis could simulate buckets via key prefixes. We use nested buckets in Bolt, but only for conveninece; flat buckets are fine.
**Index ordinal** We assign a unique positive integer ordinal to each index. These values are never reused, even if an index is removed.
**Table states** We store a meta document per table, called “table state”. This document holds the information about which indexes are defined for the table, and assigns a (an ordinal) to each one. Ordinals are never reused as indexes are removed and added.
## Binary encoding
**Key encoding**. Keys are encoded using a _tuple encoding_.
**Value**: value header, then encoded data, then encoded index key records.
**Value header**: 1. Flags (uvarint). 2. Schema version (uvarint). 3. Data size (uvarint). 3. Index size (uvarint).
**Value data**: msgpack of the row struct.
**Index key records** (inside a value) record the keys contributed by this row. If index computation changes in the future, we still need to know which index keys to delete when updating the row, so we store all index keys. Format: 1. Number of entries (uvarint). 2. For each entry: index ordinal (uvarint), key length (uvarint), key bytes.
Index ¶
- Constants
- Variables
- func All[Row any](c Cursor[Row]) []*Row
- func AllKeys[Key any](c RawCursor) []Key
- func AllLimited[Row any](c Cursor[Row], limit int) []*Row
- func AllRawKeys(c RawCursor) [][]byte
- func AllTableRows[Row any](txh Txish) []*Row
- func AllUntypedKeys(c RawCursor) []any
- func Count(c RawCursor) int
- func CountAll(txh Txish, tbl *Table) int
- func DeleteAll(c RawCursor) int
- func DeleteByKey[Row any](txh Txish, key any) bool
- func DeleteRow[Row any](txh Txish, row *Row) bool
- func Exists[Row any](txh Txish, key any) bool
- func Filter[Row any](c Cursor[Row], f func(*Row) bool) []*Row
- func First[Row any](c Cursor[Row]) *Row
- func Foo() int64
- func Get[Row any](txh Txish, key any) *Row
- func GetByKeyRaw[Row any](txh Txish, keyRaw []byte) *Row
- func Lookup[Row any](txh Txish, idx *Index, indexKey any) *Row
- func LookupExists(txh Txish, idx *Index, indexKey any) bool
- func LookupKey[Key any](txh Txish, idx *Index, indexKey any) (Key, bool)
- func Memo[T any](txish Txish, key string, f func() (T, error)) (T, error)
- func Proto[T any]() any
- func Put(txh Txish, rows ...any) bool
- func Reload[Row any](txh Txish, row *Row) *Row
- func SGet[T any](txh Txish, sk *SKey, v *T) bool
- func SGetRaw(txh Txish, sk *SKey) []byte
- func SPut[T any](txh Txish, sk *SKey, v *T)
- func SPutRaw(txh Txish, sk *SKey, raw []byte)
- func Select[Row any](c Cursor[Row], f func(*Row) bool) *Row
- type Change
- func (chg *Change) HasKey() bool
- func (chg *Change) HasOldRow() bool
- func (chg *Change) HasRow() bool
- func (chg *Change) Key() any
- func (chg *Change) KeyVal() reflect.Value
- func (chg *Change) OldRow() any
- func (chg *Change) OldRowVal() reflect.Value
- func (chg *Change) Op() Op
- func (chg *Change) RawKey() []byte
- func (chg *Change) Row() any
- func (chg *Change) RowVal() reflect.Value
- func (chg *Change) Table() *Table
- type ChangeFlags
- type Cursor
- func ExactIndexScan[Row any](txh Txish, idx *Index, indexValue any) Cursor[Row]
- func ExactTableScan[Row any](txh Txish, value any) Cursor[Row]
- func FullIndexScan[Row any](txh Txish, idx *Index) Cursor[Row]
- func FullReverseTableScan[Row any](txh Txish) Cursor[Row]
- func FullTableScan[Row any](txh Txish) Cursor[Row]
- func IndexScan[Row any](txh Txish, idx *Index, opt ScanOptions) Cursor[Row]
- func PrefixIndexScan[Row any](txh Txish, idx *Index, els int, indexValue any) Cursor[Row]
- func RangeIndexScan[Row any](txh Txish, idx *Index, lowerValue, upperValue any, lowerInc, upperInc bool) Cursor[Row]
- func RangeTableScan[Row any](txh Txish, lowerValue, upperValue any, lowerInc, upperInc bool) Cursor[Row]
- func ReverseExactIndexScan[Row any](txh Txish, idx *Index, indexValue any) Cursor[Row]
- func ReversePrefixIndexScan[Row any](txh Txish, idx *Index, els int, indexValue any) Cursor[Row]
- func ReverseRangeIndexScan[Row any](txh Txish, idx *Index, lowerValue, upperValue any, lowerInc, upperInc bool) Cursor[Row]
- func ReverseRangeTableScan[Row any](txh Txish, lowerValue, upperValue any, lowerInc, upperInc bool) Cursor[Row]
- func TableScan[Row any](txh Txish, opt ScanOptions) Cursor[Row]
- type DB
- func (db *DB) BeginRead() *Tx
- func (db *DB) BeginUpdate() *Tx
- func (db *DB) Bolt() *bbolt.DB
- func (db *DB) Close()
- func (db *DB) DescribeOpenTxns() string
- func (db *DB) IsClosed() bool
- func (db *DB) Read(f func(tx *Tx))
- func (db *DB) ReadErr(f func(tx *Tx) error) error
- func (db *DB) Size() int64
- func (db *DB) Tx(writable bool, f func(tx *Tx) error) error
- func (db *DB) Write(f func(tx *Tx))
- type DataError
- type DumpFlags
- type FlatMarshaler
- type FlatMarshallable
- type FlatUnmarshaler
- type Index
- func (idx *Index) DecodeIndexKeyVal(tup tuple) reflect.Value
- func (idx *Index) DecodeIndexKeyValInto(keyVal reflect.Value, tup tuple)
- func (idx *Index) FullName() string
- func (idx *Index) ParseNakedIndexKey(s string) (any, error)
- func (idx *Index) ParseNakedIndexKeyVal(s string) (reflect.Value, error)
- func (idx *Index) ShortName() string
- func (idx *Index) Table() *Table
- func (idx *Index) Unique() *Index
- type IndexBuilder
- type IndexOpt
- type IndexRow
- type KVCursor
- func (c *KVCursor) IndexKeys() func(yield func(k []byte) bool)
- func (c *KVCursor) Keys() func(yield func(k []byte) bool)
- func (c *KVCursor) Next() bool
- func (c *KVCursor) Object() kvo.ImmutableMap
- func (c *KVCursor) Objects() func(yield func(k []byte, o kvo.ImmutableMap) bool)
- func (c *KVCursor) RawIndexKey() []byte
- func (c *KVCursor) RawKey() []byte
- func (c *KVCursor) RawValue() []byte
- func (c *KVCursor) RawValues() func(yield func(k, v []byte) bool)
- type KVIndex
- type KVIndexContentBuilder
- type KVIndexKey
- type KVIndexKeyToPrimaryKey
- type KVIndexer
- type KVKey
- type KVMap
- type KVTable
- type KVTableBuilder
- type Op
- type Options
- type RawCursor
- type RawIndexCursor
- func (c *RawIndexCursor) IndexKey() any
- func (c *RawIndexCursor) Key() any
- func (c *RawIndexCursor) Meta() ValueMeta
- func (c *RawIndexCursor) Next() bool
- func (c *RawIndexCursor) RawKey() []byte
- func (c *RawIndexCursor) RawRow() []byte
- func (c *RawIndexCursor) Row() (any, ValueMeta)
- func (c *RawIndexCursor) RowVal() (reflect.Value, ValueMeta)
- func (c *RawIndexCursor) Table() *Table
- func (c *RawIndexCursor) TryRow() (any, ValueMeta, error)
- func (c *RawIndexCursor) TryRowVal() (reflect.Value, ValueMeta, error)
- func (c *RawIndexCursor) Tx() *Tx
- type RawRange
- func RawEE(l, u []byte) RawRange
- func RawEI(l, u []byte) RawRange
- func RawEO(l []byte) RawRange
- func RawIE(l, u []byte) RawRange
- func RawII(l, u []byte) RawRange
- func RawIO(l []byte) RawRange
- func RawOE(u []byte) RawRange
- func RawOI(u []byte) RawRange
- func RawOO() RawRange
- func RawPrefix(p []byte) RawRange
- type RawRangeCursor
- type RawTableCursor
- func (c *RawTableCursor) Key() any
- func (c *RawTableCursor) Meta() ValueMeta
- func (c *RawTableCursor) Next() bool
- func (c *RawTableCursor) RawKey() []byte
- func (c *RawTableCursor) RawRow() []byte
- func (c *RawTableCursor) Row() (any, ValueMeta)
- func (c *RawTableCursor) RowVal() (reflect.Value, ValueMeta)
- func (c *RawTableCursor) Table() *Table
- func (c *RawTableCursor) TryRow() (any, ValueMeta, error)
- func (c *RawTableCursor) TryRowVal() (reflect.Value, ValueMeta, error)
- func (c *RawTableCursor) Tx() *Tx
- type SKey
- type ScanMethod
- type ScanOptions
- func ExactIDRangeScan(exact, lower, upper any, lowerInc, upperInc bool) ScanOptions
- func ExactIDRangeScanVal(exact, lower, upper reflect.Value, lowerInc, upperInc bool) ScanOptions
- func ExactScan(v any) ScanOptions
- func ExactScanVal(val reflect.Value) ScanOptions
- func FullScan() ScanOptions
- func LowerBoundScan(lower any, includeEqual bool) ScanOptions
- func RangeScan(lower, upper any, lowerInc, upperInc bool) ScanOptions
- func RangeScanVal(lower, upper reflect.Value, lowerInc, upperInc bool) ScanOptions
- func UpperBoundScan(upper any, includeEqual bool) ScanOptions
- type Schema
- func (scm *Schema) Include(peer *Schema)
- func (scm *Schema) KVTableNamed(name string) *KVTable
- func (scm *Schema) KVTables() []*KVTable
- func (scm *Schema) TableByRow(row any) *Table
- func (scm *Schema) TableByRowType(rt reflect.Type) *Table
- func (scm *Schema) TableNamed(name string) *Table
- func (scm *Schema) Tables() []*Table
- type Table
- func (tbl *Table) AddIndex(idx *Index) *Table
- func (tbl *Table) DecodeKeyVal(rawKey []byte) reflect.Value
- func (tbl *Table) DecodeKeyValInto(keyVal reflect.Value, rawKey []byte)
- func (tbl *Table) EncodeKey(key any) []byte
- func (tbl *Table) EncodeKeyVal(keyVal reflect.Value) []byte
- func (tbl *Table) IndexNamed(name string) *Index
- func (tbl *Table) KeyString(key any) string
- func (tbl *Table) KeyType() reflect.Type
- func (tbl *Table) Name() string
- func (tbl *Table) NewRow() any
- func (tbl *Table) NewRowVal() reflect.Value
- func (tbl *Table) ParseKey(s string) (any, error)
- func (tbl *Table) ParseKeyVal(s string) (reflect.Value, error)
- func (tbl *Table) RawKeyString(keyRaw []byte) string
- func (tbl *Table) RowHasZeroKey(row any) bool
- func (tbl *Table) RowKey(row any) any
- func (tbl *Table) RowKeyVal(rowVal reflect.Value) reflect.Value
- func (tbl *Table) RowType() reflect.Type
- func (tbl *Table) RowValHasZeroKey(rowVal reflect.Value) bool
- func (tbl *Table) SetRowKey(row, key any)
- func (tbl *Table) SetRowKeyVal(rowVal, keyVal reflect.Value)
- type TableBuilder
- func (b *TableBuilder[Row, Key]) AddIndex(idx *Index)
- func (b *TableBuilder[Row, Key]) Indexer(f func(row *Row, ib *IndexBuilder))
- func (b *TableBuilder[Row, Key]) Migrate(f func(tx *Tx, row *Row, oldVer uint64))
- func (b *TableBuilder[Row, Key]) SetSchemaVersion(ver uint64)
- func (b *TableBuilder[Row, Key]) SuppressContentWhenLogging()
- func (b *TableBuilder[Row, Key]) Tag(tag *Tag)
- type TableError
- type TableStats
- type Tag
- type TagFamily
- type TagFamilyCardinality
- type TaggableImpl
- type Tx
- func (tx *Tx) BeginVerbose()
- func (tx *Tx) Close()
- func (tx *Tx) Commit() error
- func (tx *Tx) CommitDespiteError()
- func (tx *Tx) DB() *DB
- func (tx *Tx) DBTx() *Tx
- func (tx *Tx) DeleteByKey(tbl *Table, key any) bool
- func (tx *Tx) DeleteByKeyRaw(tbl *Table, keyRaw []byte) bool
- func (tx *Tx) DeleteByKeyVal(tbl *Table, keyVal reflect.Value) bool
- func (tx *Tx) Dump(f DumpFlags) string
- func (tx *Tx) EndVerbose()
- func (tx *Tx) Exists(tbl *Table, key any) bool
- func (tx *Tx) ExistsByKeyRaw(tbl *Table, keyRaw []byte) bool
- func (tx *Tx) Get(tbl *Table, key any) (any, ValueMeta)
- func (tx *Tx) GetByKeyRaw(tbl *Table, keyRaw []byte) (any, ValueMeta)
- func (tx *Tx) GetByKeyVal(tbl *Table, keyVal reflect.Value) (any, ValueMeta)
- func (tx *Tx) GetMemo(key string) (any, bool)
- func (tx *Tx) GetMeta(tbl *Table, key any) ValueMeta
- func (tx *Tx) GetMetaByKeyVal(tbl *Table, keyVal reflect.Value) ValueMeta
- func (tx *Tx) IndexScan(idx *Index, opt ScanOptions) *RawIndexCursor
- func (tx *Tx) IsWritable() bool
- func (tx *Tx) KVGet(tbl *KVTable, key []byte) kvo.ImmutableMap
- func (tx *Tx) KVGetRaw(tbl *KVTable, key []byte) []byte
- func (tx *Tx) KVIndexScan(idx *KVIndex, rang RawRange) *KVCursor
- func (tx *Tx) KVPut(tbl *KVTable, key []byte, value kvo.Packable)
- func (tx *Tx) KVPutRaw(tbl *KVTable, key, value []byte)
- func (tx *Tx) KVTableScan(tbl *KVTable, rang RawRange) *KVCursor
- func (tx *Tx) KVTableStats(tbl *KVTable) TableStats
- func (tx *Tx) Lookup(idx *Index, indexKey any) any
- func (tx *Tx) LookupExists(idx *Index, indexKeyVal reflect.Value) bool
- func (tx *Tx) LookupKey(idx *Index, indexKey any) any
- func (tx *Tx) LookupKeyVal(idx *Index, indexKeyVal reflect.Value) reflect.Value
- func (tx *Tx) LookupVal(idx *Index, indexKeyVal reflect.Value) (reflect.Value, ValueMeta)
- func (tx *Tx) Memo(key string, f func() (any, error)) (any, error)
- func (tx *Tx) OnChange(opts map[*Table]ChangeFlags, f func(tx *Tx, chg *Change))
- func (tx *Tx) Put(tbl *Table, row any) (oldMeta, newMeta ValueMeta)
- func (tx *Tx) PutVal(tbl *Table, rowVal reflect.Value) (oldMeta, newMeta ValueMeta)
- func (tx *Tx) Reindex(tbl *Table, idx *Index)
- func (tx *Tx) Schema() *Schema
- func (tx *Tx) SetLogger(logger *slog.Logger)
- func (tx *Tx) TableScan(tbl *Table, opt ScanOptions) *RawTableCursor
- func (tx *Tx) TableStats(tbl *Table) TableStats
- func (tx *Tx) TryGet(tbl *Table, key any) (any, ValueMeta, error)
- func (tx *Tx) TryGetByKeyVal(tbl *Table, keyVal reflect.Value) (any, ValueMeta, error)
- func (tx *Tx) UnsafeDeleteByKeyRawSkippingIndex(tbl *Table, keyRaw []byte) bool
- type Txish
- type ValueMeta
Constants ¶
const ( DumpTableHeaders = DumpFlags(1 << iota) DumpRows DumpStats DumpIndices DumpIndexRows DumpAll = DumpFlags(0xFFFFFFFFFFFFFFFF) )
const ( MsgPack encodingMethod = iota JSON )
const ( ScanMethodFull = ScanMethod(iota) ScanMethodExact ScanMethodRange ScanMethodExactIndexWithIDRange )
const (
SuppressContentWhenLogging = tableOpt(1)
)
Variables ¶
var ( ReaderCount atomic.Int64 WriterCount atomic.Int64 )
var Break = errors.New("break")
Functions ¶
func AllLimited ¶ added in v0.1.6
func AllRawKeys ¶
func AllTableRows ¶
func AllUntypedKeys ¶
func GetByKeyRaw ¶ added in v0.1.6
Types ¶
type ChangeFlags ¶ added in v0.2.0
type ChangeFlags uint64
const ( ChangeFlagNotify ChangeFlags = 1 << iota ChangeFlagIncludeKey ChangeFlagIncludeRow ChangeFlagIncludeOldRow ChangeFlagIncludeMutableRow )
func (ChangeFlags) Contains ¶ added in v0.2.0
func (v ChangeFlags) Contains(f ChangeFlags) bool
func (ChangeFlags) ContainsAny ¶ added in v0.2.0
func (v ChangeFlags) ContainsAny(f ChangeFlags) bool
type Cursor ¶
func ExactIndexScan ¶
func ExactTableScan ¶ added in v0.1.6
func FullReverseTableScan ¶ added in v0.1.4
func FullTableScan ¶ added in v0.1.1
func PrefixIndexScan ¶
func RangeIndexScan ¶ added in v0.1.6
func RangeTableScan ¶ added in v0.1.6
func ReverseExactIndexScan ¶ added in v0.1.5
func ReversePrefixIndexScan ¶ added in v0.1.5
func ReverseRangeIndexScan ¶ added in v0.1.6
func ReverseRangeTableScan ¶ added in v0.1.6
type DB ¶
type DB struct { ReaderCount atomic.Int64 WriterCount atomic.Int64 PendingWriterCount atomic.Int64 ReadCount atomic.Uint64 WriteCount atomic.Uint64 // contains filtered or unexported fields }
func (*DB) BeginUpdate ¶
func (*DB) Close ¶
func (db *DB) Close()
Close is safe to call multiple times, but not concurrently.
func (*DB) DescribeOpenTxns ¶ added in v0.1.6
func (*DB) Tx ¶
Tx currently implements Check-Mutate phases for writable transactions:
Phase 1, Check: before any modifications are made. Runs inside bdb.Batch. Returning an error won't cause the entire batch to fail.
Phase 2, Mutate: from the first mutation. Runs inside bdb.Batch. The entire transaction will be retried in case of error.
TODO: split Mutate phase into Mutate and Post-Mutate phases:
Phase 1, Check (initial phase): inside bdb.Batch, error does not fail batch.
Phase 2, Mutate (initiated by any mutation call): inside bdb.Batch, error fails batch.
Phase 3, Read (initiated by explicit call like Commit): mutations committed, outside bdb.Batch, a new read-only tx is opened on demand.
Check-Mutate-Read would allow to avoid holding the batch during rendering.
A read-only transaction would be a natural extension of Check-Mutate-Read with Check and Mutate phases skipped.
type FlatMarshaler ¶
type FlatMarshallable ¶
type FlatMarshallable interface { FlatMarshaler FlatUnmarshaler }
type FlatUnmarshaler ¶
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
func (*Index) DecodeIndexKeyVal ¶ added in v0.1.6
func (*Index) DecodeIndexKeyValInto ¶ added in v0.2.0
func (*Index) ParseNakedIndexKey ¶ added in v0.2.2
func (*Index) ParseNakedIndexKeyVal ¶ added in v0.2.2
type IndexBuilder ¶
type IndexBuilder struct {
// contains filtered or unexported fields
}
type KVCursor ¶ added in v0.3.1
type KVCursor struct {
// contains filtered or unexported fields
}
func (*KVCursor) Object ¶ added in v0.3.1
func (c *KVCursor) Object() kvo.ImmutableMap
func (*KVCursor) Objects ¶ added in v0.3.1
func (c *KVCursor) Objects() func(yield func(k []byte, o kvo.ImmutableMap) bool)
func (*KVCursor) RawIndexKey ¶ added in v0.3.2
type KVIndexContentBuilder ¶ added in v0.3.2
type KVIndexContentBuilder struct {
// contains filtered or unexported fields
}
func (*KVIndexContentBuilder) Add ¶ added in v0.3.2
func (b *KVIndexContentBuilder) Add(ik []byte)
type KVIndexKey ¶ added in v0.3.2
type KVIndexKey interface { Clone() KVIndexKey PutBytes(raw []byte) bool String() string FillPrimaryKey(pk KVKey) }
type KVIndexKeyToPrimaryKey ¶ added in v0.3.2
type KVIndexer ¶ added in v0.3.2
type KVIndexer = func(b *KVIndexContentBuilder, pk []byte, v kvo.ImmutableRecord)
type KVTable ¶ added in v0.3.0
type KVTable struct { TaggableImpl // contains filtered or unexported fields }
func DefineKVTable ¶ added in v0.3.0
func DefineRawTable ¶ added in v0.3.3
func DefineRawTable(scm *Schema, name string, build func(b *KVTableBuilder)) *KVTable
func (*KVTable) KeyBytesToString ¶ added in v0.3.2
type KVTableBuilder ¶ added in v0.3.0
type KVTableBuilder struct {
// contains filtered or unexported fields
}
func (*KVTableBuilder) DefineIndex ¶ added in v0.3.2
func (b *KVTableBuilder) DefineIndex(name string, keySample KVIndexKey, resolver KVIndexKeyToPrimaryKey, indexer KVIndexer) *KVIndex
func (*KVTableBuilder) Tag ¶ added in v0.3.8
func (b *KVTableBuilder) Tag(tag *Tag)
type RawIndexCursor ¶
type RawIndexCursor struct {
// contains filtered or unexported fields
}
func (*RawIndexCursor) IndexKey ¶ added in v0.1.6
func (c *RawIndexCursor) IndexKey() any
func (*RawIndexCursor) Key ¶
func (c *RawIndexCursor) Key() any
func (*RawIndexCursor) Meta ¶
func (c *RawIndexCursor) Meta() ValueMeta
func (*RawIndexCursor) Next ¶
func (c *RawIndexCursor) Next() bool
func (*RawIndexCursor) RawKey ¶
func (c *RawIndexCursor) RawKey() []byte
func (*RawIndexCursor) RawRow ¶ added in v0.2.0
func (c *RawIndexCursor) RawRow() []byte
func (*RawIndexCursor) Row ¶
func (c *RawIndexCursor) Row() (any, ValueMeta)
func (*RawIndexCursor) Table ¶
func (c *RawIndexCursor) Table() *Table
func (*RawIndexCursor) TryRow ¶ added in v0.2.1
func (c *RawIndexCursor) TryRow() (any, ValueMeta, error)
func (*RawIndexCursor) TryRowVal ¶ added in v0.2.1
func (c *RawIndexCursor) TryRowVal() (reflect.Value, ValueMeta, error)
func (*RawIndexCursor) Tx ¶
func (c *RawIndexCursor) Tx() *Tx
type RawRange ¶ added in v0.3.1
type RawRange struct { Prefix []byte Lower []byte Upper []byte LowerInc bool UpperInc bool Reverse bool }
RawRange defines a range of byte strings. The constructors use mnemonics: O means open, I means inclusive, E means exclusive; the first letter is for the lower bound, the second for the upper bound.
type RawRangeCursor ¶ added in v0.3.1
type RawRangeCursor struct {
// contains filtered or unexported fields
}
func (*RawRangeCursor) Key ¶ added in v0.3.1
func (c *RawRangeCursor) Key() []byte
func (*RawRangeCursor) Next ¶ added in v0.3.1
func (c *RawRangeCursor) Next() bool
func (*RawRangeCursor) Value ¶ added in v0.3.1
func (c *RawRangeCursor) Value() []byte
type RawTableCursor ¶
type RawTableCursor struct {
// contains filtered or unexported fields
}
func (*RawTableCursor) Key ¶
func (c *RawTableCursor) Key() any
func (*RawTableCursor) Meta ¶
func (c *RawTableCursor) Meta() ValueMeta
func (*RawTableCursor) Next ¶
func (c *RawTableCursor) Next() bool
func (*RawTableCursor) RawKey ¶
func (c *RawTableCursor) RawKey() []byte
func (*RawTableCursor) RawRow ¶ added in v0.2.0
func (c *RawTableCursor) RawRow() []byte
func (*RawTableCursor) Row ¶
func (c *RawTableCursor) Row() (any, ValueMeta)
func (*RawTableCursor) Table ¶
func (c *RawTableCursor) Table() *Table
func (*RawTableCursor) TryRow ¶ added in v0.2.1
func (c *RawTableCursor) TryRow() (any, ValueMeta, error)
func (*RawTableCursor) TryRowVal ¶ added in v0.2.1
func (c *RawTableCursor) TryRowVal() (reflect.Value, ValueMeta, error)
func (*RawTableCursor) Tx ¶
func (c *RawTableCursor) Tx() *Tx
type ScanMethod ¶
type ScanMethod int
type ScanOptions ¶
type ScanOptions struct { Reverse bool Method ScanMethod Lower reflect.Value Upper reflect.Value LowerInc bool UpperInc bool Els int Extra reflect.Value }
func ExactIDRangeScan ¶ added in v0.3.1
func ExactIDRangeScan(exact, lower, upper any, lowerInc, upperInc bool) ScanOptions
func ExactIDRangeScanVal ¶ added in v0.3.1
func ExactIDRangeScanVal(exact, lower, upper reflect.Value, lowerInc, upperInc bool) ScanOptions
func ExactScan ¶
func ExactScan(v any) ScanOptions
func ExactScanVal ¶
func ExactScanVal(val reflect.Value) ScanOptions
func FullScan ¶
func FullScan() ScanOptions
func LowerBoundScan ¶ added in v0.2.0
func LowerBoundScan(lower any, includeEqual bool) ScanOptions
func RangeScan ¶ added in v0.1.6
func RangeScan(lower, upper any, lowerInc, upperInc bool) ScanOptions
func RangeScanVal ¶ added in v0.1.6
func RangeScanVal(lower, upper reflect.Value, lowerInc, upperInc bool) ScanOptions
func UpperBoundScan ¶ added in v0.2.0
func UpperBoundScan(upper any, includeEqual bool) ScanOptions
func (ScanOptions) LogString ¶ added in v0.1.2
func (so ScanOptions) LogString() string
func (ScanOptions) Prefix ¶
func (so ScanOptions) Prefix(els int) ScanOptions
func (ScanOptions) Reversed ¶
func (so ScanOptions) Reversed() ScanOptions
type Schema ¶
type Schema struct { Name string // contains filtered or unexported fields }
func (*Schema) KVTableNamed ¶ added in v0.3.2
func (*Schema) TableByRow ¶ added in v0.1.2
func (*Schema) TableByRowType ¶ added in v0.1.2
func (*Schema) TableNamed ¶
type Table ¶
type Table struct { TaggableImpl // contains filtered or unexported fields }
func DefineTable ¶ added in v0.2.0
func DefineTable[Row, Key any](scm *Schema, name string, f func(b *TableBuilder[Row, Key])) *Table
func (*Table) DecodeKeyValInto ¶ added in v0.2.0
func (*Table) EncodeKeyVal ¶ added in v0.1.6
func (*Table) IndexNamed ¶ added in v0.1.6
func (*Table) RawKeyString ¶
func (*Table) RowHasZeroKey ¶ added in v0.1.2
func (*Table) RowValHasZeroKey ¶ added in v0.1.2
func (*Table) SetRowKeyVal ¶
type TableBuilder ¶ added in v0.2.0
type TableBuilder[Row, Key any] struct { // contains filtered or unexported fields }
func (*TableBuilder[Row, Key]) AddIndex ¶ added in v0.2.0
func (b *TableBuilder[Row, Key]) AddIndex(idx *Index)
func (*TableBuilder[Row, Key]) Indexer ¶ added in v0.2.0
func (b *TableBuilder[Row, Key]) Indexer(f func(row *Row, ib *IndexBuilder))
func (*TableBuilder[Row, Key]) Migrate ¶ added in v0.2.0
func (b *TableBuilder[Row, Key]) Migrate(f func(tx *Tx, row *Row, oldVer uint64))
func (*TableBuilder[Row, Key]) SetSchemaVersion ¶ added in v0.2.0
func (b *TableBuilder[Row, Key]) SetSchemaVersion(ver uint64)
func (*TableBuilder[Row, Key]) SuppressContentWhenLogging ¶ added in v0.2.0
func (b *TableBuilder[Row, Key]) SuppressContentWhenLogging()
func (*TableBuilder[Row, Key]) Tag ¶ added in v0.3.8
func (b *TableBuilder[Row, Key]) Tag(tag *Tag)
type TableError ¶
func (*TableError) Error ¶
func (e *TableError) Error() string
func (*TableError) Unwrap ¶
func (e *TableError) Unwrap() error
type TableStats ¶
type TableStats struct { Rows int64 IndexRows int64 DataSize int64 DataAlloc int64 IndexSize int64 IndexAlloc int64 }
func (*TableStats) TotalAlloc ¶
func (ts *TableStats) TotalAlloc() int64
func (*TableStats) TotalSize ¶
func (ts *TableStats) TotalSize() int64
type TagFamily ¶ added in v0.3.8
type TagFamily struct {
// contains filtered or unexported fields
}
func NewTagFamily ¶ added in v0.3.8
func NewTagFamily(name string, tags []*Tag, defaultTag *Tag, card TagFamilyCardinality) *TagFamily
type TagFamilyCardinality ¶ added in v0.3.8
type TagFamilyCardinality int
const ( TagFamilyCardinalityOptionalOne TagFamilyCardinality = iota TagFamilyCardinalityRequiredOne TagFamilyCardinalityOptionalMany TagFamilyCardinalityRequiredMany )
type TaggableImpl ¶ added in v0.3.8
type TaggableImpl struct {
// contains filtered or unexported fields
}
func (*TaggableImpl) HasTag ¶ added in v0.3.8
func (i *TaggableImpl) HasTag(tag *Tag) bool
func (*TaggableImpl) TagInFamily ¶ added in v0.3.8
func (i *TaggableImpl) TagInFamily(fam *TagFamily) *Tag
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
func (*Tx) BeginVerbose ¶ added in v0.2.0
func (tx *Tx) BeginVerbose()
func (*Tx) CommitDespiteError ¶
func (tx *Tx) CommitDespiteError()
func (*Tx) EndVerbose ¶ added in v0.2.0
func (tx *Tx) EndVerbose()
func (*Tx) ExistsByKeyRaw ¶ added in v0.1.6
func (*Tx) GetByKeyRaw ¶ added in v0.1.6
func (*Tx) GetByKeyVal ¶
func (*Tx) GetMetaByKeyVal ¶
func (*Tx) IndexScan ¶
func (tx *Tx) IndexScan(idx *Index, opt ScanOptions) *RawIndexCursor
func (*Tx) IsWritable ¶
func (*Tx) KVIndexScan ¶ added in v0.3.2
func (*Tx) KVTableScan ¶ added in v0.3.1
func (*Tx) KVTableStats ¶ added in v0.3.7
func (tx *Tx) KVTableStats(tbl *KVTable) TableStats
func (*Tx) LookupExists ¶ added in v0.2.0
func (*Tx) LookupKeyVal ¶
func (*Tx) OnChange ¶ added in v0.1.4
func (tx *Tx) OnChange(opts map[*Table]ChangeFlags, f func(tx *Tx, chg *Change))
func (*Tx) TableScan ¶
func (tx *Tx) TableScan(tbl *Table, opt ScanOptions) *RawTableCursor
func (*Tx) TableStats ¶
func (tx *Tx) TableStats(tbl *Table) TableStats
func (*Tx) TryGetByKeyVal ¶ added in v0.2.1
type ValueMeta ¶
func (ValueMeta) IsModified ¶ added in v0.2.3
Source Files ¶
- byteutil.go
- change.go
- db.go
- debug.go
- doc.go
- encflat.go
- encindexkeys.go
- encoding.go
- enctuple.go
- encvalue.go
- errors.go
- index.go
- monitoring.go
- opdelete.go
- opget.go
- opimpl.go
- opimpldecode.go
- opkv.go
- oplookup.go
- opmaint.go
- opput.go
- ops.go
- opscan.go
- pools.go
- reflect.go
- scan.go
- schema.go
- schemabuilder.go
- schemaindex.go
- schemakvindex.go
- schemakvo.go
- schemastate.go
- schematable.go
- tags.go
- tx.go
- util.go
Directories ¶
Path | Synopsis |
---|---|
Package journal implements WAL-like append-only journals.
|
Package journal implements WAL-like append-only journals. |
Package kvo (stands for Key Value Objects) manages trees of objects mainly represented as key-value pairs.
|
Package kvo (stands for Key Value Objects) manages trees of objects mainly represented as key-value pairs. |