Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyDBProcess(db *DB, name string, processFn func())
- func BackupBuckets(db *DB, out *bufio.Writer, bucketNames ...string) error
- func ChannelError(target *error, err error)
- func CollectionAddEntry[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, order O, item I)
- func CollectionRemoveEntry[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, item I)
- func DEBUGInspect[K, V any](tx *Tx, bucket *BucketInfo[K, V])
- func Delete[K, T any](tx *Tx, info *BucketInfo[K, T], id K)
- func DeleteTargetTerms[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K)
- func DumpBucketJSON[K, V any](db *DB, out *bufio.Writer, label string, bucket *BucketInfo[K, V])
- func EnsureBuckets(tx *Tx, dbInfo *Info)
- func GenericRead(tx *Tx, inspection *Inspection)
- func HasKey[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], id K) bool
- func InitBuckets(db *DB, infos ...*Info)
- func IterateAll[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], visitFn func(key K, item T) bool)
- func IterateAllReverse[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], visitFn func(key K, item T) bool)
- func IterateAllTerms[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], ...)
- func IterateBucketFrom[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], startKey K, ...) []byte
- func IterateBucketFromPartial[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], startKey K, ...) []byte
- func IterateCollection[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, ...)
- func IterateCollectionReverse[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, ...)
- func IterateInBatches[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], batchSize int, ...)
- func IterateTarget[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, ...)
- func IterateTerm[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], term T, ...) []byte
- func NextIntId[K, T any](tx *Tx, info *BucketInfo[K, T]) int
- func RawHasKey(bkt *BBucket, key []byte) bool
- func RawMustPut(bkt *BBucket, key []byte, value []byte)
- func RawNextSequence(bucket *BBucket) uint64
- func RawSetSequenceCorrectly(bucket *BBucket)
- func Read[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], id K, item *T) bool
- func ReadAppend[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], id K, list *[]T) bool
- func ReadCollection[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, items *[]I, count int)
- func ReadCollectionReverse[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, items *[]I, count int)
- func ReadSlice[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], ids []K, list *[]T) int
- func ReadSliceToMap[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], ids []K, itemsMap map[K]T) int
- func ReadTermCount[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], term *T, count *int) bool
- func ReadTermTargetSingle[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], term T, target *K) bool
- func ReadTermTargets[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], term T, targets *[]K, window Window) []byte
- func ReadToMap[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], id K, itemsMap map[K]T) bool
- func RestoreBuckets(db *DB, in *bytes.Reader) error
- func RunProcess(label string, processFn func())
- func ScanList[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], startKey K, count int, items *[]T) (nextKey K, done bool)
- func SetTargetSingleTerm[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, term T)
- func SetTargetSingleTermExt[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, priority P, term T)
- func SetTargetTerms[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, terms map[T]P)
- func SetTargetTermsPlain[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, terms []T)
- func SetTargetTermsUniform[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, terms []T, priority P)
- func TxClose(tx *Tx)
- func TxCommit(tx *Tx)
- func TxWriteBatches[Key, Struct any](db *DB, info *BucketInfo[Key, Struct], batchSize int, ...)
- func UniformTerms[T, P comparable](terms []T, priority P) (out map[T]P)
- func WarmTheCache(tx *Tx, dbInfo *Info)
- func WithReadTx(db *DB, fn func(tx *Tx))
- func WithWriteTx(db *DB, fn func(tx *Tx))
- func Write[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], id K, item *T)
- type BBucket
- type BucketInfo
- type CollectionInfo
- type Cursor
- type DB
- type GenericItem
- type IndexInfo
- type Info
- type Inspection
- type InspectionBucketMetadata
- type IterationDirection
- type Tx
- type Window
Constants ¶
const BUCKET_HEADER byte = 0x01
const CCountPrefix byte = 0x13
const CItemPrefix byte = 0x12
const CKeyPrefix byte = 0x10
const ITEM_HEADER byte = 0x02
const IndexCountPrefix byte = 0x03
const IndexTargetPrefix byte = 0x02
const IndexTermPrefix byte = 0x01
const IterateRegular = IterationDirection(0)
const IterateReverse = IterationDirection(1)
Variables ¶
var PackCountFn = vpack.Int
Functions ¶
func ApplyDBProcess ¶
kind of like a migration, but mostly we expect it to be about recreating indecies and stuff
func ChannelError ¶
func CollectionAddEntry ¶ added in v0.2.0
func CollectionAddEntry[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, order O, item I)
func CollectionRemoveEntry ¶ added in v0.2.0
func CollectionRemoveEntry[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, item I)
func DEBUGInspect ¶
func DEBUGInspect[K, V any](tx *Tx, bucket *BucketInfo[K, V])
func Delete ¶
func Delete[K, T any](tx *Tx, info *BucketInfo[K, T], id K)
func DeleteTargetTerms ¶
func DeleteTargetTerms[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K)
func DumpBucketJSON ¶
func EnsureBuckets ¶
func GenericRead ¶
func GenericRead(tx *Tx, inspection *Inspection)
GenericRead takes a generic bucketInfo (must be *BucketInfo, i.e. a pointer) and reads a list of keys and values without really knowing the underlying type. Introspection is needed to properly display the type. Formatting the data as JSON is a good start.
func InitBuckets ¶ added in v0.2.3
func IterateAll ¶
func IterateAll[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], visitFn func(key K, item T) bool)
func IterateAllReverse ¶
func IterateAllReverse[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], visitFn func(key K, item T) bool)
func IterateAllTerms ¶
func IterateAllTerms[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], visitFn func(term T, target K, priority P) bool)
func IterateBucketFrom ¶ added in v0.2.0
func IterateBucketFrom[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], startKey K, visitFn func(key K, value T) bool) []byte
IterateBucketFrom lets you specify the starting key using the userspace key type
func IterateBucketFromPartial ¶ added in v0.2.4
func IterateBucketFromPartial[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], startKey K, visitFn func(key K, value T) bool) []byte
IterateBucketFromPartial lets you specify the starting key using the userspace key type and lets you fill it partially
func IterateCollection ¶ added in v0.2.0
func IterateCollection[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, visit func(key K, order O, item I) bool)
func IterateCollectionReverse ¶ added in v0.2.0
func IterateCollectionReverse[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, visit func(key K, order O, item I) bool)
func IterateInBatches ¶
func IterateInBatches[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], batchSize int, visitFn func(items []T) bool)
func IterateTarget ¶
func IterateTarget[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, visitFn func(term T, priority P) bool)
iterate over terms that are assigned to target
func IterateTerm ¶
func IterateTerm[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], term T, visitFn func(target K, priority P) bool) []byte
func RawNextSequence ¶
func RawSetSequenceCorrectly ¶
func RawSetSequenceCorrectly(bucket *BBucket)
func Read ¶
func Read[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], id K, item *T) bool
func ReadAppend ¶
func ReadAppend[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], id K, list *[]T) bool
like read slice but for reading one item and appending it to a list
func ReadCollection ¶ added in v0.2.0
func ReadCollection[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, items *[]I, count int)
func ReadCollectionReverse ¶ added in v0.2.0
func ReadCollectionReverse[K, O, I any](tx *Tx, info *CollectionInfo[K, O, I], key K, items *[]I, count int)
func ReadSlice ¶
func ReadSlice[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], ids []K, list *[]T) int
ReadSlice reads objects given by ids, appending them to the given slice. returns the number of objects that were successfully read
func ReadSliceToMap ¶
func ReadSliceToMap[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], ids []K, itemsMap map[K]T) int
ReadSliceToMap reads objects given by id into the given map. returns the number of objects that were successfully read
func ReadTermCount ¶
func ReadTermCount[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], term *T, count *int) bool
func ReadTermTargetSingle ¶
func ReadTermTargetSingle[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], term T, target *K) bool
func ReadTermTargets ¶
func ReadTermTargets[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], term T, targets *[]K, window Window) []byte
func ReadToMap ¶
func ReadToMap[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], id K, itemsMap map[K]T) bool
func RunProcess ¶
func RunProcess(label string, processFn func())
func ScanList ¶
func ScanList[K, T any](tx *Tx, bucketInfo *BucketInfo[K, T], startKey K, count int, items *[]T) (nextKey K, done bool)
func SetTargetSingleTerm ¶
func SetTargetSingleTerm[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, term T)
func SetTargetSingleTermExt ¶ added in v0.2.0
func SetTargetSingleTermExt[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, priority P, term T)
func SetTargetTerms ¶
func SetTargetTerms[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, terms map[T]P)
Updates target,term pairs so that only the terms provided here point to target. terms map the term to the priority
func SetTargetTermsPlain ¶
func SetTargetTermsPlain[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, terms []T)
sets terms without priorities
func SetTargetTermsUniform ¶
func SetTargetTermsUniform[K, T, P comparable](tx *Tx, indexInfo *IndexInfo[K, T, P], target K, terms []T, priority P)
func TxWriteBatches ¶
func TxWriteBatches[Key, Struct any](db *DB, info *BucketInfo[Key, Struct], batchSize int, processFn func(tx *Tx, batch []Struct))
func UniformTerms ¶
func UniformTerms[T, P comparable](terms []T, priority P) (out map[T]P)
func WithReadTx ¶ added in v0.2.0
func WithWriteTx ¶
WithWriteTx calls supplied function with a writeable transaction
Caller must commit the tx explicitly; otherwise it will get rolled back by default
func Write ¶
func Write[K comparable, T any](tx *Tx, bucketInfo *BucketInfo[K, T], id K, item *T)
Writes an item to a key. Note: does not write anything if id is the zero value
Types ¶
type BBucket ¶
func TxRawBucket ¶
type BucketInfo ¶
type CollectionInfo ¶ added in v0.2.0
type CollectionInfo[K, O, I any] struct { Name string KeyFn vpack.PackFn[K] OrderFn vpack.PackFn[O] ItemFn vpack.PackFn[I] }
collection bucket
type GenericItem ¶
type IndexInfo ¶
type IndexInfo[K, T, P comparable] struct { Name string TargetPackFn vpack.PackFn[K] TermPackFn vpack.PackFn[T] PriorityPackFn vpack.PackFn[P] }
type Inspection ¶
type Inspection struct {
// request
BucketInfoPtr any // must be a *BucketInfo[K, V]
Limit int
// both request/response
NextKey any
// response
Items []GenericItem
TotalItemsCount int
}
type InspectionBucketMetadata ¶ added in v0.2.4
type InspectionBucketMetadata struct {
Name string
KeyPackFn reflect.Value
ValuePackFn reflect.Value
KeyType reflect.Type
ValueType reflect.Type
}
func InspectAnyBucketInfo ¶ added in v0.2.4
func InspectAnyBucketInfo(bucketInfo any) (meta InspectionBucketMetadata)
type IterationDirection ¶ added in v0.2.1
type IterationDirection uint8