From f785f6c5531d24bafb42f8ac2cbfdcdf4f206cbb Mon Sep 17 00:00:00 2001 From: Aditi Ahuja Date: Tue, 15 Oct 2024 18:39:26 +0530 Subject: [PATCH] add once instead of many times to bitmap --- faiss_vector_posting.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/faiss_vector_posting.go b/faiss_vector_posting.go index 0dd2a36..384b367 100644 --- a/faiss_vector_posting.go +++ b/faiss_vector_posting.go @@ -417,12 +417,14 @@ func (sb *SegmentBase) InterpretVectorIndex(field string, requiresFiltering bool // Getting the vector IDs corresponding to the eligible // doc IDs. eligibleVecIDsBitmap := roaring.NewBitmap() + vecIDsUint32 := make([]uint32, 0) for _, eligibleDocID := range eligibleDocIDs { vecIDs := docVecIDMap[uint32(eligibleDocID)] for _, vecID := range vecIDs { - eligibleVecIDsBitmap.Add(uint32(vecID)) + vecIDsUint32 = append(vecIDsUint32, uint32(vecID)) } } + eligibleVecIDsBitmap.AddMany(vecIDsUint32) // Determining which clusters, identified by centroid ID, // have at least one eligible vector and hence, ought to be @@ -464,6 +466,9 @@ func (sb *SegmentBase) InterpretVectorIndex(field string, requiresFiltering bool minEligibleCentroids = i + 1 } + // If the fraction of eligible vec IDs is greater than 50%, + // use an exclude selector instead for the ineligible IDs. + // Search the clusters specified by 'closestCentroidIDs' for // vectors whose IDs are present in 'vectorIDsToInclude' scores, ids, err := vecIndex.SearchClustersFromIVFIndex(