diff --git a/index/scorch/introducer.go b/index/scorch/introducer.go index dc748ad8..37a66dc8 100644 --- a/index/scorch/introducer.go +++ b/index/scorch/introducer.go @@ -49,8 +49,7 @@ func (s *Scorch) mainLoop() { if s.root.segment[i].deleted == nil { newSnapshot.segment[i].deleted = delta } else { - newSnapshot.segment[i].deleted = s.root.segment[i].deleted.Clone() - newSnapshot.segment[i].deleted.Or(delta) + newSnapshot.segment[i].deleted = roaring.Or(s.root.segment[i].deleted, delta) } newSnapshot.offsets[i] = running diff --git a/index/scorch/reader_test.go b/index/scorch/reader_test.go index a050bb44..f673b198 100644 --- a/index/scorch/reader_test.go +++ b/index/scorch/reader_test.go @@ -93,6 +93,14 @@ func TestIndexReader(t *testing.T) { t.Errorf("count was 2, but only saw %d", actualCount) } + internalIDBogus, err := indexReader.InternalID("a-bogus-docId") + if err != nil { + t.Fatal(err) + } + if internalIDBogus != nil { + t.Errorf("expected bogus docId to have nil InternalID") + } + internalID2, err := indexReader.InternalID("2") if err != nil { t.Fatal(err) diff --git a/index/scorch/snapshot_index.go b/index/scorch/snapshot_index.go index 8c6ea1aa..11fc063c 100644 --- a/index/scorch/snapshot_index.go +++ b/index/scorch/snapshot_index.go @@ -256,7 +256,7 @@ func (i *IndexSnapshot) InternalID(id string) (rv index.IndexInternalID, err err }() next, err := tfr.Next(nil) - if err != nil { + if err != nil || next == nil { return nil, err }