bruteforce

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package bruteforce provides a simple vector index that answers kNN queries by scanning all vectors and scoring via cosine similarity. It supports a compact binary format for persistence in the vector_storage table.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

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

Index is a simple brute-force vector index implementing cosine similarity.

func (*Index) Build

func (i *Index) Build(ids []string, vectors [][]float32) error

Build loads ids and vectors and precomputes magnitudes.

func (*Index) MarshalBinary

func (i *Index) MarshalBinary() ([]byte, error)

MarshalBinary stores: dim(uint32), n(uint32), then for each item: idLen(uint32), id bytes, vec(float32[dim]).

func (*Index) Query

func (i *Index) Query(query []float32, k int) ([]string, []float64, error)

Query returns top-k by cosine similarity.

func (*Index) UnmarshalBinary

func (i *Index) UnmarshalBinary(data []byte) error

UnmarshalBinary restores the index from bytes.

Jump to

Keyboard shortcuts

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