cassandra

package module
v0.61.0 Latest Latest
Warning

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

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

Documentation

Overview

Package cassandra stores precomputed vectors in an exclusively owned Cassandra table. NewStore verifies its Paxos protocol and SpaceID binding in the table comment, native vector<float,N> width and single-column primary key. Set InitializeSchema and CreateDimensions to provision a new bound table; the constructor never changes a pre-existing table's space.

All document mutations use QUORUM commits, SERIAL Paxos and server timestamps. Ordinary CQL writes cannot share this table: a future client timestamp can override a conditional deletion even when Cassandra reports it applied. Tables written by the former ordinary-write protocol are rejected by their native table binding and must be recreated. Changing that marker alone cannot repair old timestamp history or authorize ordinary writes to a current table.

Upsert validates every input and native metric before the first mutation. A row is inserted conditionally or replaced conditionally if already present. Deletion between these proposals is a known rejection; the adapter never retries to resurrect it. WriteError retains the acknowledged prefix, rejected or uncertain row, and unattempted suffix.

This schema has no vector index. QueryByScan and DeleteMatching require an explicit record, byte and time grant. The scan charges every observed row, including nonmatches, for its ID, content, original metadata JSON and float32 vector. It decodes exact metadata, applies Core filter semantics before scoring and emits no partial top-K. Cassandra has no collection snapshot. Conditional deletion compares the captured columns and cannot delete a replacement. DeleteIDs does not scan, and a missing identity is an idempotent success. The host owns its session and retry policy.

Index

Constants

View Source
const (
	DefaultKeyspaceName    = "scope"
	DefaultTableName       = "vector_store"
	DefaultIDColumn        = "id"
	DefaultContentColumn   = "content"
	DefaultMetadataColumn  = "metadata"
	DefaultEmbeddingColumn = "embedding"
	DefaultSimilarity      = SimilarityCosine
)
View Source
const Provider = "Cassandra"

Variables

This section is empty.

Functions

This section is empty.

Types

type Session added in v0.43.0

type Session interface {
	Query(string, ...any) *gocql.Query
}

Session supplies native queries. The host owns the Apache driver's session.

type SimilarityFunction

type SimilarityFunction string

SimilarityFunction selects a native Cassandra scalar function. No vector index participates in selecting or ranking Core matches.

const (
	SimilarityCosine     SimilarityFunction = "cosine"
	SimilarityDotProduct SimilarityFunction = "dot_product"
	SimilarityEuclidean  SimilarityFunction = "euclidean"
)

func (SimilarityFunction) String

func (s SimilarityFunction) String() string

func (SimilarityFunction) Valid

func (s SimilarityFunction) Valid() bool

type Store

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

Store uses Core JSON and filter semantics, native vector codecs and scalar similarities, and one Paxos protocol for every document mutation. Conditional deletion protects the exact rows observed by a scan.

func NewStore

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

func (*Store) DeleteIDs

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

func (*Store) DeleteMatching added in v0.59.0

func (s *Store) DeleteMatching(ctx context.Context, predicate filter.Predicate, budget vectorstore.ScanBudget) error

func (*Store) QueryByScan added in v0.60.0

func (s *Store) QueryByScan(ctx context.Context, request *vectorstore.Query, budget vectorstore.ScanBudget) (response *vectorstore.SearchResponse, err error)

func (*Store) Upsert added in v0.59.0

func (s *Store) Upsert(ctx context.Context, request *vectorstore.Batch) error

type StoreConfig

type StoreConfig struct {
	Session         Session
	KeyspaceName    string
	TableName       string
	IDColumn        string
	ContentColumn   string
	EmbeddingColumn string
	MetadataColumn  string
	Space           vectorstore.SpaceID
	Similarity      SimilarityFunction
	// CreateDimensions seeds a new vector column when InitializeSchema is true.
	// Existing native schema always owns the width used by operations.
	CreateDimensions int
	// InitializeSchema creates only the keyspace and four-column table. Every
	// constructor verifies the actual native column types and primary key.
	InitializeSchema bool
	// KeyspaceReplication is the trusted CQL replication clause for creation.
	// Empty creates a single-replica SimpleStrategy keyspace.
	KeyspaceReplication string
}

StoreConfig selects an exclusively owned table whose document mutations all use this adapter's Paxos protocol. Its native binding rejects the former ordinary-write protocol; those tables must be recreated, because their timestamps can override conditional mutations. Empty names use exported defaults. Session and Space are required.

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