Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeQuadKey(key []byte) (s, p, o, g uint64, err error)
- func EncodeQuadKey(prefix byte, s, p, o, g uint64) []byte
- type Quad
- type Store
- func (s *Store) AddFact(s_, p, o, g uint64) error
- func (s *Store) AddFacts(quads []Quad) error
- func (s *Store) Close() error
- func (s *Store) NumFacts() uint64
- func (s *Store) RunVLogGC(ctx context.Context)
- func (s *Store) Scan(prefix byte, seekKey []byte, limit int, fn func(s, p, o, g uint64) bool) error
Constants ¶
const ( PrefixSPOg byte = 0x10 // Subject-Predicate-Object-Graph (Standard Forward) PrefixPOSg byte = 0x11 // Predicate-Object-Subject-Graph (Reverse Lookup) PrefixPSOg byte = 0x12 // Predicate-Subject-Object-Graph (Graph Filtering) PrefixGSPO byte = 0x13 // Graph-Subject-Predicate-Object (Isolation Layer) PrefixSystem byte = 0xFF // Metadata (Count, Schema bounds, Leiden Communities) )
Prefix keys for BadgerDB to route to proper index tables.
Variables ¶
var (
KeyFactCount = []byte{PrefixSystem, 0x01} // uint64 count of stored facts
)
Functions ¶
func DecodeQuadKey ¶
DecodeQuadKey reads the bytes back out of the index, correctly reversing the permutation.
func EncodeQuadKey ¶
EncodeQuadKey produces a strictly aligned 33-byte slice for lexicographical sorting. By using Big-Endian representation, the numeric scale of uint64 perfectly aligns with the byte sequence scale inside BadgerDB SSTables, enabling optimal binary searches via LFTJ (Leapfrog Triejoin).
Types ¶
type Quad ¶ added in v0.7.0
type Quad struct {
S, P, O, G uint64
}
Quad is a batch-friendly tuple of the four quad components. See AddFact for the per-index layout.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides the persistent BadgerDB backend for the Sovereign Logic Kernel.
func NewStore ¶
NewStore initializes a high-performance BadgerDB instance optimized for Manglekit's read-heavy Datalog workloads and asynchronous agent write-behinds. Writes are asynchronous (WithSyncWrites(false)) — the right default for cache-style, re-derivable state. For session persistence that must survive a crash, use NewStoreWithOptions with syncWrites=true.
func NewStoreWithOptions ¶ added in v0.7.0
NewStoreWithOptions is NewStore with an explicit durability stance. syncWrites=true makes Badger fsync on write (WithSyncWrites(true)), the opt-in durability option for session persistence; the default (false) keeps asynchronous writes for cache-style usage.
func (*Store) AddFacts ¶ added in v0.7.0
AddFacts persists a batch of quads using a single Badger write batch instead of one transaction per quad. The fact counter is updated once, atomically with the batch, counting only genuinely new facts (duplicate SPOg keys within or before the batch do not inflate it).