objects

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

package objects provides managers for all kind-related items, such as objects. Manager provides methods for "regular" interaction, such as add, get, delete, update, etc. Additionally BatchManager allows for efficient batch-adding of object instances and references.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchManager

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

BatchManager manages kind changes in batch at a use-case level , i.e. agnostic of underlying databases or storage providers

func NewBatchManager

func NewBatchManager(vectorRepo BatchVectorRepo, vectorizer VectorizerProvider,
	locks locks, schemaManager schemaManager, config *config.WeaviateConfig,
	logger logrus.FieldLogger, authorizer authorizer) *BatchManager

NewBatchManager creates a new manager

func (*BatchManager) AddObjects

func (b *BatchManager) AddObjects(ctx context.Context, principal *models.Principal,
	objects []*models.Object, fields []*string) (BatchObjects, error)

AddObjects Class Instances in batch to the connected DB

func (*BatchManager) AddReferences

func (b *BatchManager) AddReferences(ctx context.Context, principal *models.Principal,
	refs []*models.BatchReference) (BatchReferences, error)

AddReferences Class Instances in batch to the connected DB

type BatchObject

type BatchObject struct {
	OriginalIndex int
	Err           error
	Object        *models.Object
	UUID          strfmt.UUID
	Vector        []float32
}

BatchObject is a helper type that groups all the info about one object in a batch that belongs together, i.e. uuid, object body and error state.

Consumers of an Object (i.e. database connector) should always check whether an error is already present by the time they receive a batch object. Errors can be introduced at all levels, e.g. validation.

However, error'd objects are not removed to make sure that the list in Objects matches the order and content of the incoming batch request

type BatchObjects

type BatchObjects []BatchObject

BatchObjects groups many Object items together. The order matches the order from the original request. It can be turned into the expected response type using the .Response() method

type BatchReference

type BatchReference struct {
	OriginalIndex int
	Err           error
	From          *crossref.RefSource
	To            *crossref.Ref
}

BatchReference is a helper type that groups all the info about one references in a batch that belongs together, i.e. from, to, original index and error state

Consumers of an Object (i.e. database connector) should always check whether an error is already present by the time they receive a batch object. Errors can be introduced at all levels, e.g. validation.

However, error'd objects are not removed to make sure that the list in Objects matches the order and content of the incoming batch request

type BatchReferences

type BatchReferences []BatchReference

BatchReferences groups many Reference items together. The order matches the order from the original request. It can be turned into the expected response type using the .Response() method

type BatchVectorRepo

type BatchVectorRepo interface {
	VectorRepo
	// contains filtered or unexported methods
}

type ErrInternal

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

ErrInternal indicates something went wrong during processing

func NewErrInternal

func NewErrInternal(format string, args ...interface{}) ErrInternal

NewErrInternal with Errorf signature

func (ErrInternal) Error

func (e ErrInternal) Error() string

type ErrInvalidUserInput

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

ErrInvalidUserInput indicates a client-side error

func NewErrInvalidUserInput

func NewErrInvalidUserInput(format string, args ...interface{}) ErrInvalidUserInput

NewErrInvalidUserInput with Errorf signature

func (ErrInvalidUserInput) Error

func (e ErrInvalidUserInput) Error() string

type ErrNotFound

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

ErrNotFound indicates the desired resource doesn't exist

func NewErrNotFound

func NewErrNotFound(format string, args ...interface{}) ErrNotFound

NewErrNotFound with Errorf signature

func (ErrNotFound) Error

func (e ErrNotFound) Error() string

type Manager

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

Manager manages kind changes at a use-case level, i.e. agnostic of underlying databases or storage providers

func NewManager

func NewManager(locks locks, schemaManager schemaManager,
	config *config.WeaviateConfig, logger logrus.FieldLogger,
	authorizer authorizer, vectorizer VectorizerProvider, vectorRepo VectorRepo,
	modulesProvider ModulesProvider) *Manager

NewManager creates a new manager

func (*Manager) AddObject

func (m *Manager) AddObject(ctx context.Context, principal *models.Principal,
	object *models.Object) (*models.Object, error)

