db

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("object not found")
View Source
var ErrObjectNotFound = errors.New("object not found")
View Source
var ErrVectorNotFound = errors.New("vector not found")

Functions

This section is empty.

Types

type DistributedStorage added in v1.0.11

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

func NewDistributedStorage added in v1.0.11

func NewDistributedStorage(nodeAddresses []string) (*DistributedStorage, error)

func (*DistributedStorage) Close added in v1.0.11

func (ds *DistributedStorage) Close() error

func (*DistributedStorage) DeleteObject added in v1.0.12

func (ds *DistributedStorage) DeleteObject(id string) error

func (*DistributedStorage) DeleteVector added in v1.0.12

func (ds *DistributedStorage) DeleteVector(id string) error

func (*DistributedStorage) GetAllObjects added in v1.0.12

func (ds *DistributedStorage) GetAllObjects() ([]*Object, error)

func (*DistributedStorage) GetAllVectors added in v1.0.12

func (ds *DistributedStorage) GetAllVectors() ([]*Vector, error)

func (*DistributedStorage) GetObject added in v1.0.12

func (ds *DistributedStorage) GetObject(id string) (*Object, error)

func (*DistributedStorage) GetVector added in v1.0.12

func (ds *DistributedStorage) GetVector(id string) (*Vector, error)

func (*DistributedStorage) InsertObject added in v1.0.12

func (ds *DistributedStorage) InsertObject(object *Object) error

func (*DistributedStorage) InsertVector added in v1.0.12

func (ds *DistributedStorage) InsertVector(vector *Vector) error

func (*DistributedStorage) UpdateObjectMetadata added in v1.0.12

func (ds *DistributedStorage) UpdateObjectMetadata(id string, metadata map[string]string) error

func (*DistributedStorage) UpdateVectorMetadata added in v1.0.12

func (ds *DistributedStorage) UpdateVectorMetadata(id string, metadata map[string]string) error

type Object added in v1.0.12

type Object struct {
	ID       string            `json:"id"`
	Object   []byte            `json:"object"`
	Metadata map[string]string `json:"metadata"`
}

type QuantizationParams added in v1.0.5

type QuantizationParams struct {
	Min  float64
	Max  float64
	Bits int
}

func (QuantizationParams) Dequantize added in v1.0.5

func (p QuantizationParams) Dequantize(value float64) float64

func (QuantizationParams) Quantize added in v1.0.5

func (p QuantizationParams) Quantize(value float64) float64

type Storage

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

func NewStorage

func NewStorage(dbPath string) (*Storage, error)

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) DeleteObject added in v1.0.12

func (s *Storage) DeleteObject(id string) error

func (*Storage) DeleteVector added in v1.0.12

func (s *Storage) DeleteVector(id string) error

func (*Storage) GetAllObjects added in v1.0.12

func (s *Storage) GetAllObjects() ([]*Object, error)

func (*Storage) GetAllVectors added in v1.0.12

func (s *Storage) GetAllVectors() ([]*Vector, error)

func (*Storage) GetObject added in v1.0.12

func (s *Storage) GetObject(id string) (*Object, error)

func (*Storage) GetVector added in v1.0.12

func (s *Storage) GetVector(id string) (*Vector, error)

func (*Storage) InsertObject added in v1.0.12

func (s *Storage) InsertObject(object *Object) error

func (*Storage) InsertVector added in v1.0.12

func (s *Storage) InsertVector(vector *Vector) error

func (*Storage) UpdateObjectMetadata added in v1.0.12

func (s *Storage) UpdateObjectMetadata(id string, metadata map[string]string) error

func (*Storage) UpdateVectorMetadata added in v1.0.12

func (s *Storage) UpdateVectorMetadata(id string, metadata map[string]string) error

type Vector

type Vector struct {
	ID                 string
	Embedding          []float64
	Metadata           map[string]string
	Text               string
	Object             []byte
	Compressed         bool
	QuantizationParams *QuantizationParams
	PruningMask        []bool
	SparseIndices      []int
}

func (*Vector) Add

func (v *Vector) Add(other Vector) error

func (Vector) Distance

func (v Vector) Distance(other Vector) (float64, error)

func (*Vector) Normalize

func (v *Vector) Normalize()

func (*Vector) Prune added in v1.0.5

func (v *Vector) Prune(threshold float64)

func (*Vector) Quantize added in v1.0.5

func (v *Vector) Quantize(params QuantizationParams)

func (*Vector) Subtract

func (v *Vector) Subtract(other Vector) error

func (*Vector) ToSparse added in v1.0.5

func (v *Vector) ToSparse()

Jump to

Keyboard shortcuts

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