cockroachdb

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package cockroachdb provides a native CockroachDB vector-store adapter over pgwire. It uses CockroachDB's built-in VECTOR type, pgvector-compatible distance operators, and native VECTOR INDEX declaration.

Requirements: CockroachDB v25.4 or later is recommended for generally available vector indexing. Schema initialization is explicit through StoreConfig.InitializeSchema.

Index

Constants

View Source
const (
	DefaultSchemaName     = "public"
	DefaultTableName      = "vector_store"
	DefaultMetadataColumn = "metadata"
	DefaultIndexSuffix    = "_embedding_idx"
)

Exported defaults keep constructor behavior visible and overridable.

View Source
const Provider = "CockroachDB"

Provider is the stable backend name for host-side attribution.

Variables

This section is empty.

Functions

This section is empty.

Types

type DistanceMetric

type DistanceMetric string

DistanceMetric selects both the pgvector-compatible query operator and the native CockroachDB vector-index opclass.

const (
	DistanceCosine DistanceMetric = "cosine"
	DistanceL2     DistanceMetric = "l2"
	DistanceIP     DistanceMetric = "ip"
)

The metric is a closed vocabulary because score direction and threshold semantics depend on it: the same raw number means "near" under one metric and "far" under another, so an unrecognized value must be rejected rather than guessed.

func (DistanceMetric) String

func (d DistanceMetric) String() string

func (DistanceMetric) Valid

func (d DistanceMetric) Valid() bool

type Store

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

Store implements vector-store capabilities with CockroachDB's native VECTOR type and vector indexes.

func NewStore

func NewStore(ctx context.Context, config StoreConfig) (*Store, error)

NewStore performs schema setup during construction, which is why it takes a context: a store returned before its backing schema exists would fail on the first index rather than at wiring, where the misconfiguration actually is.

func (*Store) DeleteIDs

func (s *Store) DeleteIDs(ctx context.Context, ids []string) error

func (*Store) DeleteWhere

func (s *Store) DeleteWhere(ctx context.Context, predicate filter.Predicate) error

func (*Store) Index

func (s *Store) Index(ctx context.Context, request *vectorstore.IndexRequest) error

func (*Store) Search

type StoreConfig

type StoreConfig struct {
	Pool             *pgxpool.Pool
	SchemaName       string
	TableName        string
	IndexName        string
	MetadataColumn   string
	EmbeddingModel   embedding.Model
	DocumentBatcher  vectorstore.Batcher
	Dimensions       int
	DistanceMetric   DistanceMetric
	InitializeSchema bool
}

StoreConfig names every dependency explicitly rather than defaulting a client or connection, so a store cannot be built against a service the caller did not choose.

func (StoreConfig) Validate

func (s StoreConfig) Validate() error

Jump to

Keyboard shortcuts

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