Documentation
¶
Index ¶
- Constants
- func EncodeSnapshot(s Snapshot) ([]byte, error)
- type Codec
- type DurabilityConfig
- type Header
- type IntegrityReport
- type Snapshot
- type Store
- func (s *Store) Delete(indexID core.IndexID) error
- func (s *Store) Exists(indexID core.IndexID) bool
- func (s *Store) FlushAll() error
- func (s *Store) GetSnapshot(indexID core.IndexID) (*Snapshot, bool)
- func (s *Store) ListIndexes() []core.IndexID
- func (s *Store) Load(indexID core.IndexID) (*core.Matrix, error)
- func (s *Store) Save(matrix *core.Matrix) error
- func (s *Store) SaveAsync(matrix *core.Matrix) error
- func (s *Store) StartChecksumValidationWorker(interval time.Duration) chan struct{}
- func (s *Store) StartFlushWorker(interval time.Duration) chan struct{}
- func (s *Store) Stats() map[string]any
- func (s *Store) ValidateDataFiles(repair bool) (IntegrityReport, error)
Constants ¶
const ( MagicBytes = "NRDB" // QubicDB magic identifier FormatVersion = 1 )
Binary format constants
const ( FlagCompressed uint16 = 1 << 0 FlagEncrypted uint16 = 1 << 1 )
const ( FsyncPolicyAlways = "always" FsyncPolicyInterval = "interval" FsyncPolicyOff = "off" )
Variables ¶
This section is empty.
Functions ¶
func EncodeSnapshot ¶
EncodeSnapshot serializes a snapshot
Types ¶
type Codec ¶
type Codec struct {
// contains filtered or unexported fields
}
Codec handles encoding/decoding of matrices
type DurabilityConfig ¶
type DurabilityConfig struct {
WALEnabled bool
FsyncPolicy string
FsyncInterval time.Duration
ChecksumValidationInterval time.Duration
StartupRepair bool
}
DurabilityConfig defines persistence durability controls.
func DefaultDurabilityConfig ¶
func DefaultDurabilityConfig() DurabilityConfig
DefaultDurabilityConfig returns the default durability profile.
type Header ¶
type Header struct {
Magic [4]byte
Version uint16
Flags uint16
IndexIDLen uint32
DataLen uint64
Checksum uint32
}
Header for binary format
type IntegrityReport ¶
IntegrityReport summarizes checksum validation results across persisted data files.
type Snapshot ¶
type Snapshot struct {
IndexID core.IndexID `msgpack:"index_id"`
Version uint64 `msgpack:"version"`
NeuronCount int `msgpack:"neuron_count"`
SynapseCount int `msgpack:"synapse_count"`
CurrentDim int `msgpack:"current_dim"`
TotalEnergy float64 `msgpack:"total_energy"`
ModifiedAt int64 `msgpack:"modified_at"`
}
EncodeSnapshot creates a lightweight snapshot for quick persistence
func CreateSnapshot ¶
CreateSnapshot creates a snapshot from a matrix
func DecodeSnapshot ¶
DecodeSnapshot deserializes a snapshot
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store handles file-based persistence of matrices
func NewStoreWithDurability ¶
func NewStoreWithDurability(basePath string, compress bool, durability DurabilityConfig) (*Store, error)
NewStoreWithDurability creates a new persistence store with durability settings.
func (*Store) GetSnapshot ¶
GetSnapshot returns the cached snapshot for a user
func (*Store) ListIndexes ¶
ListIndexes returns all persisted user IDs
func (*Store) StartChecksumValidationWorker ¶
StartChecksumValidationWorker starts periodic checksum validation over persisted data files.
func (*Store) StartFlushWorker ¶
StartFlushWorker starts background flush worker
func (*Store) ValidateDataFiles ¶
func (s *Store) ValidateDataFiles(repair bool) (IntegrityReport, error)
ValidateDataFiles verifies checksums/decoding of persisted .nrdb files. When repair=true, corrupt files are removed and index entries are repaired.