Documentation ¶
Overview ¶
Package ngt provides implementation of Go API for https://github.com/yahoojapan/NGT
Package ngt provides implementation of Go API for https://github.com/yahoojapan/NGT
Package ngt provides implementation of Go API for https://github.com/yahoojapan/NGT
Index ¶
- Constants
- Variables
- type NGT
- type Option
- func WithBulkInsertChunkSize(size int) Option
- func WithCreationEdgeSize(size int) Option
- func WithDefaultEpsilon(epsilon float32) Option
- func WithDefaultPoolSize(poolSize uint32) Option
- func WithDefaultRadius(radius float32) Option
- func WithDimension(size int) Option
- func WithDistanceType(t distanceType) Option
- func WithDistanceTypeByString(dt string) Option
- func WithInMemoryMode(flg bool) Option
- func WithIndexPath(path string) Option
- func WithObjectType(t objectType) Option
- func WithObjectTypeByString(ot string) Option
- func WithSearchEdgeSize(size int) Option
- type SearchResult
Constants ¶
const ( // ------------------------------------------------------------- // Object Type Definition // ------------------------------------------------------------- // ObjectNone is unknown object type. ObjectNone objectType = iota // Uint8 is 8bit unsigned integer. Uint8 // Float is 32bit floating point number. Float // HalfFloat is 16bit floating point number. HalfFloat // ------------------------------------------------------------- // Distance Type Definition // ------------------------------------------------------------- // DistanceNone is unknown distance type. DistanceNone distanceType = iota - 1 // L1 is l1 norm. L1 // L2 is l2 norm. L2 // Angle is angle distance. Angle // Hamming is hamming distance. Hamming // Cosine is cosine distance. Cosine // Poincare is poincare distance. Poincare // Lorentz is lorenz distance. Lorentz // Jaccard is jaccard distance. Jaccard // SparseJaccard is sparse jaccard distance. SparseJaccard // NormalizedL2 is l2 distance with normalization. NormalizedL2 // NormalizedAngle is angle distance with normalization. NormalizedAngle // NormalizedCosine is cosine distance with normalization. NormalizedCosine // ------------------------------------------------------------- // ErrorCode is false // -------------------------------------------------------------. ErrorCode = C._Bool(false) )
Variables ¶
var ( DefaultPoolSize = uint32(10000) DefaultRadius = float32(-1.0) DefaultEpsilon = float32(0.1) )
Functions ¶
This section is empty.
Types ¶
type NGT ¶
type NGT interface { // Search returns search result as []SearchResult Search(vec []float32, size int, epsilon, radius float32) ([]SearchResult, error) // Linear Search returns linear search result as []SearchResult LinearSearch(vec []float32, size int) ([]SearchResult, error) // Insert returns NGT object id. // This only stores not indexing, you must call CreateIndex and SaveIndex. Insert(vec []float32) (uint, error) // InsertCommit returns NGT object id. // This stores and indexes at the same time. InsertCommit(vec []float32, poolSize uint32) (uint, error) // BulkInsert returns NGT object ids. // This only stores not indexing, you must call CreateIndex and SaveIndex. BulkInsert(vecs [][]float32) ([]uint, []error) // BulkInsertCommit returns NGT object ids. // This stores and indexes at the same time. BulkInsertCommit(vecs [][]float32, poolSize uint32) ([]uint, []error) // CreateAndSaveIndex call CreateIndex and SaveIndex in a row. CreateAndSaveIndex(poolSize uint32) error // CreateIndex creates NGT index. CreateIndex(poolSize uint32) error // SaveIndex stores NGT index to storage. SaveIndex() error // SaveIndexWithPath stores NGT index to specified storage. SaveIndexWithPath(path string) error // Remove removes from NGT index. Remove(id uint) error // BulkRemove removes multiple NGT index BulkRemove(ids ...uint) error // GetVector returns vector stored in NGT index. GetVector(id uint) ([]float32, error) // Close NGT index. Close() }
NGT is core interface.
type Option ¶
type Option func(*ngt) error
Option represents the functional option for NGT.
func WithBulkInsertChunkSize ¶
WithBulkInsertChunkSize represents the option to set the bulk insert chunk size for NGT.
func WithCreationEdgeSize ¶
WithCreationEdgeSize represents the option to set the creation edge size for NGT.
func WithDefaultEpsilon ¶
WithDefaultEpsilon represents the option to set the default epsilon for NGT.
func WithDefaultPoolSize ¶
WithDefaultPoolSize represents the option to set the default pool size for NGT.
func WithDefaultRadius ¶
WithDefaultRadius represents the option to set the default radius for NGT.
func WithDimension ¶
WithDimension represents the option to set the dimension for NGT.
func WithDistanceType ¶
func WithDistanceType(t distanceType) Option
WithDistanceType represents the option to set the distance type for NGT.
func WithDistanceTypeByString ¶
WithDistanceTypeByString represents the option to set the distance type for NGT.
func WithInMemoryMode ¶
WithInMemoryMode represents the option to set to start in memory mode or not for NGT.
func WithIndexPath ¶
WithIndexPath represents the option to set the index path for NGT.
func WithObjectType ¶
func WithObjectType(t objectType) Option
WithObjectType represents the option to set the object type for NGT.
func WithObjectTypeByString ¶
WithObjectTypeByString represents the option to set the object type by string for NGT.
func WithSearchEdgeSize ¶
WithSearchEdgeSize represents the option to set the search edge size for NGT.
type SearchResult ¶
SearchResult is struct for comfortable use in Go.