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
- type AddReferenceInput
- type BatchDeleteParams
- type BatchDeleteResponse
- type BatchDeleteResult
- type BatchManager
- func (b *BatchManager) AddObjects(ctx context.Context, principal *models.Principal, objects []*models.Object, ...) (BatchObjects, error)
- func (b *BatchManager) AddReferences(ctx context.Context, principal *models.Principal, ...) (BatchReferences, error)
- func (b *BatchManager) DeleteObjects(ctx context.Context, principal *models.Principal, ...) (*BatchDeleteResponse, error)
- func (b *BatchManager) DeleteObjectsFromGRPC(ctx context.Context, principal *models.Principal, params BatchDeleteParams, ...) (BatchDeleteResult, error)
- type BatchObject
- type BatchObjects
- type BatchReference
- type BatchReferences
- type BatchSimpleObject
- type BatchSimpleObjects
- type BatchVectorRepo
- type DeleteReferenceInput
- type ErrDirtyReadOfDeletedObject
- type ErrDirtyWriteOfDeletedObject
- type ErrInternal
- type ErrInvalidUserInput
- type ErrMultiTenancy
- type ErrNotFound
- type Error
- type Manager
- func (m *Manager) AddObject(ctx context.Context, principal *models.Principal, object *models.Object, ...) (*models.Object, error)
- func (m *Manager) AddObjectReference(ctx context.Context, principal *models.Principal, input *AddReferenceInput, ...) *Error
- func (m *Manager) DeleteObject(ctx context.Context, principal *models.Principal, class string, id strfmt.UUID, ...) error
- func (m *Manager) DeleteObjectReference(ctx context.Context, principal *models.Principal, input *DeleteReferenceInput, ...) *Error
- func (m *Manager) GetObject(ctx context.Context, principal *models.Principal, class string, id strfmt.UUID, ...) (*models.Object, error)
- func (m *Manager) GetObjectClassFromName(ctx context.Context, principal *models.Principal, className string) (*models.Class, error)
- func (m *Manager) GetObjects(ctx context.Context, principal *models.Principal, offset *int64, limit *int64, ...) ([]*models.Object, error)
- func (m *Manager) GetObjectsClass(ctx context.Context, principal *models.Principal, id strfmt.UUID) (*models.Class, error)
- func (m *Manager) HeadObject(ctx context.Context, principal *models.Principal, class string, id strfmt.UUID, ...) (bool, *Error)
- func (m *Manager) MergeObject(ctx context.Context, principal *models.Principal, updates *models.Object, ...) *Error
- func (m *Manager) Query(ctx context.Context, principal *models.Principal, params *QueryParams) ([]*models.Object, *Error)
- func (m *Manager) UpdateObject(ctx context.Context, principal *models.Principal, class string, id strfmt.UUID, ...) (*models.Object, error)
- func (m *Manager) UpdateObjectReferences(ctx context.Context, principal *models.Principal, input *PutReferenceInput, ...) *Error
- func (m *Manager) ValidateObject(ctx context.Context, principal *models.Principal, obj *models.Object, ...) error
- type MergeDocument
- type Metrics
- func (m *Metrics) AddObjectDec()
- func (m *Metrics) AddObjectInc()
- func (m *Metrics) AddReferenceDec()
- func (m *Metrics) AddReferenceInc()
- func (m *Metrics) AddUsageDimensions(className, queryType, operation string, dims int)
- func (m *Metrics) BatchDec()
- func (m *Metrics) BatchDeleteDec()
- func (m *Metrics) BatchDeleteInc()
- func (m *Metrics) BatchInc()
- func (m *Metrics) BatchObjects(objects int)
- func (m *Metrics) BatchOp(op string, startNs int64)
- func (m *Metrics) BatchRefDec()
- func (m *Metrics) BatchRefInc()
- func (m *Metrics) BatchTenants(tenants int)
- func (m *Metrics) DeleteObjectDec()
- func (m *Metrics) DeleteObjectInc()
- func (m *Metrics) DeleteReferenceDec()
- func (m *Metrics) DeleteReferenceInc()
- func (m *Metrics) GetObjectDec()
- func (m *Metrics) GetObjectInc()
- func (m *Metrics) HeadObjectDec()
- func (m *Metrics) HeadObjectInc()
- func (m *Metrics) MergeObjectDec()
- func (m *Metrics) MergeObjectInc()
- func (m *Metrics) UpdateObjectDec()
- func (m *Metrics) UpdateObjectInc()
- func (m *Metrics) UpdateReferenceDec()
- func (m *Metrics) UpdateReferenceInc()
- type ModulesProvider
- type PutReferenceInput
- type QueryInput
- type QueryParams
- type Replica
- type Replicas
- type VObject
- type VectorRepo
Constants ¶
const ( StatusForbidden = 403 StatusBadRequest = 400 StatusNotFound = 404 StatusUnprocessableEntity = 422 StatusInternalServerError = 500 )
objects status code
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddReferenceInput ¶
type AddReferenceInput struct { // Class name Class string // ID of an object ID strfmt.UUID // Property name Property string // Ref cross reference Ref models.SingleRef }
AddReferenceInput represents required inputs to add a reference to an existing object.
type BatchDeleteParams ¶
type BatchDeleteResponse ¶
type BatchDeleteResponse struct { Match *models.BatchDeleteMatch DryRun bool Output string Params BatchDeleteParams Result BatchDeleteResult }
type BatchDeleteResult ¶
type BatchDeleteResult struct { Matches int64 Limit int64 DryRun bool Objects BatchSimpleObjects }
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, modulesProvider ModulesProvider, locks locks, schemaManager schemaManager, config *config.WeaviateConfig, logger logrus.FieldLogger, authorizer authorizer, prom *monitoring.PrometheusMetrics, ) *BatchManager
NewBatchManager creates a new manager
func (*BatchManager) AddObjects ¶
func (b *BatchManager) AddObjects(ctx context.Context, principal *models.Principal, objects []*models.Object, fields []*string, repl *additional.ReplicationProperties, ) (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, repl *additional.ReplicationProperties, ) (BatchReferences, error)
AddReferences Class Instances in batch to the connected DB
func (*BatchManager) DeleteObjects ¶
func (b *BatchManager) DeleteObjects(ctx context.Context, principal *models.Principal, match *models.BatchDeleteMatch, dryRun *bool, output *string, repl *additional.ReplicationProperties, tenant string, ) (*BatchDeleteResponse, error)
DeleteObjects deletes objects in batch based on the match filter
func (*BatchManager) DeleteObjectsFromGRPC ¶ added in v1.23.3
func (b *BatchManager) DeleteObjectsFromGRPC(ctx context.Context, principal *models.Principal, params BatchDeleteParams, repl *additional.ReplicationProperties, tenant string, ) (BatchDeleteResult, error)
DeleteObjectsFromGRPC deletes objects in batch based on the match filter
type BatchObject ¶
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 `json:"originalIndex"` Err error `json:"err"` From *crossref.RefSource `json:"from"` To *crossref.Ref `json:"to"` Tenant string `json:"tenant"` }
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 BatchSimpleObject ¶
type BatchSimpleObjects ¶
type BatchSimpleObjects []BatchSimpleObject
type BatchVectorRepo ¶
type BatchVectorRepo interface { VectorRepo // contains filtered or unexported methods }
type DeleteReferenceInput ¶
type DeleteReferenceInput struct { // Class name Class string // ID of an object ID strfmt.UUID // Property name Property string // Reference cross reference Reference models.SingleRef }
DeleteReferenceInput represents required inputs to delete a reference from an existing object.
type ErrDirtyReadOfDeletedObject ¶ added in v1.24.22
type ErrDirtyReadOfDeletedObject struct {
// contains filtered or unexported fields
}
This error is thrown by the replication logic when an object has either:
1. been deleted locally but exists remotely
2. been deleted remotely but exists locally
signifying that the current operation is happening simultaneously to another operation on the same replicated resource.
This error is used to bubble up the error from the replication logic so that it can be handled depending on the context of the higher level operation.
This was introduced originally to handle cases where concurrent delete_many and single_patch operations were happening on the same object across multiple replicas. The read repair of the patch method would fail with a 500 conflict error if the delete operation was not propagated to all replicas before the patch operation was attempted. By using this error and handling it in func (m *Manager) MergeObject, any patch updates will assume that the object has been deleted everywhere, despite it only being deleted in one place, and will therefore return a 404 not found error.
func NewErrDirtyReadOfDeletedObject ¶ added in v1.24.22
func NewErrDirtyReadOfDeletedObject(err error) ErrDirtyReadOfDeletedObject
It depends on the order of operations
Created -> Deleted => It is safe in this case to propagate deletion to all replicas Created -> Deleted -> Created => propagating deletion will result in data lost
Updated -> Deleted => It is safe in this case to propagate deletion to all replicas Updated -> Deleted -> Updated => It is also safe in this case since updating a deleted object makes no logical sense
func (ErrDirtyReadOfDeletedObject) Error ¶ added in v1.24.22
func (e ErrDirtyReadOfDeletedObject) Error() string
func (ErrDirtyReadOfDeletedObject) Unwrap ¶ added in v1.24.22
func (e ErrDirtyReadOfDeletedObject) Unwrap() error
type ErrDirtyWriteOfDeletedObject ¶ added in v1.24.22
type ErrDirtyWriteOfDeletedObject struct {
// contains filtered or unexported fields
}
func NewErrDirtyWriteOfDeletedObject ¶ added in v1.24.22
func NewErrDirtyWriteOfDeletedObject(err error) ErrDirtyWriteOfDeletedObject
func (ErrDirtyWriteOfDeletedObject) Error ¶ added in v1.24.22
func (e ErrDirtyWriteOfDeletedObject) Error() string
func (ErrDirtyWriteOfDeletedObject) Unwrap ¶ added in v1.24.22
func (e ErrDirtyWriteOfDeletedObject) Unwrap() error
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 ErrMultiTenancy ¶ added in v1.20.1
type ErrMultiTenancy struct {
// contains filtered or unexported fields
}
func NewErrMultiTenancy ¶ added in v1.20.1
func NewErrMultiTenancy(err error) ErrMultiTenancy
NewErrMultiTenancy with error signature
func (ErrMultiTenancy) Error ¶ added in v1.20.1
func (e ErrMultiTenancy) Error() string
func (ErrMultiTenancy) Unwrap ¶ added in v1.25.2
func (e ErrMultiTenancy) Unwrap() error
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, vectorRepo VectorRepo, modulesProvider ModulesProvider, metrics objectsMetrics, allocChecker *memwatch.Monitor, ) *Manager
NewManager creates a new manager
func (*Manager) AddObject ¶
func (m *Manager) AddObject(ctx context.Context, principal *models.Principal, object *models.Object, repl *additional.ReplicationProperties, ) (*models.Object, error)
AddObject Class Instance to the connected DB.
func (*Manager) AddObjectReference ¶
func (m *Manager) AddObjectReference(ctx context.Context, principal *models.Principal, input *AddReferenceInput, repl *additional.ReplicationProperties, tenant string, ) *Error
AddObjectReference to an existing object. 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, class string, id strfmt.UUID, repl *additional.ReplicationProperties, tenant string, ) error
DeleteObject Class Instance from the connected DB
if class == "" it will delete all object with same id regardless of the class name. This is due to backward compatibility reasons and should be removed in the future
func (*Manager) DeleteObjectReference ¶
func (m *Manager) DeleteObjectReference(ctx context.Context, principal *models.Principal, input *DeleteReferenceInput, repl *additional.ReplicationProperties, tenant string, ) *Error
func (*Manager) GetObject ¶
func (m *Manager) GetObject(ctx context.Context, principal *models.Principal, class string, id strfmt.UUID, additional additional.Properties, replProps *additional.ReplicationProperties, tenant string, ) (*models.Object, error)
GetObject Class from the connected DB
func (*Manager) GetObjectClassFromName ¶ added in v1.21.0
func (*Manager) GetObjects ¶
func (m *Manager) GetObjects(ctx context.Context, principal *models.Principal, offset *int64, limit *int64, sort *string, order *string, after *string, addl additional.Properties, tenant string, ) ([]*models.Object, error)
GetObjects Class from the connected DB
func (*Manager) GetObjectsClass ¶
func (*Manager) HeadObject ¶
func (m *Manager) HeadObject(ctx context.Context, principal *models.Principal, class string, id strfmt.UUID, repl *additional.ReplicationProperties, tenant string, ) (bool, *Error)
HeadObject check object's existence in the connected DB
func (*Manager) MergeObject ¶
func (m *Manager) MergeObject(ctx context.Context, principal *models.Principal, updates *models.Object, repl *additional.ReplicationProperties, ) *Error
func (*Manager) UpdateObject ¶
func (m *Manager) UpdateObject(ctx context.Context, principal *models.Principal, class string, id strfmt.UUID, updates *models.Object, repl *additional.ReplicationProperties, ) (*models.Object, error)
UpdateObject updates object of class. 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, input *PutReferenceInput, repl *additional.ReplicationProperties, tenant string, ) *Error
UpdateObjectReferences of a specific data object. 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, obj *models.Object, repl *additional.ReplicationProperties, ) 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 `json:"class"` ID strfmt.UUID `json:"id"` PrimitiveSchema map[string]interface{} `json:"primitiveSchema"` References BatchReferences `json:"references"` Vector []float32 `json:"vector"` Vectors models.Vectors `json:"vectors"` UpdateTime int64 `json:"updateTime"` AdditionalProperties models.AdditionalProperties `json:"additionalProperties"` PropertiesToDelete []string `json:"propertiesToDelete"` }
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func NewMetrics ¶
func NewMetrics(prom *monitoring.PrometheusMetrics) *Metrics
func (*Metrics) AddObjectDec ¶
func (m *Metrics) AddObjectDec()
func (*Metrics) AddObjectInc ¶
func (m *Metrics) AddObjectInc()
func (*Metrics) AddReferenceDec ¶
func (m *Metrics) AddReferenceDec()
func (*Metrics) AddReferenceInc ¶
func (m *Metrics) AddReferenceInc()
func (*Metrics) AddUsageDimensions ¶
func (*Metrics) BatchDeleteDec ¶
func (m *Metrics) BatchDeleteDec()
func (*Metrics) BatchDeleteInc ¶
func (m *Metrics) BatchDeleteInc()
func (*Metrics) BatchObjects ¶ added in v1.25.14
func (*Metrics) BatchRefDec ¶
func (m *Metrics) BatchRefDec()
func (*Metrics) BatchRefInc ¶
func (m *Metrics) BatchRefInc()
func (*Metrics) BatchTenants ¶ added in v1.25.14
func (*Metrics) DeleteObjectDec ¶
func (m *Metrics) DeleteObjectDec()
func (*Metrics) DeleteObjectInc ¶
func (m *Metrics) DeleteObjectInc()
func (*Metrics) DeleteReferenceDec ¶
func (m *Metrics) DeleteReferenceDec()
func (*Metrics) DeleteReferenceInc ¶
func (m *Metrics) DeleteReferenceInc()
func (*Metrics) GetObjectDec ¶
func (m *Metrics) GetObjectDec()
func (*Metrics) GetObjectInc ¶
func (m *Metrics) GetObjectInc()
func (*Metrics) HeadObjectDec ¶
func (m *Metrics) HeadObjectDec()
func (*Metrics) HeadObjectInc ¶
func (m *Metrics) HeadObjectInc()
func (*Metrics) MergeObjectDec ¶
func (m *Metrics) MergeObjectDec()
func (*Metrics) MergeObjectInc ¶
func (m *Metrics) MergeObjectInc()
func (*Metrics) UpdateObjectDec ¶
func (m *Metrics) UpdateObjectDec()
func (*Metrics) UpdateObjectInc ¶
func (m *Metrics) UpdateObjectInc()
func (*Metrics) UpdateReferenceDec ¶
func (m *Metrics) UpdateReferenceDec()
func (*Metrics) UpdateReferenceInc ¶
func (m *Metrics) UpdateReferenceInc()
type ModulesProvider ¶
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) UsingRef2Vec(className string) bool UpdateVector(ctx context.Context, object *models.Object, class *models.Class, repo modulecapabilities.FindObjectFn, logger logrus.FieldLogger) error BatchUpdateVector(ctx context.Context, class *models.Class, objects []*models.Object, findObjectFn modulecapabilities.FindObjectFn, logger logrus.FieldLogger) (map[int]error, error) VectorizerName(className string) (string, error) }
type PutReferenceInput ¶
type PutReferenceInput struct { // Class name Class string // ID of an object ID strfmt.UUID // Property name Property string // Ref cross reference Refs models.MultipleRef }
PutReferenceInput represents required inputs to add a reference to an existing object.
type QueryInput ¶
type QueryInput struct { Class string Offset int Limit int Cursor *filters.Cursor Filters *filters.LocalFilter Sort []filters.Sort Tenant string Additional additional.Properties }
type QueryParams ¶
type QueryParams struct { Class string Offset *int64 Limit *int64 After *string Sort *string Order *string Tenant *string Additional additional.Properties }
type Replica ¶ added in v1.18.0
type Replica struct { ID strfmt.UUID `json:"id,omitempty"` Deleted bool `json:"deleted"` Object *storobj.Object `json:"object,omitempty"` }
Replica represents a replicated data item
func (*Replica) MarshalBinary ¶ added in v1.18.0
func (*Replica) UnmarshalBinary ¶ added in v1.18.0
func (Replica) UpdateTime ¶ added in v1.18.0
UpdateTime return update time if it exists and 0 otherwise
type Replicas ¶ added in v1.18.0
type Replicas []Replica
func (Replicas) MarshalBinary ¶ added in v1.18.0
func (*Replicas) UnmarshalBinary ¶ added in v1.18.0
type VObject ¶ added in v1.18.0
type VObject struct { // ID of the Object. // Format: uuid ID strfmt.UUID `json:"id,omitempty"` Deleted bool `json:"deleted"` // LatestObject is to most up-to-date version of an object LatestObject *models.Object `json:"object,omitempty"` Vector []float32 `json:"vector"` Vectors models.Vectors `json:"vectors"` // StaleUpdateTime is the LastUpdateTimeUnix of the stale object sent to the coordinator StaleUpdateTime int64 `json:"updateTime,omitempty"` // Version is the most recent incremental version number of the object Version uint64 `json:"version"` }
VObject is a versioned object for detecting replication inconsistencies
func (*VObject) MarshalBinary ¶ added in v1.18.0
func (*VObject) UnmarshalBinary ¶ added in v1.18.0
type VectorRepo ¶
type VectorRepo interface { PutObject(ctx context.Context, concept *models.Object, vector []float32, vectors models.Vectors, repl *additional.ReplicationProperties, schemaVersion uint64) error DeleteObject(ctx context.Context, className string, id strfmt.UUID, repl *additional.ReplicationProperties, tenant string, schemaVersion uint64) error // Object returns object of the specified class giving by its id Object(ctx context.Context, class string, id strfmt.UUID, props search.SelectProperties, additional additional.Properties, repl *additional.ReplicationProperties, tenant string) (*search.Result, error) // Exists returns true if an object of a giving class exists Exists(ctx context.Context, class string, id strfmt.UUID, repl *additional.ReplicationProperties, tenant string) (bool, error) ObjectByID(ctx context.Context, id strfmt.UUID, props search.SelectProperties, additional additional.Properties, tenant string) (*search.Result, error) ObjectSearch(ctx context.Context, offset, limit int, filters *filters.LocalFilter, sort []filters.Sort, additional additional.Properties, tenant string) (search.Results, error) AddReference(ctx context.Context, source *crossref.RefSource, target *crossref.Ref, repl *additional.ReplicationProperties, tenant string, schemaVersion uint64) error Merge(ctx context.Context, merge MergeDocument, repl *additional.ReplicationProperties, tenant string, schemaVersion uint64) error Query(context.Context, *QueryInput) (search.Results, *Error) }
Source Files ¶
- add.go
- auto_schema.go
- batch_add.go
- batch_delete.go
- batch_manager.go
- batch_references_add.go
- batch_types.go
- delete.go
- errors.go
- get.go
- head.go
- manager.go
- merge.go
- metrics.go
- query.go
- references.go
- references_add.go
- references_delete.go
- references_update.go
- replication.go
- update.go
- validate.go
- vector.go