0
0
Fork 0

fix crash in DocNumbers when segment is empty

This commit is contained in:
Marty Schoch 2017-12-01 09:50:27 -05:00
parent eb256f78bc
commit cff14f1212
1 changed files with 10 additions and 6 deletions

View File

@ -122,13 +122,17 @@ func (s *Segment) Count() uint64 {
// DocNumbers returns a bitset corresponding to the doc numbers of all the
// provided _id strings
func (s *Segment) DocNumbers(ids []string) *roaring.Bitmap {
idDictionary := s.Dicts[idFieldID]
rv := roaring.New()
for _, id := range ids {
postingID := idDictionary[id]
if postingID > 0 {
rv.Or(s.Postings[postingID-1])
// guard against empty segment
if len(s.FieldsMap) > 0 {
idDictionary := s.Dicts[idFieldID]
for _, id := range ids {
postingID := idDictionary[id]
if postingID > 0 {
rv.Or(s.Postings[postingID-1])
}
}
}
return rv