AddObject Class Instance to the connected DB. If the class contains a network ref, it has a side-effect on the schema: The schema will be updated to include this particular network ref class.

func (*Manager) AddObjectReference

func (m *Manager) AddObjectReference(ctx context.Context, principal *models.Principal,
	id strfmt.UUID, propertyName string, property *models.SingleRef) error

AddObjectReference Class Instance to the connected DB. If the class contains a network ref, it has a side-effect on the schema: The schema will be updated to include this particular network ref class.

func (*Manager) DeleteObject

func (m *Manager) DeleteObject(ctx context.Context, principal *models.Principal, id strfmt.UUID) error

DeleteObject Class Instance from the conncected DB

func (*Manager) DeleteObjectReference

func (m *Manager) DeleteObjectReference(ctx context.Context, principal *models.Principal,
	id strfmt.UUID, propertyName string, property *models.SingleRef) error

DeleteObjectReference from connected DB

func (*Manager) GetObject

func (m *Manager) GetObject(ctx context.Context, principal *models.Principal,
	id strfmt.UUID, additional traverser.AdditionalProperties) (*models.Object, error)

GetObject Class from the connected DB

func (*Manager) GetObjects

func (m *Manager) GetObjects(ctx context.Context, principal *models.Principal,
	limit *int64, additional traverser.AdditionalProperties) ([]*models.Object, error)

GetObjects Class from the connected DB

func (*Manager) MergeObject

func (m *Manager) MergeObject(ctx context.Context, principal *models.Principal,
	id strfmt.UUID, updated *models.Object) error

func (*Manager) UpdateObject

func (m *Manager) UpdateObject(ctx context.Context, principal *models.Principal, id strfmt.UUID,
	class *models.Object) (*models.Object, error)

UpdateObject Class Instance to the connected DB. If the class contains a network ref, it has a side-effect on the schema: The schema will be updated to include this particular network ref class.

func (*Manager) UpdateObjectReferences

func (m *Manager) UpdateObjectReferences(ctx context.Context, principal *models.Principal,
	id strfmt.UUID, propertyName string, refs models.MultipleRef) error

UpdateObjectReferences Class Instance to the connected DB. If the class contains a network ref, it has a side-effect on the schema: The schema will be updated to include this particular network ref class.

func (*Manager) ValidateObject

func (m *Manager) ValidateObject(ctx context.Context, principal *models.Principal,
	class *models.Object) error

ValidateObject without adding it to the database. Can be used in UIs for async validation before submitting

type MergeDocument

type MergeDocument struct {
	Class                string
	ID                   strfmt.UUID
	PrimitiveSchema      map[string]interface{}
	References           BatchReferences
	Vector               []float32
	UpdateTime           int64
	AdditionalProperties models.AdditionalProperties
}

type ModulesProvider added in v1.2.0

type ModulesProvider interface {
	GetObjectAdditionalExtend(ctx context.Context, in *search.Result,
		moduleParams map[string]interface{}) (*search.Result, error)
	ListObjectsAdditionalExtend(ctx context.Context, in search.Results,
		moduleParams map[string]interface{}) (search.Results, error)
}

type VectorRepo

type VectorRepo interface {
	PutObject(ctx context.Context, concept *models.Object, vector []float32) error
	DeleteObject(ctx context.Context, className string, id strfmt.UUID) error

	ObjectByID(ctx context.Context, id strfmt.UUID, props traverser.SelectProperties,
		additional traverser.AdditionalProperties) (*search.Result, error)
	ObjectSearch(ctx context.Context, limit int, filters *filters.LocalFilter,
		additional traverser.AdditionalProperties) (search.Results, error)

	Exists(ctx context.Context, id strfmt.UUID) (bool, error)

	AddReference(ctx context.Context, className string,
		source strfmt.UUID, propName string, ref *models.SingleRef) error
	Merge(ctx context.Context, merge MergeDocument) error
}

type Vectorizer

type Vectorizer interface {
	UpdateObject(ctx context.Context, obj *models.Object) error
}

type VectorizerProvider added in v1.2.0

type VectorizerProvider interface {
	Vectorizer(moduleName, className string) (Vectorizer, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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