common

package
v1.27.8 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IndexTypeHNSW    = "hnsw"
	IndexTypeFlat    = "flat"
	IndexTypeNoop    = "noop"
	IndexTypeDynamic = "dynamic"
)
View Source
const (
	// DefaultSearchByDistInitialLimit :
	// the initial limit of 100 here is an
	// arbitrary decision, and can be tuned
	// as needed
	DefaultSearchByDistInitialLimit = 100

	// DefaultSearchByDistLimitMultiplier :
	// the decision to increase the limit in
	// multiples of 10 here is an arbitrary
	// decision, and can be tuned as needed
	DefaultSearchByDistLimitMultiplier = 10
)
View Source
const DefaultShardedLocksCount = 512

Variables

This section is empty.

Functions

func CalculateOptimalSegments added in v1.25.23

func CalculateOptimalSegments(dims int) int

func VectorsEqual added in v1.24.0

func VectorsEqual(vecA, vecB []float32) bool

Types

type IndexStats added in v1.24.23

type IndexStats interface {
	IndexType() IndexType
}

type IndexType added in v1.24.23

type IndexType string

type Iterator added in v1.27.0

type Iterator interface {
	Next() (int, error)
	IsDone() bool
}

Iterator interface defines the methods for sampling elements.

type MultiVectorForID

type MultiVectorForID func(ctx context.Context, ids []uint64) ([][]float32, []error)

type PqMaxPool

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

func NewPqMaxPool

func NewPqMaxPool(defaultCap int) *PqMaxPool

func (*PqMaxPool) GetMax

func (pqh *PqMaxPool) GetMax(capacity int) *priorityqueue.Queue[any]

func (*PqMaxPool) Put

func (pqh *PqMaxPool) Put(pq *priorityqueue.Queue[any])

type QueryVectorDistancer added in v1.26.0

type QueryVectorDistancer struct {
	DistanceFunc func(uint64) (float32, error)
	CloseFunc    func()
}

func (*QueryVectorDistancer) Close added in v1.26.0

func (q *QueryVectorDistancer) Close()

func (*QueryVectorDistancer) DistanceToNode added in v1.26.0

func (q *QueryVectorDistancer) DistanceToNode(nodeID uint64) (float32, error)

type SearchByDistParams

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

func NewSearchByDistParams

func NewSearchByDistParams(
	offset int,
	limit int,
	totalLimit int,
	maximumSearchLimit int64,
) *SearchByDistParams

func (*SearchByDistParams) Iterate

func (params *SearchByDistParams) Iterate()

func (*SearchByDistParams) MaxLimitReached

func (params *SearchByDistParams) MaxLimitReached() bool

func (*SearchByDistParams) MaximumSearchLimit

func (params *SearchByDistParams) MaximumSearchLimit() int64

func (*SearchByDistParams) OffsetCapacity

func (params *SearchByDistParams) OffsetCapacity(ids []uint64) int

func (*SearchByDistParams) TotalLimit

func (params *SearchByDistParams) TotalLimit() int

func (*SearchByDistParams) TotalLimitCapacity

func (params *SearchByDistParams) TotalLimitCapacity(ids []uint64) int

type ShardedLocks

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

func NewDefaultShardedLocks

func NewDefaultShardedLocks() *ShardedLocks

func NewShardedLocks

func NewShardedLocks(count uint64) *ShardedLocks

func (*ShardedLocks) Lock

func (sl *ShardedLocks) Lock(id uint64)

func (*ShardedLocks) LockAll

func (sl *ShardedLocks) LockAll()

func (*ShardedLocks) Locked

func (sl *ShardedLocks) Locked(id uint64, callback func())

func (*ShardedLocks) LockedAll

func (sl *ShardedLocks) LockedAll(callback func())

func (*ShardedLocks) Unlock

func (sl *ShardedLocks) Unlock(id uint64)

func (*ShardedLocks) UnlockAll

func (sl *ShardedLocks) UnlockAll()

type ShardedRWLocks added in v1.24.0

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

func NewDefaultShardedRWLocks added in v1.24.0

func NewDefaultShardedRWLocks() *ShardedRWLocks

func NewShardedRWLocks added in v1.24.0

func NewShardedRWLocks(count uint64) *ShardedRWLocks

func (*ShardedRWLocks) Lock added in v1.24.0

func (sl *ShardedRWLocks) Lock(id uint64)

func (*ShardedRWLocks) LockAll added in v1.24.0

func (sl *ShardedRWLocks) LockAll()

func (*ShardedRWLocks) Locked added in v1.24.0

func (sl *ShardedRWLocks) Locked(id uint64, callback func())

func (*ShardedRWLocks) LockedAll added in v1.24.0

func (sl *ShardedRWLocks) LockedAll(callback func())

