Skip to content

Commit 074e13f

Browse files
do not write options
1 parent 83276a0 commit 074e13f

1 file changed

Lines changed: 3 additions & 24 deletions

File tree

section_faiss_vector_index.go

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ type vecIndexInfo struct {
7575
indexSize uint64
7676
vecIds []int64
7777
indexOptimizedFor string
78-
indexOptions index.FieldIndexingOptions
7978
index *faiss.IndexImpl
8079
}
8180

@@ -127,10 +126,6 @@ func (v *faissVectorIndexSection) Merge(opaque map[int]resetable, segments []*Se
127126
_, n = binary.Uvarint(sb.mem[pos : pos+binary.MaxVarintLen64])
128127
pos += n
129128

130-
// the field indexing options represented as a uint64
131-
fieldIndexingOptionsInt, n := binary.Uvarint(sb.mem[pos : pos+binary.MaxVarintLen64])
132-
pos += n
133-
134129
// the index optimization type represented as an int
135130
indexOptimizationTypeInt, n := binary.Uvarint(sb.mem[pos : pos+binary.MaxVarintLen64])
136131
pos += n
@@ -142,7 +137,6 @@ func (v *faissVectorIndexSection) Merge(opaque map[int]resetable, segments []*Se
142137
indexes = append(indexes, &vecIndexInfo{
143138
vecIds: make([]int64, 0, numVecs),
144139
indexOptimizedFor: index.VectorIndexOptimizationsReverseLookup[int(indexOptimizationTypeInt)],
145-
indexOptions: index.FieldIndexingOptions(fieldIndexingOptionsInt),
146140
})
147141

148142
curIdx := len(indexes) - 1
@@ -211,12 +205,6 @@ func (v *vectorIndexOpaque) flushSectionMetadata(fieldID int, w *CountHashWriter
211205
if err != nil {
212206
return err
213207
}
214-
// write out the field indexing options
215-
n = binary.PutUvarint(tempBuf, uint64(indexes[0].indexOptions))
216-
_, err = w.Write(tempBuf[:n])
217-
if err != nil {
218-
return err
219-
}
220208

221209
n = binary.PutUvarint(tempBuf, uint64(index.SupportedVectorIndexOptimizations[indexes[0].indexOptimizedFor]))
222210
_, err = w.Write(tempBuf[:n])
@@ -330,7 +318,6 @@ func (v *vectorIndexOpaque) mergeAndWriteVectorIndexes(sbs []*SegmentBase,
330318
dims = index.D()
331319
metric = int(index.MetricType())
332320
indexOptimizedFor = vecIndexes[segI].indexOptimizedFor
333-
indexOptions = vecIndexes[segI].indexOptions
334321
}
335322

336323
// not a valid merge operation as there are no valid indexes to merge.
@@ -527,7 +514,7 @@ func (vo *vectorIndexOpaque) writeVectorIndexes(w *CountHashWriter) (offset uint
527514
// read vector index options:
528515
// was this field configured
529516
// to use GPU for training?
530-
useGPU := content.options.UseGPU()
517+
useGPU := vo.fieldsOptions
531518

532519
nvecs := len(ids)
533520
nlist := determineCentroids(nvecs)
@@ -551,7 +538,7 @@ func (vo *vectorIndexOpaque) writeVectorIndexes(w *CountHashWriter) (offset uint
551538
// May fall back to CPU training if GPU training fails due
552539
// to any reason such as insufficient memory, or unavailability
553540
// of GPUs, etc.
554-
faissIndex, err = TrainIndex(faissIndex, vecs, dims, useGPU)
541+
faissIndex, err = TrainIndex(faissIndex, vecs, dims)
555542
if err != nil {
556543
return 0, err
557544
}
@@ -580,12 +567,6 @@ func (vo *vectorIndexOpaque) writeVectorIndexes(w *CountHashWriter) (offset uint
580567
if err != nil {
581568
return 0, err
582569
}
583-
// write out the field indexing options
584-
n = binary.PutUvarint(tempBuf, uint64(content.options))
585-
_, err = w.Write(tempBuf[:n])
586-
if err != nil {
587-
return 0, err
588-
}
589570

590571
n = binary.PutUvarint(tempBuf, uint64(index.SupportedVectorIndexOptimizations[content.indexOptimizedFor]))
591572
_, err = w.Write(tempBuf[:n])
@@ -665,7 +646,6 @@ func (vo *vectorIndexOpaque) process(field index.VectorField, fieldID uint16, do
665646
dim := field.Dims()
666647
metric := field.Similarity()
667648
indexOptimizedFor := field.IndexOptimizedFor()
668-
options := field.Options()
669649

670650
// caller is supposed to make sure len(vec) is a multiple of dim.
671651
// Not double checking it here to avoid the overhead.
@@ -693,7 +673,6 @@ func (vo *vectorIndexOpaque) process(field index.VectorField, fieldID uint16, do
693673
dim: uint16(dim),
694674
metric: metric,
695675
indexOptimizedFor: indexOptimizedFor,
696-
options: options,
697676
}
698677
} else {
699678
vo.vecFieldMap[fieldID].vecs[subVecHash] = &vecInfo{
@@ -748,7 +727,7 @@ type indexContent struct {
748727
dim uint16
749728
metric string
750729
indexOptimizedFor string
751-
options index.FieldIndexingOptions
730+
gpu bool
752731
}
753732

754733
type vecInfo struct {

0 commit comments

Comments
 (0)