cache

package
v0.0.0-debug-20260702 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	STATUS_NOT_INIT  = 0
	STATUS_LOADED    = 1
	STATUS_DESTROYED = 2
	STATUS_ERROR     = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type VectorIndexCache

type VectorIndexCache struct {
	IndexMap       sync.Map
	TickerInterval time.Duration
	// contains filtered or unexported fields
}

implementation of VectorIndexCache

var (
	VectorIndexCacheTTL time.Duration     = 5 * time.Minute
	Cache               *VectorIndexCache = NewVectorIndexCache()
)

func NewVectorIndexCache

func NewVectorIndexCache() *VectorIndexCache

func (*VectorIndexCache) Destroy

func (c *VectorIndexCache) Destroy()

destroy the cache

func (*VectorIndexCache) HouseKeeping

func (c *VectorIndexCache) HouseKeeping()

house keeping to check expired keys and delete from cache

func (*VectorIndexCache) Once

func (c *VectorIndexCache) Once()

initialize the Cache and only call once

func (*VectorIndexCache) Remove

func (c *VectorIndexCache) Remove(key string)

remove key from cache

func (*VectorIndexCache) Search

func (c *VectorIndexCache) Search(sqlproc *sqlexec.SqlProcess, key string, newalgo VectorIndexSearchIf,
	query any, rt vectorindex.RuntimeConfig) (keys any, distances []float64, err error)

Get index from cache and return VectorIndexSearchIf interface

type VectorIndexSearch

type VectorIndexSearch struct {
	Mutex      sync.RWMutex
	ExpireAt   atomic.Int64
	LastUpdate atomic.Int64
	Status     atomic.Int32 // 0 - NOT INIT, 1 - LOADED, 2 - marked as outdated,  3 - DESTROYED,  4 or above ERRCODE
	Outdated   atomic.Bool
	Algo       VectorIndexSearchIf
	Cond       *sync.Cond // NOTE: this is RWCond. Wait() will use mutex.RLock() and mutex.RUnlock()
}

base VectorIndex Search structure for VectorIndexSearchIf (see HnswSearch)

func (*VectorIndexSearch) Destroy

func (s *VectorIndexSearch) Destroy()

func (*VectorIndexSearch) Expired

func (s *VectorIndexSearch) Expired() bool

func (*VectorIndexSearch) Load

func (s *VectorIndexSearch) Load(sqlproc *sqlexec.SqlProcess) error

func (*VectorIndexSearch) Search

func (s *VectorIndexSearch) Search(sqlproc *sqlexec.SqlProcess, newalgo VectorIndexSearchIf, query any, rt vectorindex.RuntimeConfig) (keys any, distances []float64, err error)

type VectorIndexSearchIf

type VectorIndexSearchIf interface {
	Search(proc *sqlexec.SqlProcess, query any, rt vectorindex.RuntimeConfig) (keys any, distances []float64, err error)
	// SearchFloat32 writes results into caller-provided slices to avoid heap allocation.
	// outKeys and outDists must be pre-allocated to nQueries*rt.Limit elements.
	// GPU implementations write float32 distances directly; CPU implementations convert on write.
	SearchFloat32(proc *sqlexec.SqlProcess, query any, rt vectorindex.RuntimeConfig, outKeys []int64, outDists []float32) error
	Load(*sqlexec.SqlProcess) error
	UpdateConfig(VectorIndexSearchIf) error
	Destroy()
}

Various vector index algorithm wants to share with VectorIndexCache need to implement VectorIndexSearchIf interface (see HnswSearch)

Jump to

Keyboard shortcuts

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