github.com/weaviate/weaviate@v1.24.6/adapters/repos/db/vector_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 db
    13  
    14  import (
    15  	"context"
    16  
    17  	"github.com/weaviate/weaviate/adapters/repos/db/helpers"
    18  	"github.com/weaviate/weaviate/adapters/repos/db/vector/hnsw/distancer"
    19  	"github.com/weaviate/weaviate/entities/schema"
    20  )
    21  
    22  // VectorIndex is anything that indexes vectors efficiently. For an example
    23  // look at ./vector/hnsw/index.go
    24  type VectorIndex interface {
    25  	Dump(labels ...string)
    26  	Add(id uint64, vector []float32) error
    27  	AddBatch(ctx context.Context, id []uint64, vector [][]float32) error
    28  	Delete(id ...uint64) error
    29  	SearchByVector(vector []float32, k int, allow helpers.AllowList) ([]uint64, []float32, error)
    30  	SearchByVectorDistance(vector []float32, dist float32,
    31  		maxLimit int64, allow helpers.AllowList) ([]uint64, []float32, error)
    32  	UpdateUserConfig(updated schema.VectorIndexConfig, callback func()) error
    33  	Drop(ctx context.Context) error
    34  	Shutdown(ctx context.Context) error
    35  	Flush() error
    36  	SwitchCommitLogs(ctx context.Context) error
    37  	ListFiles(ctx context.Context, basePath string) ([]string, error)
    38  	PostStartup()
    39  	Compressed() bool
    40  	ValidateBeforeInsert(vector []float32) error
    41  	DistanceBetweenVectors(x, y []float32) (float32, bool, error)
    42  	ContainsNode(id uint64) bool
    43  	DistancerProvider() distancer.Provider
    44  }