db

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Storage

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

Storage represents the storage layer for vectors.

func NewStorage

func NewStorage(dbPath string) (*Storage, error)

NewStorage creates a new instance of Storage.

func (*Storage) Close

func (s *Storage) Close() error

Close closes the storage and performs any necessary cleanup.

func (*Storage) Delete

func (s *Storage) Delete(id string) error

Delete removes a vector from the storage by ID.

func (*Storage) Get

func (s *Storage) Get(id string) (*Vector, error)

Get retrieves a vector from the storage by ID.

func (*Storage) GetAll

func (s *Storage) GetAll() ([]*Vector, error)

GetAll retrieves all vectors from the storage.

func (*Storage) Insert

func (s *Storage) Insert(vector *Vector) error

Insert inserts a vector into the storage.

type Vector

type Vector struct {
	ID        string
	Embedding []float64
	Metadata  map[string]string
}

Vector represents a vector in the database.

func (*Vector) Add

func (v *Vector) Add(other Vector) error

Add adds another vector to the current vector.

func (Vector) Distance

func (v Vector) Distance(other Vector) (float64, error)

Distance calculates the cosine similarity between two vectors.

func (*Vector) Normalize

func (v *Vector) Normalize()

Normalize normalizes the vector to unit length.

func (*Vector) Subtract

func (v *Vector) Subtract(other Vector) error

Subtract subtracts another vector from the current vector.

Jump to

Keyboard shortcuts

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