vectorspace

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package vectorspace defines the per-database vector space identity and registry.

A vector space is uniquely identified by:

  • database name
  • type/collection name
  • vectorName (named vectors or the special "chunks" space)
  • dimensions
  • distance metric

The registry is intentionally lightweight; it tracks which vector spaces exist and which backend each space should use. Future PRs will attach the actual indexing implementations and counters.

Index

Constants

View Source
const ChunkVectorName = "chunks"

ChunkVectorName is reserved for chunk-level vector search.

View Source
const DefaultVectorName = "default"

DefaultVectorName is the canonical name for unnamed vector spaces.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackendKind

type BackendKind string

BackendKind identifies the indexing backend assigned to a vector space.

const (
	BackendAuto       BackendKind = "auto"
	BackendBruteForce BackendKind = "brute-force"
	BackendHNSW       BackendKind = "hnsw"
)

Known backend identifiers. The registry does not enforce the set strictly to allow experimentation while keeping canonical casing.

type DistanceMetric

type DistanceMetric string

DistanceMetric enumerates supported vector distance metrics.

const (
	DistanceCosine    DistanceMetric = "cosine"
	DistanceDot       DistanceMetric = "dot"
	DistanceEuclidean DistanceMetric = "euclidean"
)

Supported distance metrics for vector search.

type IndexRegistry

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

IndexRegistry tracks vector spaces per database.

func NewIndexRegistry

func NewIndexRegistry() *IndexRegistry

NewIndexRegistry creates an empty registry.

func (*IndexRegistry) CreateSpace

func (r *IndexRegistry) CreateSpace(key VectorSpaceKey, backend BackendKind) (*VectorSpace, error)

CreateSpace registers a vector space or returns the existing one.

func (*IndexRegistry) DeleteSpace

func (r *IndexRegistry) DeleteSpace(key VectorSpaceKey) bool

DeleteSpace removes the space for the given key.

func (*IndexRegistry) GetSpace

func (r *IndexRegistry) GetSpace(key VectorSpaceKey) (*VectorSpace, bool)

GetSpace returns the space for the given key if it exists.

func (*IndexRegistry) Stats

func (r *IndexRegistry) Stats() []VectorSpaceStats

Stats returns a snapshot of all registered spaces.

type VectorSpace

type VectorSpace struct {
	Key     VectorSpaceKey
	Backend BackendKind
	// contains filtered or unexported fields
}

VectorSpace represents a registered vector space and its chosen backend.

func (*VectorSpace) IncrementVectorCount

func (vs *VectorSpace) IncrementVectorCount(delta int64) int64

IncrementVectorCount adjusts the tracked vector count and returns the new value.

func (*VectorSpace) SetVectorCount

func (vs *VectorSpace) SetVectorCount(count int64)

SetVectorCount updates the tracked vector count for this space.

type VectorSpaceKey

type VectorSpaceKey struct {
	DB         string
	Type       string
	VectorName string
	Dims       int
	Distance   DistanceMetric
}

VectorSpaceKey uniquely identifies a vector space.

func (VectorSpaceKey) Canonical

func (k VectorSpaceKey) Canonical() (VectorSpaceKey, error)

Canonical returns a normalized copy of the key:

  • trims whitespace
  • lowercases identifiers
  • defaults vectorName to "default" when empty
  • defaults distance to cosine when empty
  • validates dimensions > 0 and distance support

func (VectorSpaceKey) Hash

func (k VectorSpaceKey) Hash() (string, error)

Hash returns the canonical string representation used for registry lookups.

type VectorSpaceStats

type VectorSpaceStats struct {
	Key         VectorSpaceKey
	KeyHash     string
	Dimensions  int
	Distance    DistanceMetric
	Backend     BackendKind
	VectorCount int64
}

VectorSpaceStats captures introspection data for a vector space.

Jump to

Keyboard shortcuts

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