Browse Source

[Scorch] Skipping segments that don't include requested ids

Skip the segment if the current segment's maximum docId is
smaller than the smallest requested id, while fetching
the DocNumbers.
abhinavdangeti 3 months ago
parent
commit
5554236b02
1 changed files with 13 additions and 0 deletions
  1. 13 0
      index/scorch/segment/zap/segment.go

+ 13 - 0
index/scorch/segment/zap/segment.go

@@ -418,7 +418,20 @@ func (s *SegmentBase) DocNumbers(ids []string) (*roaring.Bitmap, error) {
 		}
 
 		postingsList := emptyPostingsList
+
+		sMax, err := idDict.fst.GetMaxKey()
+		if err != nil {
+			return nil, err
+		}
+		sMaxStr := string(sMax)
+		filteredIds := make([]string, 0, len(ids))
 		for _, id := range ids {
+			if id <= sMaxStr {
+				filteredIds = append(filteredIds, id)
+			}
+		}
+
+		for _, id := range filteredIds {
 			postingsList, err = idDict.postingsList([]byte(id), nil, postingsList)
 			if err != nil {
 				return nil, err