diff --git a/indexing_options.go b/indexing_options.go index e4ce923..c77dd5a 100644 --- a/indexing_options.go +++ b/indexing_options.go @@ -24,6 +24,7 @@ const ( SkipFreqNorm SkipDVCompression SkipDVChunking + GPU ) const ( @@ -72,6 +73,10 @@ func (o FieldIndexingOptions) SkipDVChunking() bool { return o&SkipDVChunking != 0 } +func (o FieldIndexingOptions) UseGPU() bool { + return o&GPU != 0 +} + func (o FieldIndexingOptions) String() string { rv := "" if o.IsIndexed() { @@ -113,5 +118,11 @@ func (o FieldIndexingOptions) String() string { } rv += "DV_CHUNKING" } + if o.UseGPU() { + if rv != "" { + rv += ", " + } + rv += "GPU" + } return rv } diff --git a/indexing_options_test.go b/indexing_options_test.go index 9683f50..8d1c09f 100644 --- a/indexing_options_test.go +++ b/indexing_options_test.go @@ -26,6 +26,7 @@ func TestFieldIndexingOptions(t *testing.T) { includeTermVectors bool docValues bool skipFreqNorm bool + useGPU bool }{ { options: IndexField | StoreField | IncludeTermVectors, @@ -88,6 +89,12 @@ func TestFieldIndexingOptions(t *testing.T) { docValues: true, includeTermVectors: false, }, + { + options: IndexField | SkipFreqNorm | GPU, + isIndexed: true, + skipFreqNorm: true, + useGPU: true, + }, } for _, test := range tests { @@ -112,5 +119,9 @@ func TestFieldIndexingOptions(t *testing.T) { if actuallyFreqNormValues != test.skipFreqNorm { t.Errorf("expected docValue to be %v, got %v for %d", test.skipFreqNorm, actuallyFreqNormValues, test.options) } + actuallyUseGPU := test.options.UseGPU() + if actuallyUseGPU != test.useGPU { + t.Errorf("expected useGPU to be %v, got %v for %d", test.useGPU, actuallyUseGPU, test.options) + } } } diff --git a/vector.go b/vector.go index c3b3012..7a873e7 100644 --- a/vector.go +++ b/vector.go @@ -18,6 +18,9 @@ package index type VectorField interface { + // Name of the field + Name() string + // The vector data Vector() []float32 // Dimensionality of the vector Dims() int @@ -25,6 +28,8 @@ type VectorField interface { Similarity() string // nlist/nprobe config (recall/latency) the index is optimized for IndexOptimizedFor() string + // Field indexing options + Options() FieldIndexingOptions } // -----------------------------------------------------------------------------