Skip to content

Commit

Permalink
parse index config correctly and avoid returning nil
Browse files Browse the repository at this point in the history
  • Loading branch information
moogacs committed Apr 25, 2024
1 parent cea1a65 commit 1b690dc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 1 addition & 2 deletions usecases/schema/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/weaviate/weaviate/cluster/proto/api"
"github.com/weaviate/weaviate/entities/models"
"github.com/weaviate/weaviate/entities/schema"
schemaConfig "github.com/weaviate/weaviate/entities/schema/config"
)

type executor struct {
Expand Down Expand Up @@ -91,7 +90,7 @@ func (e *executor) UpdateClass(req api.UpdateClassRequest) error {
}
} else {
if err := e.migrator.UpdateVectorIndexConfig(ctx,
className, req.Class.VectorIndexConfig.(schemaConfig.VectorIndexConfig)); err != nil {
className, asVectorIndexConfig(req.Class)); err != nil {
return fmt.Errorf("vector index config update: %w", err)
}
}
Expand Down
17 changes: 15 additions & 2 deletions usecases/schema/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,30 @@ func validateVectorConfigsParityAndImmutables(initial, updated *models.Class) er
}

func asVectorIndexConfigs(c *models.Class) map[string]schemaConfig.VectorIndexConfig {
cfgs := map[string]schemaConfig.VectorIndexConfig{}
if c.VectorConfig == nil {
return nil
return cfgs
}

cfgs := map[string]schemaConfig.VectorIndexConfig{}
for vecName := range c.VectorConfig {
cfgs[vecName] = c.VectorConfig[vecName].VectorIndexConfig.(schemaConfig.VectorIndexConfig)
}
return cfgs
}

func asVectorIndexConfig(c *models.Class) schemaConfig.VectorIndexConfig {
var (
cfg schemaConfig.VectorIndexConfig
ok bool
)
cfg, ok = c.VectorIndexConfig.(schemaConfig.VectorIndexConfig)
if !ok {
return nil
}

return cfg
}

func validateShardingConfig(current, update *models.Class, mtEnabled bool) error {
if mtEnabled {
return nil
Expand Down

0 comments on commit 1b690dc

Please sign in to comment.