Browse Source

Merge pull request #1108 from abhinavdangeti/minMaxKey

[Scorch] Skipping segments that don't include requested ids
Abhinav Dangeti 1 month ago
parent
commit
d72521093e
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