From 67986d41bfab5634bc11d81f7a02bd7279782476 Mon Sep 17 00:00:00 2001 From: Steve Yen Date: Thu, 30 Nov 2017 08:36:01 -0800 Subject: [PATCH 1/2] scorch InternalID() handles case of unknown docId --- index/scorch/reader_test.go | 8 ++++++++ index/scorch/snapshot_index.go | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) 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 } From 398dcb19b3c7bc96e74f42a838784307715a92da Mon Sep 17 00:00:00 2001 From: Steve Yen Date: Thu, 30 Nov 2017 10:37:02 -0800 Subject: [PATCH 2/2] scorch introducer uses the roaring.Or(x, y) API Instead of cloning an input bitmap, the roaring.Or(x, y) implementation fills a brand new result bitmap, which should be allow for more efficient packing and memory utilization. --- index/scorch/introducer.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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