Documentation
¶
Overview ¶
Package store provides SQLite-backed storage primitives for Stroma indexes.
Index ¶
- Constants
- func CheckSQLiteReady() error
- func CheckSQLiteReadyContext(ctx context.Context) error
- func CosineScoreFromDistance(distance float64) float64
- func DecodeVectorBlob(blob []byte) ([]float64, error)
- func DecodeVectorBlobBinary(blob []byte) ([]float64, error)
- func DecodeVectorBlobInt8(blob []byte) ([]float64, error)
- func EncodeVectorBlob(vector []float64) ([]byte, error)
- func EncodeVectorBlobBinary(vector []float64) ([]byte, error)
- func EncodeVectorBlobInt8(vector []float64) ([]byte, error)
- func IsMissingIndex(err error) bool
- func MissingIndexPath(err error) string
- func OpenReadOnly(path string) (*sql.DB, error)
- func OpenReadOnlyContext(ctx context.Context, path string) (*sql.DB, error)
- func OpenReadWrite(path string) (*sql.DB, error)
- func OpenReadWriteContext(ctx context.Context, path string) (*sql.DB, error)
- type MissingIndexError
Constants ¶
const ( // QuantizationFloat32 is the default float32 vector quantization. QuantizationFloat32 = "float32" // QuantizationInt8 uses signed 8-bit scalar quantization. QuantizationInt8 = "int8" // QuantizationBinary uses sign-based 1-bit quantization for the // prefilter and pairs it with a full-precision float32 companion // column for rescoring. The embedder dimension must be a multiple of // 8 because each byte of the packed blob carries 8 consecutive dims. QuantizationBinary = "binary" )
Variables ¶
This section is empty.
Functions ¶
func CheckSQLiteReady ¶
func CheckSQLiteReady() error
CheckSQLiteReady validates that the SQLite driver and sqlite-vec extension are usable.
func CheckSQLiteReadyContext ¶
CheckSQLiteReadyContext validates that the SQLite driver and sqlite-vec extension are usable.
func CosineScoreFromDistance ¶
CosineScoreFromDistance converts sqlite-vec cosine distance into a clamped score.
func DecodeVectorBlob ¶
DecodeVectorBlob decodes a sqlite-vec float32 blob into float64 values. The hot path does one allocation (the returned []float64) and reads each 4-byte little-endian float32 directly from the input buffer — the earlier binary.Read + bytes.Reader route allocated an intermediate []float32 plus a reader wrapper per call, which compounded on reuse-heavy rebuilds where this runs for every stored chunk.
func DecodeVectorBlobBinary ¶
DecodeVectorBlobBinary expands a bit-packed vector blob back to {-1, 1} float64 values. The returned vector has length blob-bytes * 8.
func DecodeVectorBlobInt8 ¶
DecodeVectorBlobInt8 decodes a sqlite-vec int8 vector blob back to float64.
func EncodeVectorBlob ¶
EncodeVectorBlob encodes float64 embeddings into the sqlite-vec blob format.
func EncodeVectorBlobBinary ¶
EncodeVectorBlobBinary packs the vector into a sqlite-vec bit blob using sign-based quantization: each output bit is 1 when the corresponding component is non-negative, 0 otherwise. The dimension must be a multiple of 8. The bit ordering matches sqlite-vec's vec_bit() parser: within each byte, dimension k occupies bit (k % 8) counted from the LSB.
func EncodeVectorBlobInt8 ¶
EncodeVectorBlobInt8 L2-normalizes the input vector and then quantizes it to signed 8-bit integers for sqlite-vec int8 vector columns. Normalizing before quantization ensures any embedder output is mapped into [-1, 1] without silent clamping or hidden preconditions.
func IsMissingIndex ¶
IsMissingIndex reports whether err wraps a missing-index failure.
func MissingIndexPath ¶
MissingIndexPath returns the configured path for a missing-index failure.
func OpenReadOnly ¶
OpenReadOnly opens a fresh read-only SQLite handle.
func OpenReadOnlyContext ¶
OpenReadOnlyContext opens a fresh read-only SQLite handle.
func OpenReadWrite ¶
OpenReadWrite opens a read-write SQLite handle.
Types ¶
type MissingIndexError ¶
type MissingIndexError struct {
Path string
}
MissingIndexError reports that the requested index file does not exist yet.
func (*MissingIndexError) Error ¶
func (e *MissingIndexError) Error() string