flat

package
v0.0.12 Latest Latest
Warning

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

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

Documentation

Overview

Package flat provides an implementation of a flat index for vector storage and search.

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	DistanceType: index.DistanceTypeSquaredL2,
}

DefaultOptions contains the default configuration options for the flat index.

Functions

This section is empty.

Types

type Flat

type Flat struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Flat represents a flat index for vector storage and search.

func New

func New(optFns ...func(o *Options)) *Flat

New creates a new instance of the flat index with the given dimension and options.

func (*Flat) BruteSearch

func (f *Flat) BruteSearch(query []float32, k int, filter func(id uint32) bool) ([]index.SearchResult, error)

BruteSearch performs a brute-force search in the flat index.

func (*Flat) GobDecode

func (f *Flat) GobDecode(data []byte) error

GobDecode method for Flat.

func (*Flat) GobEncode

func (f *Flat) GobEncode() ([]byte, error)

GobEncode method for Flat.

func (*Flat) Insert

func (f *Flat) Insert(v []float32) (uint32, error)

Insert inserts a vector into the flat index.

func (*Flat) KNNSearch

func (f *Flat) KNNSearch(q []float32, k int, efSearch int, filter func(id uint32) bool) ([]index.SearchResult, error)

KNNSearch performs a K-nearest neighbor search in the flat index.

func (*Flat) Stats

func (f *Flat) Stats()

Stats prints statistics about flat

type Node

type Node struct {
	Vector []float32 // Vector (X dimensions)
	ID     uint32    // Unique identifier
}

Node represents a node in the flat index with its vector and unique identifier.

type Options

type Options struct {
	// DistanceType represents the type of distance function used for calculating distances between vectors.
	DistanceType index.DistanceType
}

Options contains configuration options for the flat index.

Jump to

Keyboard shortcuts

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