Documentation
¶
Index ¶
- Variables
- func LegacySnapshot(nodeID string, m map[string]types.ClassState) (*raft.SnapshotMeta, io.ReadCloser, error)
- func MergeProps(old, new []*models.Property) []*models.Property
- func NewSchema(nodeID string, shardReader shardReader) *schema
- type ClassInfo
- type Indexer
- type LoadLegacySchema
- type Parser
- type SaveLegacySchema
- type SchemaManager
- func (s *SchemaManager) AddClass(cmd *command.ApplyRequest, nodeID string, schemaOnly bool, ...) error
- func (s *SchemaManager) AddProperty(cmd *command.ApplyRequest, schemaOnly bool, enableSchemaCallback bool) error
- func (s *SchemaManager) AddTenants(cmd *command.ApplyRequest, schemaOnly bool) error
- func (s *SchemaManager) Close(ctx context.Context) (err error)
- func (s *SchemaManager) DeleteClass(cmd *command.ApplyRequest, schemaOnly bool, enableSchemaCallback bool) error
- func (s *SchemaManager) DeleteTenants(cmd *command.ApplyRequest, schemaOnly bool) error
- func (s *SchemaManager) Load(ctx context.Context, nodeID string) error
- func (s *SchemaManager) NewSchemaReader() SchemaReader
- func (s *SchemaManager) NewSchemaReaderWithWaitFunc(f func(context.Context, uint64) error) SchemaReader
- func (s *SchemaManager) PreApplyFilter(req *api.ApplyRequest) error
- func (sm *SchemaManager) QueryReadOnlyClasses(req *cmd.QueryRequest) ([]byte, error)
- func (sm *SchemaManager) QuerySchema() ([]byte, error)
- func (sm *SchemaManager) QueryShardOwner(req *cmd.QueryRequest) ([]byte, error)
- func (sm *SchemaManager) QueryShardingState(req *cmd.QueryRequest) ([]byte, error)
- func (sm *SchemaManager) QueryTenants(req *cmd.QueryRequest) ([]byte, error)
- func (sm *SchemaManager) QueryTenantsShards(req *cmd.QueryRequest) ([]byte, error)
- func (s *SchemaManager) ReloadDBFromSchema()
- func (s *SchemaManager) ReplaceStatesNodeName(new string)
- func (s *SchemaManager) Restore(rc io.ReadCloser, parser Parser) error
- func (s *SchemaManager) RestoreClass(cmd *command.ApplyRequest, nodeID string, schemaOnly bool, ...) error
- func (s *SchemaManager) SetIndexer(idx Indexer)
- func (s *SchemaManager) Snapshot() raft.FSMSnapshot
- func (s *SchemaManager) UpdateClass(cmd *command.ApplyRequest, nodeID string, schemaOnly bool, ...) error
- func (s *SchemaManager) UpdateShardStatus(cmd *command.ApplyRequest, schemaOnly bool) error
- func (s *SchemaManager) UpdateTenants(cmd *command.ApplyRequest, schemaOnly bool) error
- type SchemaReader
- func (rs SchemaReader) ClassEqual(name string) string
- func (rs SchemaReader) ClassInfo(class string) (ci ClassInfo)
- func (rs SchemaReader) ClassInfoWithVersion(ctx context.Context, class string, version uint64) (ci ClassInfo, err error)
- func (rs SchemaReader) CopyShardingState(class string) (ss *sharding.State)
- func (rs SchemaReader) CopyShardingStateWithVersion(ctx context.Context, class string, version uint64) (ss *sharding.State, err error)
- func (rs SchemaReader) GetShardsStatus(class, tenant string) (models.ShardStatusList, error)
- func (rs SchemaReader) Len() int
- func (rs SchemaReader) MultiTenancy(class string) models.MultiTenancyConfig
- func (rs SchemaReader) MultiTenancyWithVersion(ctx context.Context, class string, version uint64) (models.MultiTenancyConfig, error)
- func (rs SchemaReader) Read(class string, reader func(*models.Class, *sharding.State) error) error
- func (rs SchemaReader) ReadOnlyClass(class string) (cls *models.Class)
- func (rs SchemaReader) ReadOnlyClassWithVersion(ctx context.Context, class string, version uint64) (cls *models.Class, err error)
- func (rs SchemaReader) ReadOnlySchema() models.Schema
- func (rs SchemaReader) ShardFromUUID(class string, uuid []byte) (shard string)
- func (rs SchemaReader) ShardFromUUIDWithVersion(ctx context.Context, class string, uuid []byte, version uint64) (shard string, err error)
- func (rs SchemaReader) ShardOwner(class, shard string) (owner string, err error)
- func (rs SchemaReader) ShardOwnerWithVersion(ctx context.Context, class, shard string, version uint64) (owner string, err error)
- func (rs SchemaReader) ShardReplicas(class, shard string) (nodes []string, err error)
- func (rs SchemaReader) ShardReplicasWithVersion(ctx context.Context, class, shard string, version uint64) (nodes []string, err error)
- func (rs SchemaReader) States() map[string]types.ClassState
- func (rs SchemaReader) TenantsShards(class string, tenants ...string) (map[string]string, error)
- func (rs SchemaReader) TenantsShardsWithVersion(ctx context.Context, version uint64, class string, tenants ...string) (tenantShards map[string]string, err error)
- func (rs SchemaReader) WaitForUpdate(ctx context.Context, version uint64) error
- type VersionedSchemaReader
- func (s VersionedSchemaReader) ClassEqual(name string) string
- func (s VersionedSchemaReader) ClassInfo(ctx context.Context, class string, v uint64) (ClassInfo, error)
- func (s VersionedSchemaReader) CopyShardingState(ctx context.Context, class string, v uint64) (*sharding.State, error)
- func (s VersionedSchemaReader) Len() int
- func (s VersionedSchemaReader) MultiTenancy(ctx context.Context, class string, v uint64) (models.MultiTenancyConfig, error)
- func (s VersionedSchemaReader) Read(ctx context.Context, class string, v uint64, ...) error
- func (s VersionedSchemaReader) ReadOnlyClass(ctx context.Context, class string, v uint64) (*models.Class, error)
- func (s VersionedSchemaReader) ShardFromUUID(ctx context.Context, class string, uuid []byte, v uint64) (string, error)
- func (s VersionedSchemaReader) ShardOwner(ctx context.Context, class, shard string, v uint64) (string, error)
- func (s VersionedSchemaReader) ShardReplicas(ctx context.Context, class, shard string, v uint64) ([]string, error)
- func (s VersionedSchemaReader) TenantsShards(ctx context.Context, v uint64, class string, tenants ...string) (map[string]string, uint64, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrBadRequest = errors.New("bad request") ErrSchema = errors.New("updating schema") )
Functions ¶
func LegacySnapshot ¶
func LegacySnapshot(nodeID string, m map[string]types.ClassState) (*raft.SnapshotMeta, io.ReadCloser, error)
LegacySnapshot returns a ready-to-use in-memory Raft snapshot based on the provided legacy schema
func MergeProps ¶
MergeProps makes sure duplicates are not created by ignoring new props with the same names as old props. If property of nested type is present in both new and old slices, final property is created by merging new property into copy of old one
Types ¶
type ClassInfo ¶
type Indexer ¶
type Indexer interface { AddClass(api.AddClassRequest) error UpdateClass(api.UpdateClassRequest) error DeleteClass(string) error AddProperty(class string, req api.AddPropertyRequest) error AddTenants(class string, req *api.AddTenantsRequest) error UpdateTenants(class string, req *api.UpdateTenantsRequest) error DeleteTenants(class string, req *api.DeleteTenantsRequest) error UpdateShardStatus(*api.UpdateShardStatusRequest) error GetShardsStatus(class, tenant string) (models.ShardStatusList, error) UpdateIndex(api.UpdateClassRequest) error TriggerSchemaUpdateCallbacks() // ReloadLocalDB reloads the local database using the latest schema. ReloadLocalDB(ctx context.Context, all []api.UpdateClassRequest) error // RestoreClassDir restores classes on the filesystem directly from the temporary class backup stored on disk. RestoreClassDir(class string) error Open(context.Context) error Close(context.Context) error }
Indexer interface updates both the collection and its indices in the filesystem. This is distinct from updating metadata, which is handled through a different interface.
type LoadLegacySchema ¶
type LoadLegacySchema func() (map[string]types.ClassState, error)
LoadLegacySchema returns the legacy schema
type Parser ¶
type Parser interface { // ParseClassUpdate parses a class after unmarshaling by setting concrete types for the fields ParseClass(class *models.Class) error // ParseClass parses new updates by providing the current class data. ParseClassUpdate(class, update *models.Class) (*models.Class, error) }
Parser parses concrete class fields after deserialization
type SaveLegacySchema ¶
type SaveLegacySchema func(map[string]types.ClassState) error
SaveLegacySchema saves the RAFT schema representation to the legacy storage
type SchemaManager ¶
type SchemaManager struct {
// contains filtered or unexported fields
}
func NewSchemaManager ¶
func (*SchemaManager) AddClass ¶
func (s *SchemaManager) AddClass(cmd *command.ApplyRequest, nodeID string, schemaOnly bool, enableSchemaCallback bool) error
func (*SchemaManager) AddProperty ¶
func (s *SchemaManager) AddProperty(cmd *command.ApplyRequest, schemaOnly bool, enableSchemaCallback bool) error
func (*SchemaManager) AddTenants ¶
func (s *SchemaManager) AddTenants(cmd *command.ApplyRequest, schemaOnly bool) error
func (*SchemaManager) DeleteClass ¶
func (s *SchemaManager) DeleteClass(cmd *command.ApplyRequest, schemaOnly bool, enableSchemaCallback bool) error
func (*SchemaManager) DeleteTenants ¶
func (s *SchemaManager) DeleteTenants(cmd *command.ApplyRequest, schemaOnly bool) error
func (*SchemaManager) NewSchemaReader ¶
func (s *SchemaManager) NewSchemaReader() SchemaReader
func (*SchemaManager) NewSchemaReaderWithWaitFunc ¶
func (s *SchemaManager) NewSchemaReaderWithWaitFunc(f func(context.Context, uint64) error) SchemaReader
func (*SchemaManager) PreApplyFilter ¶
func (s *SchemaManager) PreApplyFilter(req *api.ApplyRequest) error
func (*SchemaManager) QueryReadOnlyClasses ¶
func (sm *SchemaManager) QueryReadOnlyClasses(req *cmd.QueryRequest) ([]byte, error)
func (*SchemaManager) QuerySchema ¶
func (sm *SchemaManager) QuerySchema() ([]byte, error)
func (*SchemaManager) QueryShardOwner ¶
func (sm *SchemaManager) QueryShardOwner(req *cmd.QueryRequest) ([]byte, error)
func (*SchemaManager) QueryShardingState ¶
func (sm *SchemaManager) QueryShardingState(req *cmd.QueryRequest) ([]byte, error)
func (*SchemaManager) QueryTenants ¶
func (sm *SchemaManager) QueryTenants(req *cmd.QueryRequest) ([]byte, error)
func (*SchemaManager) QueryTenantsShards ¶
func (sm *SchemaManager) QueryTenantsShards(req *cmd.QueryRequest) ([]byte, error)
func (*SchemaManager) ReloadDBFromSchema ¶
func (s *SchemaManager) ReloadDBFromSchema()
func (*SchemaManager) ReplaceStatesNodeName ¶ added in v1.25.12
func (s *SchemaManager) ReplaceStatesNodeName(new string)
ReplaceStatesNodeName it update the node name inside sharding states. WARNING: this shall be used in one node cluster environments only. because it will replace the shard node name if the node name got updated only if the replication factor is 1, otherwise it's no-op
func (*SchemaManager) Restore ¶
func (s *SchemaManager) Restore(rc io.ReadCloser, parser Parser) error
func (*SchemaManager) RestoreClass ¶
func (s *SchemaManager) RestoreClass(cmd *command.ApplyRequest, nodeID string, schemaOnly bool, enableSchemaCallback bool) error
func (*SchemaManager) SetIndexer ¶
func (s *SchemaManager) SetIndexer(idx Indexer)
func (*SchemaManager) Snapshot ¶
func (s *SchemaManager) Snapshot() raft.FSMSnapshot
func (*SchemaManager) UpdateClass ¶
func (s *SchemaManager) UpdateClass(cmd *command.ApplyRequest, nodeID string, schemaOnly bool, enableSchemaCallback bool) error
UpdateClass modifies the vectors and inverted indexes associated with a class Other class properties are handled by separate functions
func (*SchemaManager) UpdateShardStatus ¶
func (s *SchemaManager) UpdateShardStatus(cmd *command.ApplyRequest, schemaOnly bool) error
func (*SchemaManager) UpdateTenants ¶
func (s *SchemaManager) UpdateTenants(cmd *command.ApplyRequest, schemaOnly bool) error
type SchemaReader ¶
type SchemaReader struct {
// contains filtered or unexported fields
}
SchemaReader is used for retrying schema queries. It is a thin wrapper around the original schema, separating retry logic from the actual operation. Retry may be needed due to eventual consistency issues where updates might take some time to arrive at the follower.
func (SchemaReader) ClassEqual ¶
func (rs SchemaReader) ClassEqual(name string) string
ClassEqual returns the name of an existing class with a similar name, and "" otherwise strings.EqualFold is used to compare classes
func (SchemaReader) ClassInfo ¶
func (rs SchemaReader) ClassInfo(class string) (ci ClassInfo)
func (SchemaReader) ClassInfoWithVersion ¶
func (SchemaReader) CopyShardingState ¶
func (rs SchemaReader) CopyShardingState(class string) (ss *sharding.State)
func (SchemaReader) CopyShardingStateWithVersion ¶
func (SchemaReader) GetShardsStatus ¶
func (rs SchemaReader) GetShardsStatus(class, tenant string) (models.ShardStatusList, error)
func (SchemaReader) Len ¶
func (rs SchemaReader) Len() int
func (SchemaReader) MultiTenancy ¶
func (rs SchemaReader) MultiTenancy(class string) models.MultiTenancyConfig
func (SchemaReader) MultiTenancyWithVersion ¶
func (rs SchemaReader) MultiTenancyWithVersion(ctx context.Context, class string, version uint64) (models.MultiTenancyConfig, error)
func (SchemaReader) Read ¶
Read performs a read operation `reader` on the specified class and sharding state
func (SchemaReader) ReadOnlyClass ¶
func (rs SchemaReader) ReadOnlyClass(class string) (cls *models.Class)
ReadOnlyClass returns a shallow copy of a class. The copy is read-only and should not be modified.
func (SchemaReader) ReadOnlyClassWithVersion ¶
func (rs SchemaReader) ReadOnlyClassWithVersion(ctx context.Context, class string, version uint64) (cls *models.Class, err error)
ReadOnlyClass returns a shallow copy of a class. The copy is read-only and should not be modified.
func (SchemaReader) ReadOnlySchema ¶
func (rs SchemaReader) ReadOnlySchema() models.Schema
ReadOnlySchema returns a read only schema Changing the schema outside this package might lead to undefined behavior.
it creates a shallow copy of existing classes
This function assumes that class attributes are being overwritten. The properties attribute is the only one that might vary in size; therefore, we perform a shallow copy of the existing properties. This implementation assumes that individual properties are overwritten rather than partially updated
func (SchemaReader) ShardFromUUID ¶
func (rs SchemaReader) ShardFromUUID(class string, uuid []byte) (shard string)
ShardFromUUID returns shard name of the provided uuid
func (SchemaReader) ShardFromUUIDWithVersion ¶
func (rs SchemaReader) ShardFromUUIDWithVersion(ctx context.Context, class string, uuid []byte, version uint64) (shard string, err error)
ShardFromUUID returns shard name of the provided uuid
func (SchemaReader) ShardOwner ¶
func (rs SchemaReader) ShardOwner(class, shard string) (owner string, err error)
ShardOwner returns the node owner of the specified shard
func (SchemaReader) ShardOwnerWithVersion ¶
func (rs SchemaReader) ShardOwnerWithVersion(ctx context.Context, class, shard string, version uint64) (owner string, err error)
ShardOwner returns the node owner of the specified shard
func (SchemaReader) ShardReplicas ¶
func (rs SchemaReader) ShardReplicas(class, shard string) (nodes []string, err error)
ShardReplicas returns the replica nodes of a shard
func (SchemaReader) ShardReplicasWithVersion ¶
func (rs SchemaReader) ShardReplicasWithVersion(ctx context.Context, class, shard string, version uint64) (nodes []string, err error)
ShardReplicas returns the replica nodes of a shard
func (SchemaReader) States ¶
func (rs SchemaReader) States() map[string]types.ClassState
func (SchemaReader) TenantsShards ¶
TenantsShards returns shard name for the provided tenant and its activity status
func (SchemaReader) TenantsShardsWithVersion ¶
func (rs SchemaReader) TenantsShardsWithVersion(ctx context.Context, version uint64, class string, tenants ...string) (tenantShards map[string]string, err error)
TenantsShardsWithVersion returns shard name for the provided tenant and its activity status
func (SchemaReader) WaitForUpdate ¶
func (rs SchemaReader) WaitForUpdate(ctx context.Context, version uint64) error
type VersionedSchemaReader ¶
type VersionedSchemaReader struct { WaitForUpdate func(ctx context.Context, version uint64) error // contains filtered or unexported fields }
VersionedSchemaReader is utilized to query the schema based on a specific update version. Serving as a thin wrapper around the original schema, it segregates waiting logic from the actual operation. It waits until it finds an update at least as up-to-date as the specified version. Note that updates may take some time to propagate to the follower, hence this process might take time.
func (VersionedSchemaReader) ClassEqual ¶
func (s VersionedSchemaReader) ClassEqual(name string) string
ClassEqual returns the name of an existing class with a similar name, and "" otherwise strings.EqualFold is used to compare classes
func (VersionedSchemaReader) CopyShardingState ¶
func (VersionedSchemaReader) Len ¶
func (s VersionedSchemaReader) Len() int
func (VersionedSchemaReader) MultiTenancy ¶
func (s VersionedSchemaReader) MultiTenancy(ctx context.Context, class string, v uint64, ) (models.MultiTenancyConfig, error)
func (VersionedSchemaReader) Read ¶
func (s VersionedSchemaReader) Read(ctx context.Context, class string, v uint64, reader func(*models.Class, *sharding.State) error, ) error
Read performs a read operation `reader` on the specified class and sharding state
func (VersionedSchemaReader) ReadOnlyClass ¶
func (s VersionedSchemaReader) ReadOnlyClass(ctx context.Context, class string, v uint64, ) (*models.Class, error)
ReadOnlyClass returns a shallow copy of a class. The copy is read-only and should not be modified.
func (VersionedSchemaReader) ShardFromUUID ¶
func (s VersionedSchemaReader) ShardFromUUID(ctx context.Context, class string, uuid []byte, v uint64, ) (string, error)
ShardFromUUID returns shard name of the provided uuid
func (VersionedSchemaReader) ShardOwner ¶
func (s VersionedSchemaReader) ShardOwner(ctx context.Context, class, shard string, v uint64, ) (string, error)
ShardOwner returns the node owner of the specified shard
func (VersionedSchemaReader) ShardReplicas ¶
func (s VersionedSchemaReader) ShardReplicas( ctx context.Context, class, shard string, v uint64, ) ([]string, error)
ShardReplicas returns the replica nodes of a shard