Documentation ¶
Overview ¶
Copyright (c) 2018-2022 Blockwatch Data Inc. Author: alex@blockwatch.cc
Copyright (c) 2018-2020 Blockwatch Data Inc. Author: alex@blockwatch.cc
Index ¶
- Constants
- Variables
- func DisableLog()
- func SortBatch(idx int, rval reflect.Value, pks []uint64)
- func UseLogger(logger logpkg.Logger)
- type BatchSorter
- type BinaryCondition
- type BlockInfo
- type BlockInfoList
- type Buffer
- type CSVHeader
- type Condition
- func (c *Condition) Compile() (err error)
- func (c Condition) MatchPack(pkg *Package, mask *vec.Bitset) *vec.Bitset
- func (c Condition) MatchValue(val *Value) bool
- func (c Condition) MaybeMatchPack(info PackInfo) bool
- func (c Condition) NValues() int
- func (c Condition) PkRange() (uint64, uint64)
- func (c Condition) String() string
- type ConditionTreeNode
- func (n *ConditionTreeNode) AddAndCondition(c *Condition)
- func (n *ConditionTreeNode) AddNode(node ConditionTreeNode)
- func (n *ConditionTreeNode) AddOrCondition(c *Condition)
- func (n *ConditionTreeNode) Compile() error
- func (n ConditionTreeNode) Conditions() []*Condition
- func (n ConditionTreeNode) Cost(info PackInfo) int
- func (n ConditionTreeNode) Depth() int
- func (n ConditionTreeNode) Dump() string
- func (n ConditionTreeNode) Empty() bool
- func (n ConditionTreeNode) Fields() FieldList
- func (n ConditionTreeNode) IsNested() bool
- func (n ConditionTreeNode) IsProcessed() bool
- func (n ConditionTreeNode) Leaf() bool
- func (n ConditionTreeNode) MatchPack(pkg *Package, info PackInfo) *vec.Bitset
- func (n ConditionTreeNode) MatchPackAnd(pkg *Package, info PackInfo) *vec.Bitset
- func (n ConditionTreeNode) MatchPackOr(pkg *Package, info PackInfo) *vec.Bitset
- func (n ConditionTreeNode) MatchValue(v *Value) bool
- func (n ConditionTreeNode) MaybeMatchPack(info PackInfo) bool
- func (n ConditionTreeNode) NoMatch() bool
- func (n ConditionTreeNode) PkRange() (uint64, uint64)
- func (n ConditionTreeNode) Size() int
- func (n ConditionTreeNode) Weight() int
- type DB
- func (d *DB) Close() error
- func (d *DB) CloseStore(s Store) error
- func (d *DB) CloseTable(t Table) error
- func (d *DB) CreateStore(name string, opts Options) (Store, error)
- func (d *DB) CreateStoreIfNotExists(name string, opts Options) (Store, error)
- func (d *DB) CreateTable(engine TableEngine, name string, fields FieldList, opts Options) (Table, error)
- func (d *DB) CreateTableIfNotExists(engine TableEngine, name string, fields FieldList, opts Options) (Table, error)
- func (d *DB) Dir() string
- func (d *DB) DropStore(name string) error
- func (d *DB) DropTable(name string) error
- func (d *DB) Dump(w io.Writer) error
- func (d *DB) Engine() string
- func (d *DB) GC(ctx context.Context, ratio float64) error
- func (d *DB) IsClosed() bool
- func (d *DB) IsReadOnly() bool
- func (d *DB) IsUsed() bool
- func (d *DB) ListIndexNames(table string) ([]string, error)
- func (d *DB) ListStoreNames() ([]string, error)
- func (d *DB) ListTableNames() ([]string, error)
- func (d *DB) Manifest() (store.Manifest, error)
- func (d *DB) NumOpenStores() int
- func (d *DB) NumOpenTables() int
- func (d *DB) OpenStore(name string, opts Options) (Store, error)
- func (d *DB) OpenStores() []Store
- func (d *DB) OpenTable(engine TableEngine, name string, opts Options) (Table, error)
- func (d *DB) OpenTables() []Table
- func (d *DB) Path() string
- func (d *DB) Tx(writeable bool) (*Tx, error)
- func (d *DB) Update(fn func(*Tx) error) error
- func (d *DB) UpdateManifest(name, label string) error
- func (d *DB) View(fn func(*Tx) error) error
- type DumpMode
- type Field
- func (f Field) DecodeValue(buf *bytes.Buffer, dst reflect.Value, finfo *fieldInfo) (err error)
- func (f Field) Encode(val any) ([]byte, error)
- func (f Field) EncodeValue(buf *bytes.Buffer, val reflect.Value, finfo *fieldInfo) (err error)
- func (f Field) Equal(f2 Field) bool
- func (f Field) IsPk() bool
- func (f Field) IsValid() bool
- func (f Field) NewBlock(sz int) *block.Block
- func (f Field) SkipValue(buf *bytes.Buffer) (err error)
- type FieldFlags
- type FieldList
- func (l FieldList) Add(field *Field) FieldList
- func (l FieldList) AddUnique(fields ...*Field) FieldList
- func (l FieldList) Aliases() []string
- func (l FieldList) Clone() FieldList
- func (l FieldList) CompositePk() FieldList
- func (l FieldList) Contains(name string) bool
- func (l FieldList) CopyData(pos []int, val []byte) []byte
- func (l FieldList) Decode(buf []byte, val any) error
- func (l FieldList) DecodeWithInfo(buf []byte, val any, tinfo *typeInfo) error
- func (l FieldList) Encode(val any) ([]byte, error)
- func (l FieldList) EncodeValue(buf *bytes.Buffer, val reflect.Value, tinfo *typeInfo) error
- func (l FieldList) Find(name string) *Field
- func (l FieldList) HasCompositePk() bool
- func (l FieldList) HasPk() bool
- func (l FieldList) Hash() uint64
- func (l FieldList) Indexed() FieldList
- func (l FieldList) Mask(m FieldList) []byte
- func (l FieldList) MaskString(m FieldList) string
- func (l FieldList) MergeUnique(fields ...*Field) FieldList
- func (l FieldList) NameMap() map[string]string
- func (l FieldList) NameMapReverse() map[string]string
- func (l FieldList) Names() []string
- func (l FieldList) Pk() *Field
- func (l FieldList) PkIndex() int
- func (l FieldList) Select(names ...string) FieldList
- func (l FieldList) SelectChecked(names ...string) (FieldList, error)
- func (l FieldList) Sort() FieldList
- func (l FieldList) String() string
- type FieldType
- func (t FieldType) Between(val, from, to interface{}) bool
- func (t FieldType) BetweenBlock(b *block.Block, from, to interface{}, bits, mask *Bitset) *Bitset
- func (t FieldType) BlockType() block.BlockType
- func (t FieldType) BuildBloomFilter(b *block.Block, cardinality uint32, factor int) *bloom.Filter
- func (t FieldType) CastSliceType(val interface{}, f *Field) (interface{}, error)
- func (t FieldType) CastType(val interface{}, f *Field) (interface{}, error)
- func (t FieldType) CheckSliceType(val interface{}) error
- func (t FieldType) CheckType(val interface{}) error
- func (t FieldType) Compare(xa, xb interface{}) int
- func (t FieldType) CopySliceType(val interface{}) (interface{}, error)
- func (t FieldType) Equal(xa, xb interface{}) bool
- func (t FieldType) EqualBlock(b *block.Block, val interface{}, bits, mask *Bitset) *Bitset
- func (t FieldType) EqualPacksAt(p1 *Package, i1, n1 int, p2 *Package, i2, n2 int) bool
- func (t FieldType) EstimateCardinality(b *block.Block, precision uint) uint32
- func (t FieldType) Gt(xa, xb interface{}) bool
- func (t FieldType) GtBlock(b *block.Block, val interface{}, bits, mask *Bitset) *Bitset
- func (t FieldType) Gte(xa, xb interface{}) bool
- func (t FieldType) GteBlock(b *block.Block, val interface{}, bits, mask *Bitset) *Bitset
- func (t FieldType) Hash(val interface{}) [2]uint32
- func (t FieldType) In(v, in interface{}) bool
- func (t FieldType) InBetween(slice, from, to interface{}) bool
- func (t FieldType) IsValid() bool
- func (t FieldType) Len() int
- func (t FieldType) Lt(xa, xb interface{}) bool
- func (t FieldType) LtBlock(b *block.Block, val interface{}, bits, mask *Bitset) *Bitset
- func (t FieldType) Lte(xa, xb interface{}) bool
- func (t FieldType) LteBlock(b *block.Block, val interface{}, bits, mask *Bitset) *Bitset
- func (r FieldType) MarshalText() ([]byte, error)
- func (t FieldType) NotEqualBlock(b *block.Block, val interface{}, bits, mask *Bitset) *Bitset
- func (t FieldType) ParseAs(s string, f *Field) (interface{}, error)
- func (t FieldType) ParseSliceAs(s string, f *Field) (interface{}, error)
- func (t FieldType) Regexp(v interface{}, re string) bool
- func (t FieldType) RegexpBlock(b *block.Block, re string, bits, mask *Bitset) *Bitset
- func (t FieldType) SliceToString(val interface{}, f *Field) string
- func (t FieldType) String() string
- func (t *FieldType) UnmarshalText(data []byte) error
- type FilterMode
- type ForwardIterator
- type GenericStore
- func (s *GenericStore) Close() error
- func (s *GenericStore) DB() *DB
- func (s *GenericStore) Del(key []byte) error
- func (s *GenericStore) Del64(key uint64) error
- func (s *GenericStore) DelTx(tx *Tx, key []byte) ([]byte, error)
- func (s *GenericStore) DeleteValue64(key uint64) error
- func (s *GenericStore) Drop() error
- func (s *GenericStore) Engine() string
- func (s *GenericStore) Get(key []byte) ([]byte, error)
- func (s *GenericStore) Get64(key uint64) ([]byte, error)
- func (s *GenericStore) GetTx(tx *Tx, key []byte) []byte
- func (s *GenericStore) GetValue64(key uint64, val any) error
- func (s *GenericStore) IsClosed() bool
- func (s *GenericStore) Name() string
- func (s *GenericStore) Options() Options
- func (s *GenericStore) PrefixRange(prefix []byte, fn func(k, v []byte) error) error
- func (s *GenericStore) PurgeCache()
- func (s *GenericStore) Put(key, val []byte) error
- func (s *GenericStore) Put64(key uint64, val []byte) error
- func (s *GenericStore) PutTx(tx *Tx, key, val []byte) ([]byte, error)
- func (s *GenericStore) PutValue64(key uint64, val any) error
- func (s *GenericStore) Range(from, to []byte, fn func(k, v []byte) error) error
- func (s *GenericStore) Stats() []TableStats
- type Index
- type IndexData
- type IndexKind
- func (t IndexKind) MarshalText() ([]byte, error)
- func (t IndexKind) MayHaveCollisions() bool
- func (t IndexKind) String() string
- func (t *IndexKind) UnmarshalText(d []byte) error
- func (t IndexKind) ValueAtFunc() IndexValueAtFunc
- func (t IndexKind) ValueFunc() IndexValueFunc
- func (t IndexKind) ZeroAtFunc() IndexZeroAtFunc
- type IndexList
- type IndexValueAtFunc
- type IndexValueFunc
- type IndexZeroAtFunc
- type Join
- func (j Join) AppendResult(out, left *Package, l int, right *Package, r int) error
- func (j Join) CheckConditions() error
- func (j Join) CheckInputs() error
- func (j *Join) Compile() error
- func (j Join) Dump() string
- func (j Join) Fields() FieldList
- func (j Join) IsEquiJoin() bool
- func (j Join) Query(ctx context.Context, q Query) (*Result, error)
- func (j Join) Stream(ctx context.Context, q Query, fn func(r Row) error) error
- type JoinTable
- type JoinType
- type Journal
- func (j *Journal) Close()
- func (j *Journal) DataPack() *Package
- func (j *Journal) Delete(pk uint64) (int, error)
- func (j *Journal) DeleteBatch(pks []uint64) (int, error)
- func (j *Journal) HeapSize() int
- func (j *Journal) InitFields(fields FieldList) error
- func (j *Journal) InitType(typ interface{}) error
- func (j *Journal) Insert(val any) error
- func (j *Journal) InsertBatch(batch reflect.Value) (int, error)
- func (j *Journal) InsertPack(pkg *Package, pos, n int) (int, error)
- func (j *Journal) IsDeleted(pk uint64, last int) (bool, int)
- func (j *Journal) IsSorted() bool
- func (j *Journal) LastId() uint64
- func (j *Journal) Len() int
- func (j *Journal) LoadLegacy(tx *Tx, bucketName []byte) error
- func (j *Journal) MaxId() uint64
- func (j *Journal) Open(path string) error
- func (j *Journal) PkIndex(pk uint64, last int) (int, int)
- func (j *Journal) Reset()
- func (j *Journal) ShouldFlush() bool
- func (j *Journal) SortedIndexes(b *vec.Bitset) ([]int, []uint64)
- func (j *Journal) SortedIndexesReversed(b *vec.Bitset) ([]int, []uint64)
- func (j *Journal) StoreLegacy(tx *Tx, bucketName []byte) (int, int, error)
- func (j *Journal) TombLen() int
- func (j *Journal) Update(val any) error
- func (j *Journal) UpdateBatch(batch reflect.Value) (int, error)
- type KeyValueIndex
- func (idx *KeyValueIndex) AddTx(tx *Tx, prev, val []byte) error
- func (idx *KeyValueIndex) DelTx(tx *Tx, prev []byte) error
- func (idx *KeyValueIndex) Drop() error
- func (idx *KeyValueIndex) Fields() FieldList
- func (idx *KeyValueIndex) Key() []byte
- func (idx KeyValueIndex) Kind() IndexKind
- func (idx KeyValueIndex) MarshalJSON() ([]byte, error)
- func (idx KeyValueIndex) Name() string
- func (idx *KeyValueIndex) RangeTx(tx *Tx, from, to []byte) (bitmap.Bitmap, error)
- func (idx *KeyValueIndex) Scan(prefix []byte) (bitmap.Bitmap, error)
- func (idx *KeyValueIndex) ScanTx(tx *Tx, prefix []byte) (bitmap.Bitmap, error)
- func (idx *KeyValueIndex) UnmarshalJSON(buf []byte) error
- type KeyValueMarshaler
- type KeyValueTable
- func (t *KeyValueTable) Close() error
- func (t *KeyValueTable) Compact(_ context.Context) error
- func (t *KeyValueTable) Count(ctx context.Context, q Query) (int64, error)
- func (t *KeyValueTable) CreateIndex(kind IndexKind, fields FieldList, opts Options) error
- func (t *KeyValueTable) CreateIndexIfNotExists(kind IndexKind, fields FieldList, opts Options) error
- func (t *KeyValueTable) DB() *DB
- func (t *KeyValueTable) Del(key []byte) error
- func (t *KeyValueTable) Del64(key uint64) error
- func (t *KeyValueTable) DelTx(tx *Tx, key []byte) ([]byte, error)
- func (t *KeyValueTable) Delete(ctx context.Context, q Query) (int64, error)
- func (t *KeyValueTable) DeletePks(ctx context.Context, pks []uint64) (int64, error)
- func (t *KeyValueTable) DeleteValue(val any) error
- func (t *KeyValueTable) Drop() error
- func (t *KeyValueTable) DropIndex(fields FieldList) error
- func (_ *KeyValueTable) Engine() TableEngine
- func (t *KeyValueTable) Fields() FieldList
- func (t *KeyValueTable) Get(key []byte) ([]byte, error)
- func (t *KeyValueTable) Get64(key uint64) ([]byte, error)
- func (t *KeyValueTable) GetTx(tx *Tx, key []byte) []byte
- func (t *KeyValueTable) Insert(_ context.Context, val any) error
- func (t *KeyValueTable) IsClosed() bool
- func (t *KeyValueTable) LookupPks(ctx context.Context, pks []uint64) (*Result, error)
- func (t *KeyValueTable) Name() string
- func (t *KeyValueTable) NextSequence() uint64
- func (t *KeyValueTable) Options() Options
- func (_ *KeyValueTable) PurgeCache()
- func (t *KeyValueTable) Put(key, val []byte) error
- func (t *KeyValueTable) Put64(key uint64, val []byte) error
- func (t *KeyValueTable) PutTx(tx *Tx, key, val []byte) ([]byte, error)
- func (t *KeyValueTable) PutValue(val any) error
- func (t *KeyValueTable) Query(ctx context.Context, q Query) (*Result, error)
- func (t *KeyValueTable) QueryIndexesTx(ctx context.Context, tx *Tx, node *ConditionTreeNode) (int, error)
- func (t *KeyValueTable) RebuildIndex(idx *KeyValueIndex) error
- func (t *KeyValueTable) Sequence() uint64
- func (t *KeyValueTable) Stats() []TableStats
- func (t *KeyValueTable) Stream(ctx context.Context, q Query, fn func(Row) error) error
- func (t *KeyValueTable) StreamPks(ctx context.Context, pks []uint64, fn func(r Row) error) error
- func (t *KeyValueTable) Sync(_ context.Context) error
- func (t *KeyValueTable) Update(ctx context.Context, val any) error
- type KeyValueUnmarshaler
- type LookupIterator
- type Options
- type OrderType
- type PackHeader
- func (l *PackHeader) AddOrUpdate(head PackInfo)
- func (l *PackHeader) Best(val uint64) (pos int, packmin uint64, packmax uint64, nextmin uint64, isFull bool)
- func (l *PackHeader) Clear()
- func (l *PackHeader) Count() int
- func (l *PackHeader) Get(i int) PackInfo
- func (l *PackHeader) GetByKey(key uint32) PackInfo
- func (l *PackHeader) GetSorted(i int) PackInfo
- func (l *PackHeader) GlobalMinMax() (uint64, uint64)
- func (l *PackHeader) HeapSize() int
- func (l *PackHeader) IsFull(i int) bool
- func (l *PackHeader) Len() int
- func (l *PackHeader) MinMax(n int) (uint64, uint64)
- func (l *PackHeader) MinMaxSlices() ([]uint64, []uint64)
- func (l *PackHeader) Next(last int) (pos int, packmin uint64, packmax uint64, nextmin uint64, isFull bool)
- func (l PackHeader) NextKey() uint32
- func (l *PackHeader) Remove(key uint32)
- func (l *PackHeader) Sort()
- func (l *PackHeader) TableSize() int
- func (l PackHeader) Validate() []error
- type PackIndex
- func (idx *PackIndex) AddTx(tx *Tx, pkg *Package, srcPos, srcLen int) error
- func (idx *PackIndex) CanMatch(cond Condition) bool
- func (idx *PackIndex) CloseTx(tx *Tx) error
- func (idx *PackIndex) Drop() error
- func (idx *PackIndex) Field() *Field
- func (idx *PackIndex) FlushTx(ctx context.Context, tx *Tx) error
- func (idx *PackIndex) Kind() IndexKind
- func (idx *PackIndex) LookupTx(ctx context.Context, tx *Tx, cond Condition) ([]uint64, error)
- func (idx *PackIndex) Name() string
- func (idx *PackIndex) Options() Options
- func (idx *PackIndex) PurgeCache()
- func (idx *PackIndex) Reindex(ctx context.Context, flushEvery int, ch chan<- float64) error
- func (idx *PackIndex) ReindexTx(ctx context.Context, tx *Tx, flushEvery int, ch chan<- float64) error
- func (idx *PackIndex) RemoveTx(tx *Tx, pkg *Package, srcPos, srcLen int) error
- func (idx *PackIndex) Stats() TableStats
- type PackIndexEntry
- type PackIndexList
- type PackInfo
- func (h *PackInfo) Decode(buf *bytes.Buffer) error
- func (h PackInfo) Dump(w io.Writer, mode DumpMode, nfields int) error
- func (i PackInfo) DumpDetail(w io.Writer) error
- func (h PackInfo) Encode(buf *bytes.Buffer) error
- func (h PackInfo) HeapSize() int
- func (p PackInfo) IsValid() bool
- func (p PackInfo) KeyBytes() []byte
- func (h PackInfo) MarshalBinary() ([]byte, error)
- func (h *PackInfo) UnmarshalBinary(data []byte) error
- func (h *PackInfo) UpdateStats(pkg *Package) error
- type PackInfoList
- func (l *PackInfoList) Add(info PackInfo) (PackInfo, int, bool)
- func (l PackInfoList) Len() int
- func (l PackInfoList) Less(i, j int) bool
- func (h PackInfoList) MarshalBinary() ([]byte, error)
- func (l *PackInfoList) Remove(head PackInfo) (PackInfo, int)
- func (l *PackInfoList) RemoveKey(key uint32) (PackInfo, int)
- func (l PackInfoList) Swap(i, j int)
- func (h *PackInfoList) UnmarshalBinary(data []byte) error
- type PackTable
- func (t *PackTable) Close() error
- func (t *PackTable) Compact(ctx context.Context) error
- func (t *PackTable) Count(ctx context.Context, q Query) (int64, error)
- func (t *PackTable) CountTx(ctx context.Context, tx *Tx, q Query) (int64, error)
- func (t *PackTable) CreateIndex(kind IndexKind, fields FieldList, opts Options) error
- func (t *PackTable) CreateIndexIfNotExists(kind IndexKind, fields FieldList, opts Options) error
- func (t *PackTable) DB() *DB
- func (t *PackTable) Delete(ctx context.Context, q Query) (int64, error)
- func (t *PackTable) DeletePks(ctx context.Context, val []uint64) (int64, error)
- func (t *PackTable) DeletePksTx(ctx context.Context, tx *Tx, val []uint64) (int64, error)
- func (t *PackTable) Drop() error
- func (t *PackTable) DropIndex(fields FieldList) error
- func (t *PackTable) DumpIndexPack(w io.Writer, i, p int, mode DumpMode) error
- func (t *PackTable) DumpIndexPackInfo(w io.Writer, idx int, mode DumpMode, sorted bool) error
- func (t *PackTable) DumpJournal(w io.Writer, mode DumpMode) error
- func (t *PackTable) DumpPack(w io.Writer, i int, mode DumpMode) error
- func (t *PackTable) DumpPackBlocks(w io.Writer, mode DumpMode) error
- func (t *PackTable) DumpPackInfo(w io.Writer, mode DumpMode, sorted bool) error
- func (t *PackTable) DumpPackInfoDetail(w io.Writer, mode DumpMode, sorted bool) error
- func (t *PackTable) DumpType(w io.Writer) error
- func (t *PackTable) Engine() TableEngine
- func (t *PackTable) Fields() FieldList
- func (t *PackTable) Flush(ctx context.Context) error
- func (t *PackTable) FlushJournal(ctx context.Context) error
- func (t *PackTable) Indexes() PackIndexList
- func (t *PackTable) Insert(ctx context.Context, val any) error
- func (t *PackTable) InsertResult(ctx context.Context, res *Result) error
- func (t *PackTable) InsertRow(ctx context.Context, row Row) error
- func (t *PackTable) InsertTx(ctx context.Context, tx *Tx, val any) error
- func (t *PackTable) IsClosed() bool
- func (t *PackTable) Lock()
- func (t *PackTable) LookupPks(ctx context.Context, ids []uint64) (*Result, error)
- func (t *PackTable) LookupPksTx(ctx context.Context, tx *Tx, ids []uint64) (*Result, error)
- func (t *PackTable) Name() string
- func (t *PackTable) NextSequence() uint64
- func (t *PackTable) Options() Options
- func (t *PackTable) PurgeCache()
- func (t *PackTable) Query(ctx context.Context, q Query) (*Result, error)
- func (t *PackTable) QueryIndexesTx(ctx context.Context, tx *Tx, node *ConditionTreeNode) (int, error)
- func (t *PackTable) QueryTx(ctx context.Context, tx *Tx, q Query) (*Result, error)
- func (t *PackTable) QueryTxDesc(ctx context.Context, tx *Tx, q Query) (*Result, error)
- func (t *PackTable) Sequence() uint64
- func (t *PackTable) Stats() []TableStats
- func (t *PackTable) Stream(ctx context.Context, q Query, fn func(r Row) error) error
- func (t *PackTable) StreamPks(ctx context.Context, ids []uint64, fn func(r Row) error) error
- func (t *PackTable) StreamPksTx(ctx context.Context, tx *Tx, ids []uint64, fn func(r Row) error) error
- func (t *PackTable) StreamTx(ctx context.Context, tx *Tx, q Query, fn func(r Row) error) error
- func (t *PackTable) StreamTxDesc(ctx context.Context, tx *Tx, q Query, fn func(r Row) error) error
- func (t *PackTable) Sync(ctx context.Context) error
- func (t *PackTable) Unlock()
- func (t *PackTable) Update(ctx context.Context, val any) error
- func (t *PackTable) UpdateTx(ctx context.Context, tx *Tx, val any) error
- func (t *PackTable) ValidateIndexPackHeader(w io.Writer) error
- func (t *PackTable) ValidatePackHeader(w io.Writer) error
- func (t *PackTable) WalkPacks(fn func(*Package) error) error
- func (t *PackTable) WalkPacksRange(start, end int, fn func(*Package) error) error
- type Package
- func (p *Package) AppendFrom(srcPack *Package, srcPos, srcLen int) error
- func (p *Package) Block(index int) (*block.Block, error)
- func (p *Package) Blocks() []*block.Block
- func (p *Package) BoolAt(index, pos int) (bool, error)
- func (p *Package) BytesAt(index, pos int) ([]byte, error)
- func (p *Package) CanGrow(n int) bool
- func (p *Package) Cap() int
- func (p *Package) Clear()
- func (p *Package) Clone(capacity int) (*Package, error)
- func (p *Package) Cols() int
- func (p *Package) Column(index int) (interface{}, error)
- func (p *Package) Contains(fields FieldList) bool
- func (p *Package) DecRef() int64
- func (p *Package) Decimal128At(index, pos int) (Decimal128, error)
- func (p *Package) Decimal256At(index, pos int) (Decimal256, error)
- func (p *Package) Decimal32At(index, pos int) (Decimal32, error)
- func (p *Package) Decimal64At(index, pos int) (Decimal64, error)
- func (p *Package) Delete(pos, n int) error
- func (p *Package) DumpBlocks(w io.Writer, mode DumpMode, lineNo int) (int, error)
- func (p *Package) DumpData(w io.Writer, mode DumpMode, aliases []string) error
- func (p *Package) DumpType(w io.Writer) error
- func (p *Package) FieldAt(index, pos int) (interface{}, error)
- func (p *Package) FieldById(idx int) *Field
- func (p *Package) FieldByName(name string) *Field
- func (p *Package) FieldIndex(name string) int
- func (p *Package) Fields() FieldList
- func (p *Package) Float32At(index, pos int) (float32, error)
- func (p *Package) Float64At(index, pos int) (float64, error)
- func (p *Package) Grow(n int) error
- func (p *Package) HeapSize() int
- func (p *Package) IncRef() int64
- func (p *Package) Info() PackInfo
- func (p *Package) InitFields(fields FieldList, tinfo *typeInfo) error
- func (p *Package) InitFieldsEmpty(fields FieldList, tinfo *typeInfo) error
- func (p *Package) InitFieldsFrom(src *Package) error
- func (p *Package) InitFieldsFromEmpty(src *Package) error
- func (p *Package) InitResultFields(fields FieldList, tinfo *typeInfo) error
- func (p *Package) InitType(proto interface{}) error
- func (p *Package) InsertFrom(srcPack *Package, dstPos, srcPos, srcLen int) error
- func (p *Package) Int128At(index, pos int) (vec.Int128, error)
- func (p *Package) Int16At(index, pos int) (int16, error)
- func (p *Package) Int256At(index, pos int) (vec.Int256, error)
- func (p *Package) Int32At(index, pos int) (int32, error)
- func (p *Package) Int64At(index, pos int) (int64, error)
- func (p *Package) Int8At(index, pos int) (int8, error)
- func (p *Package) IsDirty() bool
- func (p *Package) IsFull() bool
- func (p Package) IsJournal() bool
- func (p Package) IsResult() bool
- func (p Package) IsTomb() bool
- func (p *Package) IsZeroAt(index, pos int, zeroIsNull bool) bool
- func (p *Package) Key() []byte
- func (p *Package) Len() int
- func (p *Package) MarshalBinary() ([]byte, error)
- func (p *Package) Materialize()
- func (dst *Package) Merge(src *Package) error
- func (p *Package) Optimize()
- func (p *Package) PkColumn() []uint64
- func (p *Package) PkField() *Field
- func (p *Package) PkIndex(id uint64, last int) (int, int)
- func (p *Package) PkIndexUnsorted(id uint64, last int) int
- func (p *Package) PkSort() error
- func (p *Package) PopulateFields(fields FieldList) *Package
- func (p *Package) Push(v interface{}) error
- func (p *Package) RangeAt(index, start, end int) (interface{}, error)
- func (p *Package) ReadAtWithInfo(pos int, v interface{}, tinfo *typeInfo) error
- func (p *Package) Release()
- func (p *Package) ReplaceAt(pos int, v interface{}) error
- func (p *Package) ReplaceFrom(srcPack *Package, dstPos, srcPos, srcLen int) error
- func (p *Package) ResetType()
- func (p *Package) RowAt(pos int) ([]interface{}, error)
- func (p *Package) SetFieldAt(index, pos int, v interface{}) error
- func (p *Package) SetKey(key []byte)
- func (p *Package) StringAt(index, pos int) (string, error)
- func (p *Package) TimeAt(index, pos int) (time.Time, error)
- func (p *Package) Uint16At(index, pos int) (uint16, error)
- func (p *Package) Uint32At(index, pos int) (uint32, error)
- func (p *Package) Uint64At(index, pos int) (uint64, error)
- func (p *Package) Uint8At(index, pos int) (uint8, error)
- func (p *Package) UnmarshalBinary(data []byte) error
- func (p *Package) UpdateAliasesFrom(fields FieldList) *Package
- func (p *Package) Validate() error
- func (p *Package) WithCap(c int) *Package
- func (p *Package) WithKey(k uint32) *Package
- type PackageSorter
- type Query
- func (q Query) And(field string, mode FilterMode, value any) Query
- func (q Query) AndCondition(conds ...UnboundCondition) Query
- func (q Query) AndEqual(field string, value any) Query
- func (q Query) AndGt(field string, value any) Query
- func (q Query) AndGte(field string, value any) Query
- func (q Query) AndIn(field string, value any) Query
- func (q Query) AndLt(field string, value any) Query
- func (q Query) AndLte(field string, value any) Query
- func (q Query) AndNotEqual(field string, value any) Query
- func (q Query) AndNotIn(field string, value any) Query
- func (q Query) AndRange(field string, from, to any) Query
- func (q Query) AndRegexp(field string, value any) Query
- func (q *Query) Close()
- func (q *Query) Compile() error
- func (q Query) Count(ctx context.Context) (int64, error)
- func (q Query) Delete(ctx context.Context) (int64, error)
- func (q Query) Dump() string
- func (q Query) Execute(ctx context.Context, val any) error
- func (q Query) IsBound() bool
- func (q Query) IsEmptyMatch() bool
- func (q Query) Or(field string, mode FilterMode, value any) Query
- func (q Query) OrCondition(conds ...UnboundCondition) Query
- func (q Query) PrintTiming() string
- func (q *Query) QueryIndexes(ctx context.Context, tx *Tx) error
- func (q Query) Run(ctx context.Context) (*Result, error)
- func (q Query) Runtime() time.Duration
- func (q Query) Stream(ctx context.Context, fn func(r Row) error) error
- func (q Query) Table() Table
- func (q *Query) Tick() time.Duration
- func (q *Query) TickNow() (time.Duration, time.Time)
- func (q Query) WithAsc() Query
- func (q Query) WithCache(enable bool) Query
- func (q Query) WithColumns(names ...string) Query
- func (q Query) WithDebug() Query
- func (q Query) WithDesc() Query
- func (q Query) WithFields(names ...string) Query
- func (q Query) WithIndex(enable bool) Query
- func (q Query) WithLimit(l int) Query
- func (q Query) WithOffset(o int) Query
- func (q Query) WithOrder(o OrderType) Query
- func (q Query) WithStats() Query
- func (q Query) WithStatsAfter(d time.Duration) Query
- func (q Query) WithTable(table Table) Query
- func (q Query) WithoutCache() Query
- func (q Query) WithoutIndex() Query
- func (q Query) WithoutStats() Query
- type QueryStats
- type Result
- func (r *Result) Close()
- func (r *Result) Cols() int
- func (r *Result) Column(colname string) (interface{}, error)
- func (r *Result) Decode(val interface{}) error
- func (r *Result) DecodeAt(n int, val interface{}) error
- func (r *Result) DecodeRange(start, end int, proto interface{}) (interface{}, error)
- func (r Result) Dump() string
- func (r *Result) Fields() FieldList
- func (r *Result) ForEach(proto interface{}, fn func(i int, val interface{}) error) error
- func (r *Result) IsValid() bool
- func (r *Result) PkColumn() []uint64
- func (r *Result) Record(n int) []byte
- func (r *Result) Row(n int) Row
- func (r *Result) Rows() int
- func (r *Result) SortByField(name string) error
- func (r *Result) Walk(fn func(r Row) error) error
- type ReverseIterator
- type Row
- func (r Row) Bool(index int) (bool, error)
- func (r Row) Bytes(index int) ([]byte, error)
- func (r Row) Decimal128(index int) (decimal.Decimal128, error)
- func (r Row) Decimal256(index int) (decimal.Decimal256, error)
- func (r Row) Decimal32(index int) (decimal.Decimal32, error)
- func (r Row) Decimal64(index int) (decimal.Decimal64, error)
- func (r Row) Decode(val interface{}) error
- func (r Row) Field(name string) (interface{}, error)
- func (r Row) Float32(index int) (float32, error)
- func (r Row) Float64(index int) (float64, error)
- func (r Row) Index(i int) (interface{}, error)
- func (r Row) Int128(index int) (vec.Int128, error)
- func (r Row) Int16(index int) (int16, error)
- func (r Row) Int256(index int) (vec.Int256, error)
- func (r Row) Int32(index int) (int32, error)
- func (r Row) Int64(index int) (int64, error)
- func (r Row) Int8(index int) (int8, error)
- func (r Row) N() int
- func (r Row) Result() *Result
- func (r Row) String(index int) (string, error)
- func (r Row) Time(index int) (time.Time, error)
- func (r Row) Uint16(index int) (uint16, error)
- func (r Row) Uint32(index int) (uint32, error)
- func (r Row) Uint64(index int) (uint64, error)
- func (r Row) Uint8(index int) (uint8, error)
- type Store
- type Table
- type TableEngine
- type TableMeta
- type TableStats
- type Tombstone
- type Tx
- type UnboundCondition
- func And(conds ...UnboundCondition) UnboundCondition
- func Equal(col string, val interface{}) UnboundCondition
- func Gt(col string, value interface{}) UnboundCondition
- func Gte(col string, value interface{}) UnboundCondition
- func In(col string, value interface{}) UnboundCondition
- func Lt(col string, value interface{}) UnboundCondition
- func Lte(col string, value interface{}) UnboundCondition
- func NotEqual(col string, val interface{}) UnboundCondition
- func NotIn(col string, value interface{}) UnboundCondition
- func Or(conds ...UnboundCondition) UnboundCondition
- func ParseCondition(key, val string, fields FieldList) (UnboundCondition, error)
- func Range(col string, from, to interface{}) UnboundCondition
- func Regexp(col string, value interface{}) UnboundCondition
- func (u *UnboundCondition) Add(c UnboundCondition)
- func (u *UnboundCondition) And(col string, mode FilterMode, value interface{})
- func (u *UnboundCondition) AndRange(col string, from, to interface{})
- func (u UnboundCondition) Bind(fields FieldList) ConditionTreeNode
- func (u *UnboundCondition) Clear()
- func (n UnboundCondition) Dump() string
- func (u UnboundCondition) Empty() bool
- func (u UnboundCondition) Leaf() bool
- func (u *UnboundCondition) Or(col string, mode FilterMode, value interface{})
- func (u *UnboundCondition) OrRange(col string, from, to interface{})
- func (u UnboundCondition) Rename(name string) UnboundCondition
- func (u UnboundCondition) String() string
- type Value
- type Wal
- func (w *Wal) Close()
- func (w *Wal) IsOpen() bool
- func (w *Wal) Reset() error
- func (w *Wal) Sync() error
- func (w *Wal) Write(rec WalRecordType, pk uint64, val any) error
- func (w *Wal) WriteMulti(rec WalRecordType, pks []uint64, vals any) error
- func (w *Wal) WritePack(rec WalRecordType, pkg *Package, pos, n int) error
- type WalRecordType
Constants ¶
const ( COND_OR = true COND_AND = false )
const ( TableEnginePack = "pack" TableEngineKV = "kv" )
Variables ¶
var ( ErrNoEngine = errors.New("pack: engine does not exist") ErrNoTable = errors.New("pack: table does not exist") ErrNoStore = errors.New("pack: store does not exist") ErrNoIndex = errors.New("pack: index does not exist") ErrNoColumn = errors.New("pack: column does not exist") ErrTypeMismatch = errors.New("pack: type mismatch") ErrNoPk = errors.New("pack: primary key not defined") ErrNoField = errors.New("pack: field does not exist") ErrInvalidType = errors.New("pack: unsupported block type") ErrNilValue = errors.New("pack: nil value passed") ErrDatabaseReadOnly = errors.New("pack: database is read-only") ErrDatabaseClosed = errors.New("pack: database is closed") ErrIndexNotFound = errors.New("pack: index not found") ErrBucketNotFound = errors.New("pack: bucket not found") ErrPackNotFound = errors.New("pack: pack not found") ErrPackStripped = errors.New("pack: pack is stripped") ErrIdNotFound = errors.New("pack: id not found") ErrKeyNotFound = errors.New("pack: key not found") ErrTableExists = errors.New("pack: table already exists") ErrStoreExists = errors.New("pack: store already exists") ErrIndexExists = errors.New("pack: index already exists") ErrResultClosed = errors.New("pack: result already closed") EndStream = errors.New("end stream") )
var ( ZERO = []byte{} FF = []byte{0xff} )
var ( DefaultOptions = Options{ PackSizeLog2: defaultPackSizeLog2, JournalSizeLog2: 17, CacheSize: defaultCacheSize, FillLevel: 90, } NoOptions = Options{} )
var QueryLogMinDuration time.Duration = 500 * time.Millisecond
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.
Types ¶
type BatchSorter ¶
type BatchSorter struct {
// contains filtered or unexported fields
}
func NewBatchSorter ¶
func NewBatchSorter(val reflect.Value, pks []uint64) BatchSorter
func (BatchSorter) Len ¶
func (s BatchSorter) Len() int
func (BatchSorter) Less ¶
func (s BatchSorter) Less(i, j int) bool
func (BatchSorter) Sort ¶
func (s BatchSorter) Sort() bool
func (BatchSorter) Swap ¶
func (s BatchSorter) Swap(i, j int)
type BinaryCondition ¶
type BinaryCondition struct { Left *Field Right *Field Mode FilterMode }
func NewPredicate ¶
func NewPredicate(left, right string, mode FilterMode) BinaryCondition
func (*BinaryCondition) Bind ¶
func (b *BinaryCondition) Bind(l, r Table)
func (BinaryCondition) Check ¶
func (b BinaryCondition) Check() error
func (BinaryCondition) ComparePacksAt ¶
func (BinaryCondition) MatchPacksAt ¶
type BlockInfo ¶
type BlockInfo struct { Type block.BlockType Compression block.Compression Scale int // statistics MinValue interface{} // vector min MaxValue interface{} // vector max Bloom *bloom.Filter // optimized bloom filter Cardinality uint32 // unique items in vector // contains filtered or unexported fields }
func (BlockInfo) EncodedSize ¶
type BlockInfoList ¶
type BlockInfoList []BlockInfo
type Condition ¶
type Condition struct { Field *Field // evaluated table field Mode FilterMode // eq|ne|gt|gte|lt|lte|in|nin|re Raw string // string value when parsed from a query string Value interface{} // typed value From interface{} // typed value for range queries To interface{} // typed value for range queries IsSorted bool // IN/NIN condition slice is already pre-sorted // contains filtered or unexported fields }
func (Condition) MatchPack ¶
MatchPack matches all elements in package pkg against the defined condition and returns a bitset of the same length as the package with bits set to true where the match is successful.
This implementation uses low level block vectors to efficiently execute vectorized checks with custom assembly-optimized routines.
func (Condition) MatchValue ¶
func (Condition) MaybeMatchPack ¶
match package min/max values against the condition Note: min/max are raw storage values (i.e. for decimals, they are scaled integers)
type ConditionTreeNode ¶
type ConditionTreeNode struct { OrKind bool // AND|OR Children []ConditionTreeNode // sub conditions Cond *Condition // ptr to condition Bits bitmap.Bitmap // index query result }
func (*ConditionTreeNode) AddAndCondition ¶
func (n *ConditionTreeNode) AddAndCondition(c *Condition)
func (*ConditionTreeNode) AddNode ¶
func (n *ConditionTreeNode) AddNode(node ConditionTreeNode)
Invariants - root is always an AND node - root is never a leaf node - root may be empty
func (*ConditionTreeNode) AddOrCondition ¶
func (n *ConditionTreeNode) AddOrCondition(c *Condition)
func (*ConditionTreeNode) Compile ¶
func (n *ConditionTreeNode) Compile() error
may otimize (merge/replace) conditions in the future
func (ConditionTreeNode) Conditions ¶
func (n ConditionTreeNode) Conditions() []*Condition
func (ConditionTreeNode) Cost ¶
func (n ConditionTreeNode) Cost(info PackInfo) int
returns the subtree execution cost based on the number of rows that may be visited in the given pack for a full scan times the number of comparisons
func (ConditionTreeNode) Depth ¶
func (n ConditionTreeNode) Depth() int
Depth returns the max number of tree levels
func (ConditionTreeNode) Dump ¶
func (n ConditionTreeNode) Dump() string
func (ConditionTreeNode) Empty ¶
func (n ConditionTreeNode) Empty() bool
func (ConditionTreeNode) Fields ¶
func (n ConditionTreeNode) Fields() FieldList
returns unique list of fields
func (ConditionTreeNode) IsNested ¶
func (n ConditionTreeNode) IsNested() bool
func (ConditionTreeNode) IsProcessed ¶
func (n ConditionTreeNode) IsProcessed() bool
func (ConditionTreeNode) Leaf ¶
func (n ConditionTreeNode) Leaf() bool
func (ConditionTreeNode) MatchPack ¶
func (n ConditionTreeNode) MatchPack(pkg *Package, info PackInfo) *vec.Bitset
func (ConditionTreeNode) MatchPackAnd ¶
func (n ConditionTreeNode) MatchPackAnd(pkg *Package, info PackInfo) *vec.Bitset
Return a bit vector containing matching positions in the pack combining multiple AND conditions with efficient skipping and aggregation. TODO: consider concurrent matches for multiple conditions and cascading bitset merge
func (ConditionTreeNode) MatchPackOr ¶
func (n ConditionTreeNode) MatchPackOr(pkg *Package, info PackInfo) *vec.Bitset
Return a bit vector containing matching positions in the pack combining multiple OR conditions with efficient skipping and aggregation.
func (ConditionTreeNode) MatchValue ¶
func (n ConditionTreeNode) MatchValue(v *Value) bool
func (ConditionTreeNode) MaybeMatchPack ¶
func (n ConditionTreeNode) MaybeMatchPack(info PackInfo) bool
func (ConditionTreeNode) NoMatch ¶
func (n ConditionTreeNode) NoMatch() bool
func (ConditionTreeNode) PkRange ¶
func (n ConditionTreeNode) PkRange() (uint64, uint64)
func (ConditionTreeNode) Size ¶
func (n ConditionTreeNode) Size() int
Size returns the total number of condition leaf nodes
func (ConditionTreeNode) Weight ¶
func (n ConditionTreeNode) Weight() int
returns the decision tree size (including sub-conditions)
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) CloseStore ¶
func (*DB) CloseTable ¶
func (*DB) CreateStoreIfNotExists ¶
func (*DB) CreateTable ¶
func (*DB) CreateTableIfNotExists ¶
func (*DB) IsReadOnly ¶
func (*DB) ListStoreNames ¶
func (*DB) ListTableNames ¶
func (*DB) NumOpenStores ¶
func (*DB) NumOpenTables ¶
func (*DB) OpenStores ¶
func (*DB) OpenTables ¶
func (*DB) UpdateManifest ¶
type Field ¶
type Field struct { Index int `json:"index"` Name string `json:"name"` Alias string `json:"alias"` Type FieldType `json:"type"` Flags FieldFlags `json:"flags"` // primary, indexed, compression Scale int `json:"scale"` // 0..127 fixed point scale, bloom error probability 1/x IKind IndexKind `json:"ikind"` // index type: hash, integer }
func (Field) DecodeValue ¶
func (Field) EncodeValue ¶
use BigEndian to be able to reuse encoded data as searchable key
type FieldFlags ¶
type FieldFlags int
const ( FlagPrimary FieldFlags = 1 << iota FlagIndexed FlagCompressSnappy FlagCompressLZ4 FlagBloom )
func (FieldFlags) Compression ¶
func (f FieldFlags) Compression() block.Compression
func (FieldFlags) Contains ¶
func (f FieldFlags) Contains(i FieldFlags) bool
func (FieldFlags) String ¶
func (f FieldFlags) String() string
type FieldList ¶
type FieldList []*Field
func MakeSchema ¶
func (FieldList) CompositePk ¶
func (FieldList) CopyData ¶
TODO: refactor to use Value type assumes value contains all encoded data fields outputs byte and string with length prefixed
func (FieldList) DecodeWithInfo ¶
func (FieldList) EncodeValue ¶
func (FieldList) HasCompositePk ¶
func (FieldList) MaskString ¶
func (FieldList) MergeUnique ¶
func (FieldList) NameMapReverse ¶
long -> short name map
func (FieldList) SelectChecked ¶
type FieldType ¶
type FieldType byte
const ( FieldTypeUndefined FieldType = iota FieldTypeDatetime // BlockTime FieldTypeInt64 // BlockInt64 FieldTypeUint64 // BlockUint64 FieldTypeFloat64 // BlockFloat64 FieldTypeBoolean // BlockBool FieldTypeString // BlockString FieldTypeBytes // BlockBytes FieldTypeInt32 // BlockInt32 FieldTypeInt16 // BlockInt16 FieldTypeInt8 // BlockInt8 FieldTypeUint32 // BlockUint32 FieldTypeUint16 // BlockUint16 FieldTypeUint8 // BlockUint8 FieldTypeFloat32 // BlockFloat32 FieldTypeInt256 // BlockInt256 FieldTypeInt128 // BlockInt128 FieldTypeDecimal256 // BlockDecimal256 FieldTypeDecimal128 // BlockDecimal128 FieldTypeDecimal64 // BlockDecimal64 FieldTypeDecimal32 // BlockDecimal32 )
func ParseFieldType ¶
func (FieldType) BetweenBlock ¶
assumes from <= to
func (FieldType) BuildBloomFilter ¶
func (FieldType) CastSliceType ¶
func (FieldType) CheckSliceType ¶
func (FieldType) CopySliceType ¶
func (FieldType) Equal ¶
Used in BinaryCondition MatchPacksAt() for loop joins Used in Condition.MatchValue for KV table matches
func (FieldType) EqualBlock ¶
func (FieldType) EqualPacksAt ¶
Used by flushTx for checking whether a row update changes any indexed column and updates indexes when true.
func (FieldType) EstimateCardinality ¶
func (FieldType) InBetween ¶
using binary search to find if slice contains values in interval [from, to] Note: there's no *At func because this function works on slices already assumes from <= to
func (FieldType) MarshalText ¶
func (FieldType) NotEqualBlock ¶
func (FieldType) ParseSliceAs ¶
func (FieldType) RegexpBlock ¶
func (FieldType) SliceToString ¶
func (*FieldType) UnmarshalText ¶
type FilterMode ¶
type FilterMode int
const ( FilterModeInvalid FilterMode = iota FilterModeEqual FilterModeNotEqual FilterModeGt FilterModeGte FilterModeLt FilterModeLte FilterModeIn FilterModeNotIn FilterModeRange FilterModeRegexp )
func ParseFilterMode ¶
func ParseFilterMode(s string) FilterMode
func (FilterMode) IsScalar ¶
func (m FilterMode) IsScalar() bool
func (FilterMode) IsValid ¶
func (m FilterMode) IsValid() bool
func (FilterMode) Op ¶
func (m FilterMode) Op() string
func (FilterMode) String ¶
func (m FilterMode) String() string
type ForwardIterator ¶
type ForwardIterator struct {
// contains filtered or unexported fields
}
func NewForwardIterator ¶
func NewForwardIterator(q *Query) *ForwardIterator
func (*ForwardIterator) Close ¶
func (it *ForwardIterator) Close()
type GenericStore ¶
type GenericStore struct {
// contains filtered or unexported fields
}
func CreateGenericStore ¶
func CreateGenericStore(d *DB, name string, opts Options) (*GenericStore, error)
func OpenGenericStore ¶
func OpenGenericStore(d *DB, name string, opts Options) (*GenericStore, error)
func (*GenericStore) Close ¶
func (s *GenericStore) Close() error
func (*GenericStore) DB ¶
func (s *GenericStore) DB() *DB
func (*GenericStore) Del ¶
func (s *GenericStore) Del(key []byte) error
func (*GenericStore) Del64 ¶
func (s *GenericStore) Del64(key uint64) error
func (*GenericStore) DeleteValue64 ¶
func (s *GenericStore) DeleteValue64(key uint64) error
compat interface for bitset storage
func (*GenericStore) Drop ¶
func (s *GenericStore) Drop() error
func (*GenericStore) Engine ¶
func (s *GenericStore) Engine() string
func (*GenericStore) Get ¶
func (s *GenericStore) Get(key []byte) ([]byte, error)
low-level interface for direct KV storage access
func (*GenericStore) GetValue64 ¶
func (s *GenericStore) GetValue64(key uint64, val any) error
compat interface for bitset storage
func (*GenericStore) IsClosed ¶
func (s *GenericStore) IsClosed() bool
func (*GenericStore) Name ¶
func (s *GenericStore) Name() string
func (*GenericStore) Options ¶
func (s *GenericStore) Options() Options
func (*GenericStore) PrefixRange ¶
func (s *GenericStore) PrefixRange(prefix []byte, fn func(k, v []byte) error) error
poor man's query interface where user generates key range and decodes key + value
func (*GenericStore) PurgeCache ¶
func (s *GenericStore) PurgeCache()
func (*GenericStore) Put ¶
func (s *GenericStore) Put(key, val []byte) error
func (*GenericStore) PutValue64 ¶
func (s *GenericStore) PutValue64(key uint64, val any) error
compat interface for bitset storage
func (*GenericStore) Range ¶
func (s *GenericStore) Range(from, to []byte, fn func(k, v []byte) error) error
func (*GenericStore) Stats ¶
func (s *GenericStore) Stats() []TableStats
type Index ¶
type Index interface { Name() string Kind() IndexKind Drop() error PurgeCache() Fields() FieldList Stats() TableStats AddTx(tx *Tx, prev, val []byte) error DelTx(tx *Tx, prev []byte) error ScanTx(tx *Tx, prefix []byte) (bitmap.Bitmap, error) RangeTx(tx *Tx, from, to []byte) (bitmap.Bitmap, error) CloseTx(*Tx) error }
type IndexKind ¶
type IndexKind int
func (IndexKind) MarshalText ¶
func (IndexKind) MayHaveCollisions ¶
func (*IndexKind) UnmarshalText ¶
func (IndexKind) ValueAtFunc ¶
func (t IndexKind) ValueAtFunc() IndexValueAtFunc
func (IndexKind) ValueFunc ¶
func (t IndexKind) ValueFunc() IndexValueFunc
func (IndexKind) ZeroAtFunc ¶
func (t IndexKind) ZeroAtFunc() IndexZeroAtFunc
type IndexValueAtFunc ¶
type IndexValueFunc ¶
type IndexZeroAtFunc ¶
type Join ¶
type Join struct { Type JoinType Predicate BinaryCondition Left JoinTable Right JoinTable // contains filtered or unexported fields }
func (Join) AppendResult ¶
func (Join) CheckConditions ¶
func (Join) CheckInputs ¶
func (Join) IsEquiJoin ¶
type JoinTable ¶
type JoinTable struct { Table Table Where UnboundCondition // optional filters for table rows Fields util.StringList // list of output fields, in order FieldsAs util.StringList // alias names of output fields, in order Limit int // individual table scan limit // contains filtered or unexported fields }
type JoinType ¶
type JoinType int
const ( InnerJoin JoinType = iota // INNER JOIN (maybe EQUI JOIN) LeftJoin // LEFT OUTER JOIN RightJoin // RIGHT OUTER JOIN FullJoin // FULL OUTER JOIN CrossJoin // CROSS JOIN SelfJoin // unused AsOfJoin // see https://code.kx.com/q4m3/9_Queries_q-sql/#998-as-of-joins WindowJoin // see https://code.kx.com/q4m3/9_Queries_q-sql/#999-window-join )
type Journal ¶
type Journal struct {
// contains filtered or unexported fields
}
Append-only journal and in-memory tombstone
- supports INSERT, UPSERT, UPDATE, DELETE - supports walking the journal by pk order (required for queries and flush) - journal pack data is only sorted by insert order, not necessarily pk order - primary key to position mapping is always sorted in pk order - tombstone is always sorted - re-inserting deleted entries is safe
To avoid sorting the journal after insert, but still process journal entries in pk sort order (in queries or flush and in both directions), we keep a mapping from pk to journal position in `keys` which is always sorted by pk.
How the journal is used ¶
Lookup: (non-order-preserving) matches against pk values only. For best performance we pre-sort the pk's we want to look up.
Query, Stream, Count: runs a full pack match on the journal's data pack. Note the resulting bitset is in storage order, not pk order!. Then a query walks all table packs and cross-check with tomb + journal to decide if/which rows to return to the caller. Ticks off journal matches from the match bitset as they are visted along the way. Finally, walks all tail entries that only exist in the journal but were never flushed to a table pack. Since the bitset is in storage order we must translate it into pk order for this step to work. This is what SortedIndexes() and SortedIndexesReversed() are for.
TODO - write all incoming inserts/updates/deletes to a WAL - load and reconstructed journal + tomb from WAL
func (*Journal) InitFields ¶
func (*Journal) InsertBatch ¶
Inserts multiple items, returns number of successfully processed items. Inserts with pk == 0 will generate a new pk > maxpk in sequential order. Inserts with an external pk (pk > 0) will insert or upsert and track the maximum pk seen.
func (*Journal) InsertPack ¶
Assumes no duplicates. pkg is not trusted to be sorted. It may come from a desc-ordered query result or from a result that has been sorted by a different field than the primary key. Primary key may exist (>0), but is generated when missing.
func (*Journal) IsDeleted ¶
Efficient check if a pk is in the tomb or not. Use `last` to skip already processed entries when walking through a sorted list of pks.
func (*Journal) PkIndex ¶
Returns the journal index at which pk is stored or -1 when pk is not found and the last index that matched. Using the last argument allows to skip searching a part of the journal for better efficiency in loops. This works only if subsequent calls can guarantee that queried primary keys are sorted, i.e. the next pk is larger than the previous pk.
var last, index int
for last < journal.Len() { index, last = journal.PkIndex(pk, last) }
Invariant: keys list is always sorted
func (*Journal) ShouldFlush ¶
func (*Journal) SortedIndexes ¶
On lookup/query we run matching algos on the journal pack which produce a bitset of all matches. The algo below takes this bitset and translates it into a pk sorted index list.
1. Cond.MatchPack() -> Bitset (1s at unsorted journal matches) 2. Bitset.Indexes() -> []int (positions in unsorted journal) 3. data.Column(pkid) -> []uint64 (lookup pks at indexes) 4. Joined sort index/pks by pk 5. Return pk-sorted index list
func (*Journal) SortedIndexesReversed ¶
func (*Journal) StoreLegacy ¶
type KeyValueIndex ¶
type KeyValueIndex struct {
// contains filtered or unexported fields
}
func CreateKeyValueIndex ¶
func OpenKeyValueIndex ¶
func (*KeyValueIndex) Drop ¶
func (idx *KeyValueIndex) Drop() error
func (*KeyValueIndex) Fields ¶
func (idx *KeyValueIndex) Fields() FieldList
func (*KeyValueIndex) Key ¶
func (idx *KeyValueIndex) Key() []byte
func (KeyValueIndex) Kind ¶
func (idx KeyValueIndex) Kind() IndexKind
func (KeyValueIndex) MarshalJSON ¶
func (idx KeyValueIndex) MarshalJSON() ([]byte, error)
func (KeyValueIndex) Name ¶
func (idx KeyValueIndex) Name() string
func (*KeyValueIndex) UnmarshalJSON ¶
func (idx *KeyValueIndex) UnmarshalJSON(buf []byte) error
type KeyValueMarshaler ¶
Marshaler interface, a more performant alternative to type based {Get|Put|Delete}Value methods, but incompatible with secondary indexes.
type KeyValueTable ¶
type KeyValueTable struct {
// contains filtered or unexported fields
}
func CreateKeyValueTable ¶
func OpenKeyValueTable ¶
func OpenKeyValueTable(d *DB, name string, opts Options) (*KeyValueTable, error)
func (*KeyValueTable) Close ¶
func (t *KeyValueTable) Close() error
func (*KeyValueTable) CreateIndex ¶
func (t *KeyValueTable) CreateIndex(kind IndexKind, fields FieldList, opts Options) error
func (*KeyValueTable) CreateIndexIfNotExists ¶
func (t *KeyValueTable) CreateIndexIfNotExists(kind IndexKind, fields FieldList, opts Options) error
func (*KeyValueTable) DB ¶
func (t *KeyValueTable) DB() *DB
func (*KeyValueTable) Del ¶
func (t *KeyValueTable) Del(key []byte) error
func (*KeyValueTable) Del64 ¶
func (t *KeyValueTable) Del64(key uint64) error
func (*KeyValueTable) DeleteValue ¶
func (t *KeyValueTable) DeleteValue(val any) error
func (*KeyValueTable) Drop ¶
func (t *KeyValueTable) Drop() error
func (*KeyValueTable) DropIndex ¶
func (t *KeyValueTable) DropIndex(fields FieldList) error
func (*KeyValueTable) Engine ¶
func (_ *KeyValueTable) Engine() TableEngine
func (*KeyValueTable) Fields ¶
func (t *KeyValueTable) Fields() FieldList
func (*KeyValueTable) Get ¶
func (t *KeyValueTable) Get(key []byte) ([]byte, error)
low-level interface for direct KV storage access
func (*KeyValueTable) Insert ¶
func (t *KeyValueTable) Insert(_ context.Context, val any) error
Table Compat interface
func (*KeyValueTable) IsClosed ¶
func (t *KeyValueTable) IsClosed() bool
func (*KeyValueTable) Name ¶
func (t *KeyValueTable) Name() string
func (*KeyValueTable) NextSequence ¶
func (t *KeyValueTable) NextSequence() uint64
func (*KeyValueTable) Options ¶
func (t *KeyValueTable) Options() Options
func (*KeyValueTable) PurgeCache ¶
func (_ *KeyValueTable) PurgeCache()
func (*KeyValueTable) Put ¶
func (t *KeyValueTable) Put(key, val []byte) error
func (*KeyValueTable) PutTx ¶
func (t *KeyValueTable) PutTx(tx *Tx, key, val []byte) ([]byte, error)
func (*KeyValueTable) PutValue ¶
func (t *KeyValueTable) PutValue(val any) error
func (*KeyValueTable) QueryIndexesTx ¶
func (t *KeyValueTable) QueryIndexesTx(ctx context.Context, tx *Tx, node *ConditionTreeNode) (int, error)
func (*KeyValueTable) RebuildIndex ¶
func (t *KeyValueTable) RebuildIndex(idx *KeyValueIndex) error
FIXME: this accesses private index fields, better to hide rebuild behind interface and stream table data
func (*KeyValueTable) Sequence ¶ added in v0.2.9
func (t *KeyValueTable) Sequence() uint64
func (*KeyValueTable) Stats ¶
func (t *KeyValueTable) Stats() []TableStats
type KeyValueUnmarshaler ¶
type LookupIterator ¶
type LookupIterator struct {
// contains filtered or unexported fields
}
func NewLookupIterator ¶
func NewLookupIterator(q *Query, pks []uint64) *LookupIterator
func (*LookupIterator) Close ¶
func (it *LookupIterator) Close()
type Options ¶
type Options struct { PackSizeLog2 int `json:"pack_size_log2,omitempty"` JournalSizeLog2 int `json:"journal_size_log2,omitempty"` CacheSize int `json:"cache_size,omitempty"` FillLevel int `json:"fill_level,omitempty"` }
func (Options) CacheSizeMBytes ¶
func (Options) JournalSize ¶
type OrderType ¶
type OrderType int
func ParseOrderType ¶
func (OrderType) MarshalText ¶
func (*OrderType) UnmarshalText ¶
type PackHeader ¶
type PackHeader struct {
// contains filtered or unexported fields
}
PackHeader implements efficient and scalable pack info/stats management as well as primary key placement (i.e. best pack selection) for tables and indexes.
Packs are stored and referenced in key order ([4]byte = big endian uint32), and primary keys have a global order across packs. This means pk min-max ranges are unordered, but never overlap.
PackHeader takes care of searching a pack that may contain a given pk and can select the best pack to store a new pk into. New or updated packs (i.e. from calls to split or storePack) are registered using their pack info. When empty packs are deleted (Table only) they must be deregistered.
PackHeader keeps a list of all current pack info/stats and a list of all removed keys in memory. Use storePackHeader to persist the pack index to storage.
func NewPackHeader ¶
func NewPackHeader(packs PackInfoList, pkidx, maxsize int) *PackHeader
may be used in {Index|Table}.loadPackHeaders
func (*PackHeader) AddOrUpdate ¶
func (l *PackHeader) AddOrUpdate(head PackInfo)
called by storePack
func (*PackHeader) Best ¶
func (l *PackHeader) Best(val uint64) (pos int, packmin uint64, packmax uint64, nextmin uint64, isFull bool)
Returns placement hint and pack info for the specified primary key.
Assumes pos list is sorted by min value and pack min/max ranges don't overlap this is the case for all index and table packs because placement and split algorithms ensure overlaps never exist.
func (*PackHeader) Clear ¶
func (l *PackHeader) Clear()
func (*PackHeader) Count ¶
func (l *PackHeader) Count() int
func (*PackHeader) Get ¶
func (l *PackHeader) Get(i int) PackInfo
func (*PackHeader) GetByKey ¶
func (l *PackHeader) GetByKey(key uint32) PackInfo
func (*PackHeader) GetSorted ¶
func (l *PackHeader) GetSorted(i int) PackInfo
func (*PackHeader) GlobalMinMax ¶
func (l *PackHeader) GlobalMinMax() (uint64, uint64)
func (*PackHeader) HeapSize ¶
func (l *PackHeader) HeapSize() int
func (*PackHeader) IsFull ¶
func (l *PackHeader) IsFull(i int) bool
func (*PackHeader) Len ¶
func (l *PackHeader) Len() int
func (*PackHeader) MinMaxSlices ¶
func (l *PackHeader) MinMaxSlices() ([]uint64, []uint64)
func (*PackHeader) Next ¶
func (l *PackHeader) Next(last int) (pos int, packmin uint64, packmax uint64, nextmin uint64, isFull bool)
Returns pack info for the logical follower pack (in min/max sort order).
func (PackHeader) NextKey ¶
func (l PackHeader) NextKey() uint32
func (*PackHeader) Remove ¶
func (l *PackHeader) Remove(key uint32)
called by storePack when packs are empty (Table only, index packs are never removed)
func (*PackHeader) Sort ¶
func (l *PackHeader) Sort()
func (*PackHeader) TableSize ¶
func (l *PackHeader) TableSize() int
func (PackHeader) Validate ¶
func (l PackHeader) Validate() []error
type PackIndex ¶
type PackIndex struct {
// contains filtered or unexported fields
}
func CreatePackIndex ¶
func OpenPackIndex ¶
func (*PackIndex) CanMatch ¶
This index only supports the following condition types on lookup. - FilterModeEqual - FilterModeIn - FilterModeNotIn
func (*PackIndex) FlushTx ¶
merge journal entries into data partitions, repack, store, and update indexes TODO: replace append+quicksort with reverse mergesort
func (*PackIndex) PurgeCache ¶
func (idx *PackIndex) PurgeCache()
func (*PackIndex) Stats ¶
func (idx *PackIndex) Stats() TableStats
type PackIndexEntry ¶
type PackIndexList ¶
type PackIndexList []*PackIndex
func (PackIndexList) Find ¶
func (l PackIndexList) Find(name string) *PackIndex
type PackInfo ¶
type PackInfo struct { Key uint32 NValues int Blocks BlockInfoList Packsize int // contains filtered or unexported fields }
func (PackInfo) MarshalBinary ¶
func (*PackInfo) UnmarshalBinary ¶
func (*PackInfo) UpdateStats ¶
type PackInfoList ¶
type PackInfoList []PackInfo
func (PackInfoList) Len ¶
func (l PackInfoList) Len() int
func (PackInfoList) Less ¶
func (l PackInfoList) Less(i, j int) bool
func (PackInfoList) MarshalBinary ¶
func (h PackInfoList) MarshalBinary() ([]byte, error)
func (PackInfoList) Swap ¶
func (l PackInfoList) Swap(i, j int)
func (*PackInfoList) UnmarshalBinary ¶
func (h *PackInfoList) UnmarshalBinary(data []byte) error
type PackTable ¶
type PackTable struct {
// contains filtered or unexported fields
}
func CreatePackTable ¶
func (*PackTable) Compact ¶
merges non-full packs to minimize total pack count, also re-establishes a sequential/gapless pack key order when packs have been deleted
func (*PackTable) CreateIndex ¶
func (*PackTable) CreateIndexIfNotExists ¶
func (*PackTable) DeletePksTx ¶
func (*PackTable) DumpIndexPack ¶
func (*PackTable) DumpIndexPackInfo ¶
func (*PackTable) DumpPackBlocks ¶
func (*PackTable) DumpPackInfo ¶
func (*PackTable) DumpPackInfoDetail ¶
func (*PackTable) Engine ¶
func (t *PackTable) Engine() TableEngine
func (*PackTable) Indexes ¶
func (t *PackTable) Indexes() PackIndexList
func (*PackTable) InsertResult ¶
func (*PackTable) InsertTx ¶
unsafe when used concurrently, need to obtain lock _before_ starting bolt tx
func (*PackTable) LookupPksTx ¶
unsafe when called concurrently! lock table _before_ starting bolt tx!
func (*PackTable) NextSequence ¶
func (*PackTable) PurgeCache ¶
func (t *PackTable) PurgeCache()
func (*PackTable) QueryIndexesTx ¶
func (*PackTable) QueryTxDesc ¶
DESCENDING pk order algorithm
func (*PackTable) Stats ¶
func (t *PackTable) Stats() []TableStats
func (*PackTable) StreamPksTx ¶
func (*PackTable) StreamTx ¶
Similar to QueryTx but returns each match via callback function to allow stream processing at low memory overheads.
func (*PackTable) StreamTxDesc ¶
DESCENDING order stream
func (*PackTable) ValidateIndexPackHeader ¶
type Package ¶
type Package struct {
// contains filtered or unexported fields
}
func (*Package) AppendFrom ¶
func (*Package) Block ¶
Block allows raw access to the underlying block for a field. Use this for implementing efficient matching algorithms that can work with optimized data vectors used at the block layer.
func (*Package) Clear ¶
func (p *Package) Clear()
Clear resets pack size to zero. Pack identity and type info is preserved. Non-nil blocks remain allocated.
func (*Package) Column ¶
Column returns a typed slice containing materialized values for the requested field index. This function has higher cost than direct block access because optimized representation of data vectors like timestamps, bitsets and decimals are unpacked into a temporary slice and type-cast.
func (*Package) Decimal128At ¶
func (*Package) Decimal256At ¶
func (*Package) Decimal32At ¶
func (*Package) Decimal64At ¶
func (*Package) DumpBlocks ¶
func (*Package) FieldByName ¶
func (*Package) FieldIndex ¶
func (*Package) InitFields ¶
Init from field list when Go type is unavailable
func (*Package) InitFieldsEmpty ¶
Init from field list when Go type is unavailable
func (*Package) InitFieldsFrom ¶
func (*Package) InitFieldsFromEmpty ¶
func (*Package) InitResultFields ¶
may be called from Join, no pk required
func (*Package) InsertFrom ¶
func (*Package) MarshalBinary ¶
func (*Package) Materialize ¶
func (p *Package) Materialize()
func (*Package) PkIndex ¶
Searches id in primary key column and return index or -1 when not found This function is only safe to use when packs are sorted!
func (*Package) PkIndexUnsorted ¶
Searches id in primary key column and return index or -1 when not found, use this function when pack is unsorted as when updates/inserts are out of order.
func (*Package) PopulateFields ¶
func (*Package) Push ¶
Push appends a new row to all columns. Requires a type that strictly defines all columns in this pack! Column mapping uses the default struct tag `knox`.
func (*Package) ReadAtWithInfo ¶
ReadAtWithInfo reads a row at offset pos and unmarshals values into an arbitrary type described by tinfo. This method has better performance than ReadAt when calls are very frequent, e.g. walking all rows in a pack. Will set struct fields based on name and alias as defined by struct tags `pack` and `json`.
func (*Package) ReplaceAt ¶
ReplaceAt replaces a row at offset pos across all columns. Requires a type that strictly defines all columns in this pack! Column mapping uses the default struct tag `pack`, hence the fields name only (not the fields alias).
func (*Package) ReplaceFrom ¶
ReplaceFrom replaces at most srcLen rows from the current package starting at offset dstPos with rows from package src starting at pos srcPos. Both packages must have same block order.
func (*Package) SetFieldAt ¶
func (*Package) UnmarshalBinary ¶
func (*Package) UpdateAliasesFrom ¶
clones field list and sets new aliase names
type PackageSorter ¶
type PackageSorter struct { *Package // contains filtered or unexported fields }
func NewPackageSorter ¶
func NewPackageSorter(p *Package, col int) (*PackageSorter, error)
func (*PackageSorter) Len ¶
func (s *PackageSorter) Len() int
func (*PackageSorter) Less ¶
func (s *PackageSorter) Less(i, j int) bool
func (*PackageSorter) Sort ¶
func (s *PackageSorter) Sort() bool
Sorts the package by defined column and returns if the package was changed, i.e. returns false if the package was sorted before
func (*PackageSorter) Swap ¶
func (s *PackageSorter) Swap(i, j int)
type Query ¶
type Query struct { Name string // optional, used for query stats Fields []string // SELECT ... Conditions UnboundCondition // WHERE ... AND / OR tree Order OrderType // ASC|DESC Limit int // LIMIT ... Offset int // OFFSET ... NoCache bool // explicitly disable pack caching for this query NoIndex bool // explicitly disable index query (use for many known duplicates) Debugf logpkg.LogfFn // contains filtered or unexported fields }
func (Query) AndCondition ¶
func (q Query) AndCondition(conds ...UnboundCondition) Query
func (Query) IsEmptyMatch ¶
func (Query) OrCondition ¶
func (q Query) OrCondition(conds ...UnboundCondition) Query
func (Query) PrintTiming ¶
func (*Query) QueryIndexes ¶
INDEX QUERY: use index lookup for indexed fields - fetch pk lists for every indexed field - when resolved, replace source condition with new FilterModeIn condition
func (Query) WithColumns ¶
func (Query) WithFields ¶
func (Query) WithOffset ¶
func (Query) WithoutCache ¶
func (Query) WithoutIndex ¶
func (Query) WithoutStats ¶
type QueryStats ¶
type QueryStats struct { CompileTime time.Duration `json:"compile_time"` AnalyzeTime time.Duration `json:"analyze_time"` JournalTime time.Duration `json:"journal_time"` IndexTime time.Duration `json:"index_time"` ScanTime time.Duration `json:"scan_time"` TotalTime time.Duration `json:"total_time"` PacksScheduled int `json:"packs_scheduled"` PacksScanned int `json:"packs_scanned"` RowsScanned int `json:"rows_scanned"` RowsMatched int `json:"rows_matched"` IndexLookups int `json:"index_lookups"` }
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
TODO: migrate to interface and implement PackResult + KeyValueResult
func (*Result) DecodeRange ¶
func (*Result) SortByField ¶
TODO: extend to value type results
type ReverseIterator ¶
type ReverseIterator struct {
// contains filtered or unexported fields
}
func NewReverseIterator ¶
func NewReverseIterator(q *Query) *ReverseIterator
func (*ReverseIterator) Close ¶
func (it *ReverseIterator) Close()
type Row ¶
type Row struct {
// contains filtered or unexported fields
}
func (Row) Decimal128 ¶
func (r Row) Decimal128(index int) (decimal.Decimal128, error)
func (Row) Decimal256 ¶
func (r Row) Decimal256(index int) (decimal.Decimal256, error)
type Store ¶
type Store interface { Name() string Engine() string DB() *DB Options() Options IsClosed() bool Stats() []TableStats PurgeCache() Close() error Drop() error Get(key []byte) ([]byte, error) GetTx(tx *Tx, key []byte) []byte Get64(key uint64) ([]byte, error) GetValue64(key uint64, val any) error Put(key, val []byte) error PutTx(tx *Tx, key, val []byte) ([]byte, error) Put64(key uint64, val []byte) error PutValue64(key uint64, val any) error Del(key []byte) error DelTx(tx *Tx, key []byte) ([]byte, error) Del64(key uint64) error DeleteValue64(key uint64) error PrefixRange(prefix []byte, fn func(k, v []byte) error) error Range(from, to []byte, fn func(k, v []byte) error) error }
type Table ¶
type Table interface { Name() string Engine() TableEngine DB() *DB Options() Options IsClosed() bool Fields() FieldList Stats() []TableStats PurgeCache() Close() error Drop() error Sync(context.Context) error Compact(context.Context) error Insert(context.Context, any) error Update(context.Context, any) error Query(context.Context, Query) (*Result, error) Stream(context.Context, Query, func(Row) error) error Count(context.Context, Query) (int64, error) Delete(context.Context, Query) (int64, error) LookupPks(context.Context, []uint64) (*Result, error) StreamPks(context.Context, []uint64, func(Row) error) error DeletePks(context.Context, []uint64) (int64, error) CreateIndex(IndexKind, FieldList, Options) error CreateIndexIfNotExists(IndexKind, FieldList, Options) error DropIndex(FieldList) error QueryIndexesTx(context.Context, *Tx, *ConditionTreeNode) (int, error) Sequence() uint64 NextSequence() uint64 }
type TableEngine ¶
type TableEngine string
type TableStats ¶
type TableStats struct { // global statistics TableName string `json:"table_name,omitempty"` IndexName string `json:"index_name,omitempty"` LastFlushTime int64 `json:"last_flush_time"` LastFlushDuration int64 `json:"last_flush_duration"` // tuple statistics TupleCount int64 `json:"tuples_count"` InsertedTuples int64 `json:"tuples_inserted"` UpdatedTuples int64 `json:"tuples_updated"` DeletedTuples int64 `json:"tuples_deleted"` FlushedTuples int64 `json:"tuples_flushed"` QueriedTuples int64 `json:"tuples_queried"` StreamedTuples int64 `json:"tuples_streamed"` // call statistics InsertCalls int64 `json:"calls_insert"` UpdateCalls int64 `json:"calls_update"` DeleteCalls int64 `json:"calls_delete"` FlushCalls int64 `json:"calls_flush"` QueryCalls int64 `json:"calls_query"` StreamCalls int64 `json:"calls_stream"` // metadata statistics MetaBytesRead int64 `json:"meta_bytes_read"` MetaBytesWritten int64 `json:"meta_bytes_written"` MetaSize int64 `json:"meta_size"` // journal statistics JournalSize int64 `json:"journal_size"` JournalDiskSize int64 `json:"journal_disk_size"` JournalTuplesCount int64 `json:"journal_tuples_count"` JournalTuplesThreshold int64 `json:"journal_tuples_threshold"` JournalTuplesCapacity int64 `json:"journal_tuples_capacity"` JournalPacksStored int64 `json:"journal_packs_stored"` JournalTuplesFlushed int64 `json:"journal_tuples_flushed"` JournalBytesWritten int64 `json:"journal_bytes_written"` // tombstone statistics TombstoneSize int64 `json:"tombstone_size"` TombstoneDiskSize int64 `json:"tombstone_disk_size"` TombstoneTuplesCount int64 `json:"tomb_tuples_count"` TombstoneTuplesThreshold int64 `json:"tomb_tuples_threshold"` TombstoneTuplesCapacity int64 `json:"tomb_tuples_capacity"` TombstonePacksStored int64 `json:"tomb_packs_stored"` TombstoneTuplesFlushed int64 `json:"tomb_tuples_flushed"` TombstoneBytesWritten int64 `json:"tomb_bytes_written"` // pack statistics PacksCount int64 `json:"packs_count"` PacksAlloc int64 `json:"packs_alloc"` PacksRecycled int64 `json:"packs_recycled"` PacksLoaded int64 `json:"packs_loaded"` PacksStored int64 `json:"packs_stored"` // I/O statistics BytesRead int64 `json:"bytes_read"` BytesWritten int64 `json:"bytes_written"` TotalSize int64 `json:"total_size"` // pack cache statistics CacheSize int64 `json:"cache_size"` CacheCount int64 `json:"cache_count"` CacheCapacity int64 `json:"cache_capacity"` CacheHits int64 `json:"cache_hits"` CacheMisses int64 `json:"cache_misses"` CacheInserts int64 `json:"cache_inserts"` CacheEvictions int64 `json:"cache_evictions"` }
func (*TableStats) Clone ¶
func (s *TableStats) Clone() (c TableStats)
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
func (*Tx) CommitAndContinue ¶
type UnboundCondition ¶
type UnboundCondition struct { Name string Mode FilterMode // eq|ne|gt|gte|lt|lte|in|nin|re Raw string // string value when parsed from a query string Value interface{} // typed value From interface{} // typed value for range queries To interface{} // typed value for range queries OrKind bool Children []UnboundCondition }
condition that is not bound to a table field yet
func And ¶
func And(conds ...UnboundCondition) UnboundCondition
func Equal ¶
func Equal(col string, val interface{}) UnboundCondition
func Gt ¶
func Gt(col string, value interface{}) UnboundCondition
func Gte ¶
func Gte(col string, value interface{}) UnboundCondition
func In ¶
func In(col string, value interface{}) UnboundCondition
func Lt ¶
func Lt(col string, value interface{}) UnboundCondition
func Lte ¶
func Lte(col string, value interface{}) UnboundCondition
func NotEqual ¶
func NotEqual(col string, val interface{}) UnboundCondition
func NotIn ¶
func NotIn(col string, value interface{}) UnboundCondition
func Or ¶
func Or(conds ...UnboundCondition) UnboundCondition
func ParseCondition ¶
func ParseCondition(key, val string, fields FieldList) (UnboundCondition, error)
parse conditions from query string col_name.{gt|gte|lt|lte|ne|in|nin|rg|re}=value
func Range ¶
func Range(col string, from, to interface{}) UnboundCondition
func Regexp ¶
func Regexp(col string, value interface{}) UnboundCondition
func (*UnboundCondition) Add ¶
func (u *UnboundCondition) Add(c UnboundCondition)
func (*UnboundCondition) And ¶
func (u *UnboundCondition) And(col string, mode FilterMode, value interface{})
func (*UnboundCondition) AndRange ¶
func (u *UnboundCondition) AndRange(col string, from, to interface{})
func (UnboundCondition) Bind ¶
func (u UnboundCondition) Bind(fields FieldList) ConditionTreeNode
func (*UnboundCondition) Clear ¶
func (u *UnboundCondition) Clear()
func (UnboundCondition) Dump ¶
func (n UnboundCondition) Dump() string
func (UnboundCondition) Empty ¶
func (u UnboundCondition) Empty() bool
func (UnboundCondition) Leaf ¶
func (u UnboundCondition) Leaf() bool
func (*UnboundCondition) Or ¶
func (u *UnboundCondition) Or(col string, mode FilterMode, value interface{})
func (*UnboundCondition) OrRange ¶
func (u *UnboundCondition) OrRange(col string, from, to interface{})
func (UnboundCondition) Rename ¶
func (u UnboundCondition) Rename(name string) UnboundCondition
func (UnboundCondition) String ¶
func (u UnboundCondition) String() string
type Wal ¶
type Wal struct {
// contains filtered or unexported fields
}
func (*Wal) WriteMulti ¶
func (w *Wal) WriteMulti(rec WalRecordType, pks []uint64, vals any) error
type WalRecordType ¶
type WalRecordType string
var ( WalRecordTypeInsert WalRecordType = "I " WalRecordTypeUpdate WalRecordType = "U " WalRecordTypeDelete WalRecordType = "D " )
Source Files ¶
- binarycondition.go
- blockinfo.go
- cast.go
- compile.go
- condition.go
- db.go
- debug.go
- field.go
- filter.go
- index.go
- iterator.go
- join.go
- journal.go
- kv_index.go
- kv_table.go
- log.go
- marshal.go
- model.go
- options.go
- order.go
- pack_header.go
- pack_index.go
- pack_table.go
- package.go
- packinfo.go
- query.go
- result.go
- stats.go
- store.go
- tree.go
- typeinfo.go
- unbound.go
- validate.go
- value.go
- wal.go