graph

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var (
	KeyFactCount = []byte{PrefixSystem, 0x01} // uint64 count of stored facts
)

Functions

func DecodeQuadKey

func DecodeQuadKey(key []byte) (s, p, o, g uint64, err error)

DecodeQuadKey reads the bytes back out of the index, correctly reversing the permutation.

func EncodeQuadKey

func EncodeQuadKey(prefix byte, s, p, o, g uint64) []byte

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 Store

type Store struct {
	// contains filtered or unexported fields
}

Store provides the persistent BadgerDB backend for the Sovereign Logic Kernel.

func NewStore

func NewStore(path string, readOnly bool) (*Store, error)

NewStore initializes a high-performance BadgerDB instance optimized for Manglekit's read-heavy Datalog workloads and asynchronous agent write-behinds.

func (*Store) AddFact

func (s *Store) AddFact(s_, p, o, g uint64) error

AddFact persists a single quad into all four index permutations atomically.

func (*Store) Close

func (s *Store) Close() error

Close gracefully terminates the Badger instance, flushing memtables.

func (*Store) NumFacts

func (s *Store) NumFacts() uint64

NumFacts returns the total number of stored facts (lock-free read).

func (*Store) RunVLogGC

func (s *Store) RunVLogGC(ctx context.Context)

RunVLogGC is the Incremental Garbage Collection loop required by LLD 4.2. Long-running agents constantly update temporal state, bloating the BadgerDB value logs. This MUST be called as a background goroutine.

func (*Store) Scan

func (s *Store) Scan(prefix byte, seekKey []byte, limit int, fn func(s, p, o, g uint64) bool) error

Scan performs a prefix scan over a specific index permutation. The callback receives the decoded (s, p, o, g) tuple for each matching key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL