memory

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() (vectorstore.VectorStore, error)

New creates a new MemoryVectorStore.

Types

type MemoryCollection

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

MemoryCollection represents an isolated collection of documents.

func (*MemoryCollection) Clear

func (c *MemoryCollection) Clear(ctx context.Context) error

Clear removes all documents from the collection.

func (*MemoryCollection) Count

func (c *MemoryCollection) Count(ctx context.Context, filter vectorstore.Filter) (int64, error)

Count returns the number of documents in the collection.

func (*MemoryCollection) Delete

Delete removes documents by their IDs.

func (*MemoryCollection) DeleteByFilter

func (c *MemoryCollection) DeleteByFilter(ctx context.Context, filter vectorstore.Filter) (*vectorstore.DeleteResult, error)

DeleteByFilter removes all documents matching the filter.

func (*MemoryCollection) Get

func (c *MemoryCollection) Get(ctx context.Context, ids ...string) ([]*vectorstore.Document, error)

Get retrieves documents by their IDs.

func (*MemoryCollection) Name

func (c *MemoryCollection) Name() string

Name returns the collection name.

func (*MemoryCollection) Query

Query performs similarity search and returns matching documents.

func (*MemoryCollection) QueryStream

QueryStream performs similarity search and streams results via an iterator.

func (*MemoryCollection) Stats

Stats returns statistics about the collection.

func (*MemoryCollection) Upsert

Upsert inserts or updates documents in the collection.

func (*MemoryCollection) UpsertBatch

UpsertBatch performs batch upsert with progress tracking.

type MemoryVectorStore

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

MemoryVectorStore implements an in-memory vector store for testing and development. It uses brute-force search and is suitable for small to medium datasets.

Features:

  • Collection-based isolation
  • Built-in TTL cleanup
  • Content hash deduplication
  • Indexed lookups for scope/temporal fields
  • Thread-safe operations
  • Streaming query support

func (*MemoryVectorStore) Close

func (m *MemoryVectorStore) Close() error

Close closes the vector store and releases resources.

func (*MemoryVectorStore) Collection

Collection returns a collection with the specified name and options.

func (*MemoryVectorStore) DeleteCollection

func (m *MemoryVectorStore) DeleteCollection(ctx context.Context, name string) error

DeleteCollection permanently deletes a collection and all its documents.

func (*MemoryVectorStore) ListCollections

func (m *MemoryVectorStore) ListCollections(ctx context.Context) ([]string, error)

ListCollections returns the names of all collections.

func (*MemoryVectorStore) Stats

Stats returns statistics about the vector store.

Jump to

Keyboard shortcuts

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