utils

package
v0.13.0-test.4 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Euclidian = "euclidian"
	Cosine    = "cosine"
	DotProd   = "dotproduct"

	VecKeyword = "__vector_"

	VecEntry             = "__vector_entry"
	VecDead              = "__vector_dead"
	VectorIndexMaxLevels = 5
	EfConstruction       = 16
	EfSearch             = 12

	// ByteData indicates the key stores data.
	ByteData = byte(0x00)
	// DefaultPrefix is the prefix used for data, index and reverse keys so that relative
	DefaultPrefix = byte(0x00)
	// NsSeparator is the separator between the namespace and attribute.
	NsSeparator = "-"
)

Variables

This section is empty.

Functions

func ConcatStrings

func ConcatStrings(strs ...string) string

func ConvertToFloat32_2DArray

func ConvertToFloat32_2DArray(vecs any) ([][]float32, error)

func CosineDistance

func CosineDistance(a, b []float32) (float64, error)

assume normalization for vectors

func DotProduct

func DotProduct(a, b []float32) (float32, error)

func EqualFloat32Slices

func EqualFloat32Slices(a, b []float32) bool

func IsBetterScoreForDistance

func IsBetterScoreForDistance(a, b float64) bool

func Normalize

func Normalize(v []float32) ([]float32, error)

Types

type MaxHeapElement

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

func InitHeapElement

func InitHeapElement(
	val float64, i string, filteredOut bool) MaxHeapElement

func (MaxHeapElement) GetIndex

func (e MaxHeapElement) GetIndex() string

func (MaxHeapElement) GetValue

func (e MaxHeapElement) GetValue() float64

type MaxTupleHeap

type MaxTupleHeap []MaxHeapElement

func (MaxTupleHeap) Len

func (h MaxTupleHeap) Len() int

func (MaxTupleHeap) Less

func (h MaxTupleHeap) Less(i, j int) bool

func (*MaxTupleHeap) Pop

func (h *MaxTupleHeap) Pop() interface{}

func (*MaxTupleHeap) Push

func (h *MaxTupleHeap) Push(x interface{})

func (MaxTupleHeap) Swap

func (h MaxTupleHeap) Swap(i, j int)

Jump to

Keyboard shortcuts

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