Help us shape the future of Go! Take the 2026 Go Developer Survey

vectors

package module
v0.0.0-...-56a1d56 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2025 License: MIT Imports: 5 Imported by: 0

README

Vectors

Go Reference

An in-memory vector store that uses a brute-force approach for searching through vectors.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Similarity

func Similarity(v1, v2 Vector) float32

Types

type Database

type Database[V any] struct {
	Data map[ID]V
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase[V any](vectorLength int, options ...Option[V]) *Database[V]

func (*Database[V]) Add

func (db *Database[V]) Add(record Record[V]) Record[V]

func (*Database[V]) AddBatch

func (db *Database[V]) AddBatch(records []Record[V]) []Record[V]

func (*Database[V]) Delete

func (db *Database[V]) Delete(id ID)

func (*Database[V]) DeleteBatch

func (db *Database[V]) DeleteBatch(ids []ID)

func (*Database[V]) Get

func (db *Database[V]) Get(vectors []Vector, n int) []Record[V]

type ID

type ID int64

type Option

type Option[V any] func(*Database[V])

func WithRepackDivisor

func WithRepackDivisor[V any](divisor int) Option[V]

type Record

type Record[V any] struct {
	ID     ID
	Vector Vector
	Data   V
}

type Vector

type Vector []float32

type Vectors

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

func NewVectors

func NewVectors(chunkSize int) *Vectors

func (*Vectors) Add

func (v *Vectors) Add(vector Vector) ID

func (*Vectors) Compact

func (v *Vectors) Compact()

func (*Vectors) Delete

func (v *Vectors) Delete(id ID) bool

func (*Vectors) Get

func (v *Vectors) Get(vectors []Vector, n int) []ID

func (*Vectors) Repack

func (v *Vectors) Repack() *Vectors

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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