github.com/weaviate/weaviate@v1.24.6/modules/ref2vec-centroid/config/config.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 package config 13 14 import "github.com/weaviate/weaviate/entities/moduletools" 15 16 const ( 17 MethodMean = "mean" 18 MethodDefault = MethodMean 19 ) 20 21 const ( 22 calculationMethodField = "method" 23 referencePropertiesField = "referenceProperties" 24 ) 25 26 func Default() map[string]interface{} { 27 return map[string]interface{}{ 28 calculationMethodField: MethodDefault, 29 } 30 } 31 32 type Config struct { 33 class moduletools.ClassConfig 34 } 35 36 func New(cfg moduletools.ClassConfig) *Config { 37 return &Config{class: cfg} 38 } 39 40 func (c *Config) ReferenceProperties() map[string]struct{} { 41 refProps := map[string]struct{}{} 42 props := c.class.Class() 43 44 iRefProps := props[referencePropertiesField].([]interface{}) 45 for _, iProp := range iRefProps { 46 refProps[iProp.(string)] = struct{}{} 47 } 48 49 return refProps 50 } 51 52 func (c *Config) CalculationMethod() string { 53 props := c.class.Class() 54 calcMethod := props[calculationMethodField].(string) 55 return calcMethod 56 }