memory

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package memory provides an in-memory vector store using brute-force cosine similarity. Suitable for testing and development.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store is an in-memory vector store with brute-force cosine similarity search.

func New

func New() *Store

New creates a new in-memory vector store.

func (*Store) Delete

func (s *Store) Delete(_ context.Context, ids []string) error

Delete removes entries by their IDs.

func (*Store) DeleteByMetadata

func (s *Store) DeleteByMetadata(_ context.Context, filter map[string]string) error

DeleteByMetadata removes entries matching the given metadata filter. An empty filter would match every entry and is ErrInvalidArgument.

func (*Store) Describe

func (*Store) Describe() weave.ComponentInfo

Describe reports the in-memory vector store: cosine similarity, and an exact tenant_id metadata filter that is covered by Weave's own tests.

func (*Store) Len

func (s *Store) Len() int

Len returns how many entries the store holds, across every tenant.

func (*Store) Search

func (s *Store) Search(_ context.Context, vector []float32, opts *vectorstore.SearchOptions) ([]vectorstore.SearchResult, error)

Search returns the most similar entries of one tenant to the given vector using cosine similarity. An empty TenantKey is ErrTenantRequired.

func (*Store) Upsert

func (s *Store) Upsert(_ context.Context, entries []vectorstore.Entry) error

Upsert inserts or updates vector entries. Every entry needs a metadata["tenant_id"]; one without it is ErrTenantRequired, and nothing in the batch is written.

Jump to

Keyboard shortcuts

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