github.com/weaviate/weaviate@v1.24.6/adapters/repos/db/vector/noop/index.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 noop 13 14 import ( 15 "context" 16 "fmt" 17 18 "github.com/pkg/errors" 19 "github.com/weaviate/weaviate/adapters/repos/db/helpers" 20 "github.com/weaviate/weaviate/adapters/repos/db/vector/hnsw/distancer" 21 "github.com/weaviate/weaviate/entities/schema" 22 "github.com/weaviate/weaviate/entities/vectorindex/hnsw" 23 ) 24 25 type Index struct{} 26 27 func NewIndex() *Index { 28 return &Index{} 29 } 30 31 func (i *Index) AddBatch(ctx context.Context, id []uint64, vector [][]float32) error { 32 // silently ignore 33 return nil 34 } 35 36 func (i *Index) Add(id uint64, vector []float32) error { 37 // silently ignore 38 return nil 39 } 40 41 func (i *Index) Delete(id ...uint64) error { 42 // silently ignore 43 return nil 44 } 45 46 func (i *Index) SearchByVector(vector []float32, k int, allow helpers.AllowList) ([]uint64, []float32, error) { 47 return nil, nil, errors.Errorf("cannot vector-search on a class not vector-indexed") 48 } 49 50 func (i *Index) SearchByVectorDistance(vector []float32, dist float32, maxLimit int64, allow helpers.AllowList) ([]uint64, []float32, error) { 51 return nil, nil, errors.Errorf("cannot vector-search on a class not vector-indexed") 52 } 53 54 func (i *Index) UpdateUserConfig(updated schema.VectorIndexConfig, callback func()) error { 55 callback() 56 switch t := updated.(type) { 57 case hnsw.UserConfig: 58 // the fact that we are in the noop index means that 'skip' must have been 59 // set to true before, so changing it now is not possible. But if it 60 // stays, we don't mind. 61 if t.Skip { 62 return nil 63 } 64 return errors.Errorf("cannot update vector index config on a non-indexed class. Delete and re-create without skip property") 65 66 default: 67 return fmt.Errorf("unrecognized vector index config: %T", updated) 68 69 } 70 } 71 72 func (i *Index) Drop(context.Context) error { 73 // silently ignore 74 return nil 75 } 76 77 func (i *Index) Flush() error { 78 return nil 79 } 80 81 func (i *Index) Shutdown(context.Context) error { 82 return nil 83 } 84 85 func (i *Index) SwitchCommitLogs(context.Context) error { 86 return nil 87 } 88 89 func (i *Index) ListFiles(context.Context, string) ([]string, error) { 90 return nil, nil 91 } 92 93 func (i *Index) ValidateBeforeInsert(vector []float32) error { 94 return nil 95 } 96 97 func (i *Index) PostStartup() { 98 } 99 100 func (i *Index) Dump(labels ...string) { 101 } 102 103 func (i *Index) DistanceBetweenVectors(x, y []float32) (float32, bool, error) { 104 return 0, true, nil 105 } 106 107 func (i *Index) ContainsNode(id uint64) bool { 108 return false 109 } 110 111 func (i *Index) DistancerProvider() distancer.Provider { 112 return nil 113 } 114 115 func (i *Index) ShouldCompress() (bool, int) { 116 return false, 0 117 } 118 119 func (i *Index) ShouldCompressFromConfig(config schema.VectorIndexConfig) (bool, int) { 120 return false, 0 121 } 122 123 func (i *Index) Compressed() bool { 124 return false 125 } 126 127 func (i *Index) AlreadyIndexed() uint64 { 128 return 0 129 } 130 131 func (i *Index) TurnOnCompression(callback func()) error { 132 return nil 133 }