Documentation
¶
Overview ¶
Package scio provides a URI-based data catalog with atomic operations. It serves as the authoritative map of data sources, providing topology intelligence and type-agnostic access via atoms.
Index ¶
- Variables
- type Catalog
- type IndexOperations
- type Metadata
- type Operations
- type RegistrationOption
- type Registry
- type Resource
- type Scio
- func (s *Scio) Buckets() []Resource
- func (s *Scio) Databases() []Resource
- func (s *Scio) Delete(ctx context.Context, uri string) error
- func (s *Scio) DeleteDocument(ctx context.Context, uri string) error
- func (s *Scio) DeleteVector(ctx context.Context, uri string) error
- func (s *Scio) DocumentExists(ctx context.Context, uri string) (bool, error)
- func (s *Scio) Exists(ctx context.Context, uri string) (bool, error)
- func (s *Scio) FilterVectors(ctx context.Context, uri string, filter *vecna.Filter, limit int) ([]grub.AtomicVector, error)
- func (s *Scio) FindByField(field string) []Resource
- func (s *Scio) FindBySpec(spec atom.Spec) []Resource
- func (s *Scio) Get(ctx context.Context, uri string) (*atom.Atom, error)
- func (s *Scio) GetDocument(ctx context.Context, uri string) (*grub.AtomicDocument, error)
- func (s *Scio) GetVector(ctx context.Context, uri string) (*grub.AtomicVector, error)
- func (s *Scio) IndexDocument(ctx context.Context, uri string, data *atom.Atom) error
- func (s *Scio) Indexes() []Resource
- func (s *Scio) Put(ctx context.Context, uri string, obj *grub.AtomicObject) error
- func (s *Scio) Query(ctx context.Context, uri string, stmt edamame.QueryStatement, ...) ([]*atom.Atom, error)
- func (s *Scio) QueryVectors(ctx context.Context, uri string, vector []float32, k int, filter *vecna.Filter) ([]grub.AtomicVector, error)
- func (s *Scio) RegisterBucket(uri string, bucket grub.AtomicBucket, opts ...RegistrationOption) error
- func (s *Scio) RegisterDatabase(uri string, db grub.AtomicDatabase, opts ...RegistrationOption) error
- func (s *Scio) RegisterIndex(uri string, index grub.AtomicIndex, opts ...RegistrationOption) error
- func (s *Scio) RegisterSearch(uri string, search grub.AtomicSearch, opts ...RegistrationOption) error
- func (s *Scio) RegisterStore(uri string, store grub.AtomicStore, opts ...RegistrationOption) error
- func (s *Scio) Related(uri string) []Resource
- func (s *Scio) Resource(uri string) *Resource
- func (s *Scio) SearchDocuments(ctx context.Context, uri string, search *lucene.Search) ([]grub.AtomicDocument, error)
- func (s *Scio) SearchVectors(ctx context.Context, uri string, vector []float32, k int, filter *atom.Atom) ([]grub.AtomicVector, error)
- func (s *Scio) Searches() []Resource
- func (s *Scio) Select(ctx context.Context, uri string, stmt edamame.SelectStatement, ...) (*atom.Atom, error)
- func (s *Scio) Set(ctx context.Context, uri string, data *atom.Atom) error
- func (s *Scio) SetWithTTL(ctx context.Context, uri string, data *atom.Atom, ttl time.Duration) error
- func (s *Scio) Sources() []Resource
- func (s *Scio) Spec(uri string) (atom.Spec, error)
- func (s *Scio) Stores() []Resource
- func (s *Scio) UpsertVector(ctx context.Context, uri string, vector []float32, metadata *atom.Atom) error
- func (s *Scio) VectorExists(ctx context.Context, uri string) (bool, error)
- type SearchOperations
- type URI
- type Variant
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidURI indicates the URI could not be parsed. ErrInvalidURI = errors.New("invalid URI") // ErrUnknownVariant indicates an unrecognized URI scheme. ErrUnknownVariant = errors.New("unknown variant") // ErrResourceNotFound indicates the requested resource is not registered. ErrResourceNotFound = errors.New("resource not found") // ErrResourceExists indicates a resource is already registered at the URI. ErrResourceExists = errors.New("resource already exists") // ErrVariantMismatch indicates an operation was attempted on the wrong variant. ErrVariantMismatch = errors.New("variant mismatch") // ErrKeyRequired indicates a key is required but was not provided. ErrKeyRequired = errors.New("key required") // ErrKeyNotExpected indicates a key was provided but is not used by the operation. ErrKeyNotExpected = errors.New("key not expected") // ErrInvalidUUID indicates the key could not be parsed as a UUID. ErrInvalidUUID = errors.New("invalid UUID") )
Semantic errors for scio operations.
var ( ErrNotFound = grub.ErrNotFound ErrDuplicate = grub.ErrDuplicate ErrConflict = grub.ErrConflict ErrConstraint = grub.ErrConstraint ErrInvalidKey = grub.ErrInvalidKey ErrReadOnly = grub.ErrReadOnly ErrTTLNotSupported = grub.ErrTTLNotSupported ErrInvalidQuery = grub.ErrInvalidQuery )
Re-export grub errors for convenience.
Functions ¶
This section is empty.
Types ¶
type Catalog ¶
type Catalog interface {
// Sources returns all registered resources.
Sources() []Resource
// Databases returns all db:// resources.
Databases() []Resource
// Stores returns all kv:// resources.
Stores() []Resource
// Buckets returns all bcs:// resources.
Buckets() []Resource
// Indexes returns all idx:// resources.
Indexes() []Resource
// Searches returns all srch:// resources.
Searches() []Resource
// Spec returns the atom spec for a specific resource.
Spec(uri string) (atom.Spec, error)
// FindBySpec returns all resources sharing the given spec (by FQDN).
FindBySpec(spec atom.Spec) []Resource
// FindByField returns all resources containing the given field.
FindByField(field string) []Resource
// Related returns other resources with the same spec as the given URI.
Related(uri string) []Resource
}
Catalog defines topology introspection operations.
type IndexOperations ¶
type IndexOperations interface {
// GetVector retrieves a vector at the given idx:// URI.
// The URI should include a UUID key component.
// Returns ErrNotFound if the ID does not exist.
GetVector(ctx context.Context, uri string) (*grub.AtomicVector, error)
// UpsertVector stores a vector with metadata at the given idx:// URI.
// The URI should include a UUID key component.
UpsertVector(ctx context.Context, uri string, vector []float32, metadata *atom.Atom) error
// DeleteVector removes the vector at the given idx:// URI.
// The URI should include a UUID key component.
// Returns ErrNotFound if the ID does not exist.
DeleteVector(ctx context.Context, uri string) error
// VectorExists checks whether a vector exists at the given idx:// URI.
// The URI should include a UUID key component.
VectorExists(ctx context.Context, uri string) (bool, error)
// SearchVectors performs similarity search against an idx:// resource.
// The URI should reference the index without a key component.
// Returns the k nearest neighbors, optionally filtered by metadata.
SearchVectors(ctx context.Context, uri string, vector []float32, k int, filter *atom.Atom) ([]grub.AtomicVector, error)
// QueryVectors performs similarity search with vecna filter support.
// The URI should reference the index without a key component.
QueryVectors(ctx context.Context, uri string, vector []float32, k int, filter *vecna.Filter) ([]grub.AtomicVector, error)
// FilterVectors returns vectors matching the metadata filter without similarity search.
// The URI should reference the index without a key component.
FilterVectors(ctx context.Context, uri string, filter *vecna.Filter, limit int) ([]grub.AtomicVector, error)
}
IndexOperations defines vector index access operations.
type Operations ¶
type Operations interface {
// Get retrieves an atom at the given URI.
// Returns ErrNotFound if the key does not exist.
Get(ctx context.Context, uri string) (*atom.Atom, error)
// Set stores an atom at the given URI.
Set(ctx context.Context, uri string, data *atom.Atom) error
// Delete removes the record at the given URI.
// Returns ErrNotFound if the key does not exist.
Delete(ctx context.Context, uri string) error
// Exists checks whether a record exists at the given URI.
Exists(ctx context.Context, uri string) (bool, error)
// Query executes a query statement against a database resource.
// The URI should reference a db:// resource without a key.
Query(ctx context.Context, uri string, stmt edamame.QueryStatement, params map[string]any) ([]*atom.Atom, error)
// Select executes a select statement against a database resource.
// The URI should reference a db:// resource without a key.
Select(ctx context.Context, uri string, stmt edamame.SelectStatement, params map[string]any) (*atom.Atom, error)
// SetWithTTL stores an atom at the given kv:// URI with a TTL.
// TTL of 0 means no expiration.
SetWithTTL(ctx context.Context, uri string, data *atom.Atom, ttl time.Duration) error
// Put stores a blob object at the given bcs:// URI.
Put(ctx context.Context, uri string, obj *grub.AtomicObject) error
}
Operations defines data access operations.
type RegistrationOption ¶
type RegistrationOption func(*registrationConfig)
RegistrationOption configures resource registration.
func WithDescription ¶
func WithDescription(desc string) RegistrationOption
WithDescription sets the resource description.
func WithTag ¶
func WithTag(key, value string) RegistrationOption
WithTag adds a tag to the resource metadata.
func WithVersion ¶
func WithVersion(ver string) RegistrationOption
WithVersion sets the resource version.
type Registry ¶
type Registry interface {
// RegisterDatabase registers an atomic database at the given URI.
// The URI should be in the form db://table.
RegisterDatabase(uri string, db grub.AtomicDatabase, opts ...RegistrationOption) error
// RegisterStore registers an atomic store at the given URI.
// The URI should be in the form kv://store.
RegisterStore(uri string, store grub.AtomicStore, opts ...RegistrationOption) error
// RegisterBucket registers an atomic bucket at the given URI.
// The URI should be in the form bcs://bucket.
RegisterBucket(uri string, bucket grub.AtomicBucket, opts ...RegistrationOption) error
// RegisterIndex registers an atomic index at the given URI.
// The URI should be in the form idx://index.
RegisterIndex(uri string, index grub.AtomicIndex, opts ...RegistrationOption) error
// RegisterSearch registers an atomic search at the given URI.
// The URI should be in the form srch://index.
RegisterSearch(uri string, search grub.AtomicSearch, opts ...RegistrationOption) error
}
Registry defines resource registration operations.
type Scio ¶
type Scio struct {
// contains filtered or unexported fields
}
Scio is the central data catalog and access point.
func (*Scio) Delete ¶
Delete removes the record at the given URI. Returns ErrNotFound if the key does not exist. Returns ErrResourceNotFound if the resource is not registered.
func (*Scio) DeleteDocument ¶
DeleteDocument removes the document at the given srch:// URI. The URI should include a document ID key component. Returns ErrNotFound if the ID does not exist. Returns ErrResourceNotFound if the resource is not registered.
func (*Scio) DeleteVector ¶
DeleteVector removes the vector at the given idx:// URI. The URI should include a UUID key component. Returns ErrNotFound if the ID does not exist. Returns ErrResourceNotFound if the resource is not registered.
func (*Scio) DocumentExists ¶
DocumentExists checks whether a document exists at the given srch:// URI. The URI should include a document ID key component. Returns ErrResourceNotFound if the resource is not registered.
func (*Scio) Exists ¶
Exists checks whether a record exists at the given URI. Returns ErrResourceNotFound if the resource is not registered.
func (*Scio) FilterVectors ¶
func (s *Scio) FilterVectors(ctx context.Context, uri string, filter *vecna.Filter, limit int) ([]grub.AtomicVector, error)
FilterVectors returns vectors matching the metadata filter without similarity search. The URI should reference the index without a key component. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyNotExpected if a key component is provided.
func (*Scio) FindByField ¶
FindByField returns all resources containing the given field.
func (*Scio) FindBySpec ¶
FindBySpec returns all resources sharing the given spec (by FQDN).
func (*Scio) Get ¶
Get retrieves an atom at the given URI. Returns ErrNotFound if the key does not exist. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyRequired if no key is provided.
func (*Scio) GetDocument ¶
GetDocument retrieves a document at the given srch:// URI. The URI should include a document ID key component. Returns ErrNotFound if the ID does not exist. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyRequired if no key is provided.
func (*Scio) GetVector ¶
GetVector retrieves a vector at the given idx:// URI. The URI should include a UUID key component. Returns ErrNotFound if the ID does not exist. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyRequired if no key is provided.
func (*Scio) IndexDocument ¶
IndexDocument stores a document with atomized content at the given srch:// URI. The URI should include a document ID key component. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyRequired if no key is provided.
func (*Scio) Put ¶
Put stores a blob object at the given bcs:// URI. Returns ErrVariantMismatch if the URI is not a bcs:// resource.
func (*Scio) Query ¶
func (s *Scio) Query(ctx context.Context, uri string, stmt edamame.QueryStatement, params map[string]any) ([]*atom.Atom, error)
Query executes a query statement against a database resource. The URI should reference a db:// resource without a key component. Returns ErrVariantMismatch if the URI is not a db:// resource. Returns ErrKeyNotExpected if a key component is provided.
func (*Scio) QueryVectors ¶
func (s *Scio) QueryVectors(ctx context.Context, uri string, vector []float32, k int, filter *vecna.Filter) ([]grub.AtomicVector, error)
QueryVectors performs similarity search with vecna filter support. The URI should reference the index without a key component. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyNotExpected if a key component is provided.
func (*Scio) RegisterBucket ¶
func (s *Scio) RegisterBucket(uri string, bucket grub.AtomicBucket, opts ...RegistrationOption) error
RegisterBucket registers an atomic bucket at the given URI. The URI should be in the form bcs://bucket.
func (*Scio) RegisterDatabase ¶
func (s *Scio) RegisterDatabase(uri string, db grub.AtomicDatabase, opts ...RegistrationOption) error
RegisterDatabase registers an atomic database at the given URI. The URI should be in the form db://table.
func (*Scio) RegisterIndex ¶
func (s *Scio) RegisterIndex(uri string, index grub.AtomicIndex, opts ...RegistrationOption) error
RegisterIndex registers an atomic index at the given URI. The URI should be in the form idx://index.
func (*Scio) RegisterSearch ¶
func (s *Scio) RegisterSearch(uri string, search grub.AtomicSearch, opts ...RegistrationOption) error
RegisterSearch registers an atomic search at the given URI. The URI should be in the form srch://index.
func (*Scio) RegisterStore ¶
func (s *Scio) RegisterStore(uri string, store grub.AtomicStore, opts ...RegistrationOption) error
RegisterStore registers an atomic store at the given URI. The URI should be in the form kv://store.
func (*Scio) Related ¶
Related returns other resources with the same spec as the given URI. The resource at the given URI is excluded from the results.
func (*Scio) Resource ¶
Resource returns the resource metadata for a specific URI. Returns nil if the resource is not registered.
func (*Scio) SearchDocuments ¶
func (s *Scio) SearchDocuments(ctx context.Context, uri string, search *lucene.Search) ([]grub.AtomicDocument, error)
SearchDocuments performs a full-text search against a srch:// resource. The URI should reference the search index without a key component. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyNotExpected if a key component is provided.
func (*Scio) SearchVectors ¶
func (s *Scio) SearchVectors(ctx context.Context, uri string, vector []float32, k int, filter *atom.Atom) ([]grub.AtomicVector, error)
SearchVectors performs similarity search against an idx:// resource. The URI should reference the index without a key component. Returns the k nearest neighbors, optionally filtered by metadata. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyNotExpected if a key component is provided.
func (*Scio) Select ¶
func (s *Scio) Select(ctx context.Context, uri string, stmt edamame.SelectStatement, params map[string]any) (*atom.Atom, error)
Select executes a select statement against a database resource. The URI should reference a db:// resource without a key component. Returns ErrVariantMismatch if the URI is not a db:// resource. Returns ErrKeyNotExpected if a key component is provided.
func (*Scio) Set ¶
Set stores an atom at the given URI. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyRequired if no key is provided. For kv:// resources, use SetWithTTL to specify expiration.
func (*Scio) SetWithTTL ¶
func (s *Scio) SetWithTTL(ctx context.Context, uri string, data *atom.Atom, ttl time.Duration) error
SetWithTTL stores an atom at the given kv:// URI with a TTL. TTL of 0 means no expiration. Returns ErrVariantMismatch if the URI is not a kv:// resource.
func (*Scio) Spec ¶
Spec returns the atom spec for a specific resource. Returns ErrResourceNotFound if the resource is not registered.
func (*Scio) UpsertVector ¶
func (s *Scio) UpsertVector(ctx context.Context, uri string, vector []float32, metadata *atom.Atom) error
UpsertVector stores a vector with metadata at the given idx:// URI. The URI should include a UUID key component. Returns ErrResourceNotFound if the resource is not registered. Returns ErrKeyRequired if no key is provided.
type SearchOperations ¶
type SearchOperations interface {
// GetDocument retrieves a document at the given srch:// URI.
// The URI should include a document ID key component.
// Returns ErrNotFound if the ID does not exist.
GetDocument(ctx context.Context, uri string) (*grub.AtomicDocument, error)
// IndexDocument stores a document with atomized content at the given srch:// URI.
// The URI should include a document ID key component.
IndexDocument(ctx context.Context, uri string, data *atom.Atom) error
// DeleteDocument removes the document at the given srch:// URI.
// The URI should include a document ID key component.
// Returns ErrNotFound if the ID does not exist.
DeleteDocument(ctx context.Context, uri string) error
// DocumentExists checks whether a document exists at the given srch:// URI.
// The URI should include a document ID key component.
DocumentExists(ctx context.Context, uri string) (bool, error)
// SearchDocuments performs a full-text search against a srch:// resource.
// The URI should reference the search index without a key component.
SearchDocuments(ctx context.Context, uri string, search *lucene.Search) ([]grub.AtomicDocument, error)
}
SearchOperations defines full-text search access operations.
type URI ¶
type URI struct {
Variant Variant
Resource string // table, store, or bucket name
Key string // record key or blob path (may be empty for queries)
}
URI represents a parsed data address.
func ParseURI ¶
ParseURI parses a raw URI string into its components. Supported formats:
- db://table/key -> Variant: db, Resource: table, Key: key
- kv://store/key -> Variant: kv, Resource: store, Key: key
- bcs://bucket/path -> Variant: bcs, Resource: bucket, Key: path (full remainder)
func (*URI) ResourceURI ¶
ResourceURI returns the URI without the key component.
type Variant ¶
type Variant string
Variant represents a storage type.
const ( // VariantDatabase represents SQL database storage (db://). VariantDatabase Variant = "db" // VariantStore represents key-value storage (kv://). VariantStore Variant = "kv" // VariantBucket represents blob/object storage (bcs://). VariantBucket Variant = "bcs" // VariantIndex represents vector index storage (idx://). VariantIndex Variant = "idx" // VariantSearch represents full-text search storage (srch://). VariantSearch Variant = "srch" )