store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package store provides vector storage backends.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("vector not found")
)

Functions

This section is empty.

Types

type MemoryStore

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

MemoryStore is an in-memory vector store for testing.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore creates a new in-memory vector store.

func (*MemoryStore) Add

func (s *MemoryStore) Add(ctx context.Context, ids []string, vectors [][]float64, metadata []map[string]any) error

Add adds vectors to the store.

func (*MemoryStore) Close

func (s *MemoryStore) Close() error

Close closes the store.

func (*MemoryStore) Count

func (s *MemoryStore) Count(ctx context.Context) (int64, error)

Count returns total vector count.

func (*MemoryStore) Delete

func (s *MemoryStore) Delete(ctx context.Context, ids []string) error

Delete removes vectors by ID.

func (*MemoryStore) GetAll

func (s *MemoryStore) GetAll() map[string][]float64

GetAll returns all vectors (for testing).

func (*MemoryStore) GetByID

func (s *MemoryStore) GetByID(ctx context.Context, id string) ([]float64, error)

GetByID retrieves a single vector by ID.

func (*MemoryStore) GetByIDs

func (s *MemoryStore) GetByIDs(ctx context.Context, ids []string) ([][]float64, error)

GetByIDs retrieves vectors by their IDs.

func (*MemoryStore) GetMetadata

func (s *MemoryStore) GetMetadata(id string) (map[string]any, bool)

GetMetadata retrieves metadata for a vector.

type VectorStore

type VectorStore interface {
	// GetByIDs retrieves vectors by their IDs.
	GetByIDs(ctx context.Context, ids []string) ([][]float64, error)

	// GetByID retrieves a single vector by ID.
	GetByID(ctx context.Context, id string) ([]float64, error)

	// Add adds vectors to the store.
	Add(ctx context.Context, ids []string, vectors [][]float64, metadata []map[string]any) error

	// Delete removes vectors by ID.
	Delete(ctx context.Context, ids []string) error

	// Count returns total vector count.
	Count(ctx context.Context) (int64, error)

	// Close closes the connection.
	Close() error
}

VectorStore is the interface for vector storage backends.

Jump to

Keyboard shortcuts

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