func (*ShardedRWLocks) RLock added in v1.24.0

func (sl *ShardedRWLocks) RLock(id uint64)

func (*ShardedRWLocks) RLockAll added in v1.24.0

func (sl *ShardedRWLocks) RLockAll()

func (*ShardedRWLocks) RLocked added in v1.24.0

func (sl *ShardedRWLocks) RLocked(id uint64, callback func())

func (*ShardedRWLocks) RLockedAll added in v1.24.0

func (sl *ShardedRWLocks) RLockedAll(callback func())

func (*ShardedRWLocks) RUnlock added in v1.24.0

func (sl *ShardedRWLocks) RUnlock(id uint64)

func (*ShardedRWLocks) RUnlockAll added in v1.24.0

func (sl *ShardedRWLocks) RUnlockAll()

func (*ShardedRWLocks) Unlock added in v1.24.0

func (sl *ShardedRWLocks) Unlock(id uint64)

func (*ShardedRWLocks) UnlockAll added in v1.24.0

func (sl *ShardedRWLocks) UnlockAll()

type SharedGauge added in v1.24.22

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

SharedGauge is a thread-safe gauge that can be shared between multiple goroutines. It is used to track the number of running tasks, and allows to wait until all tasks are done.

func NewSharedGauge added in v1.24.22

func NewSharedGauge() *SharedGauge

func (*SharedGauge) Count added in v1.24.22

func (sc *SharedGauge) Count() int64

func (*SharedGauge) Decr added in v1.24.22

func (sc *SharedGauge) Decr()

func (*SharedGauge) Incr added in v1.24.22

func (sc *SharedGauge) Incr()

func (*SharedGauge) Wait added in v1.24.22

func (sc *SharedGauge) Wait()

type SparseFisherYatesIterator added in v1.27.0

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

SparseFisherYatesIterator implements the Iterator interface using the Sparse Fisher-Yates algorithm.

func NewSparseFisherYatesIterator added in v1.27.0

func NewSparseFisherYatesIterator(size int) *SparseFisherYatesIterator

NewSparseFisherYatesIterator creates a new SparseFisherYatesIterator with the given size.

func (*SparseFisherYatesIterator) IsDone added in v1.27.0

func (s *SparseFisherYatesIterator) IsDone() bool

IsDone checks if all elements have been sampled.

func (*SparseFisherYatesIterator) Next added in v1.27.0

func (s *SparseFisherYatesIterator) Next() *int

Next returns the next sampled index using the Sparse Fisher-Yates algorithm.

type TargetTempVectorForID added in v1.24.11

type TargetTempVectorForID struct {
	TargetVector         string
	TempVectorForIDThunk func(ctx context.Context, id uint64, container *VectorSlice, targetVector string) ([]float32, error)
}

func (TargetTempVectorForID) TempVectorForID added in v1.24.11

func (t TargetTempVectorForID) TempVectorForID(ctx context.Context, id uint64, container *VectorSlice) ([]float32, error)

type TargetVectorForID added in v1.24.11

type TargetVectorForID[T float32 | byte | uint64] struct {
	TargetVector     string
	VectorForIDThunk func(ctx context.Context, id uint64, targetVector string) ([]T, error)
}

func (TargetVectorForID[T]) VectorForID added in v1.24.11

func (t TargetVectorForID[T]) VectorForID(ctx context.Context, id uint64) ([]T, error)

type TempVectorForID

type TempVectorForID func(ctx context.Context, id uint64, container *VectorSlice) ([]float32, error)

type TempVectorUint64Pool added in v1.27.0

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

func NewTempUint64VectorsPool added in v1.27.0

func NewTempUint64VectorsPool() *TempVectorUint64Pool

func (*TempVectorUint64Pool) Get added in v1.27.0

func (pool *TempVectorUint64Pool) Get(capacity int) *VectorUint64Slice

func (*TempVectorUint64Pool) Put added in v1.27.0

func (pool *TempVectorUint64Pool) Put(container *VectorUint64Slice)

type TempVectorsPool

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

func NewTempVectorsPool

func NewTempVectorsPool() *TempVectorsPool

func (*TempVectorsPool) Get

func (pool *TempVectorsPool) Get(capacity int) *VectorSlice

func (*TempVectorsPool) Put

func (pool *TempVectorsPool) Put(container *VectorSlice)

type VectorForID

type VectorForID[T float32 | byte | uint64] func(ctx context.Context, id uint64) ([]T, error)

type VectorSlice

type VectorSlice struct {
	Slice []float32
	Mem   []float32
	Buff8 []byte
	Buff  []byte
}

type VectorUint64Slice added in v1.27.0

type VectorUint64Slice struct {
	Slice []uint64
}

Jump to

Keyboard shortcuts

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