0
0

scorch zap merge optimize newDocNums lookup to outside of loop

And, also a "go fmt".
This commit is contained in:
Steve Yen 2018-02-26 14:23:53 -08:00
parent 98d5d7bd81
commit 99ed127176
4 changed files with 8 additions and 7 deletions

View File

@ -130,14 +130,14 @@ func (s *Scorch) introduceSegment(next *segmentIntroduction) error {
segment: s.root.segment[i].segment, segment: s.root.segment[i].segment,
cachedDocs: s.root.segment[i].cachedDocs, cachedDocs: s.root.segment[i].cachedDocs,
} }
// apply new obsoletions // apply new obsoletions
if s.root.segment[i].deleted == nil { if s.root.segment[i].deleted == nil {
newss.deleted = delta newss.deleted = delta
} else { } else {
newss.deleted = roaring.Or(s.root.segment[i].deleted, delta) newss.deleted = roaring.Or(s.root.segment[i].deleted, delta)
} }
// check for live size before copying // check for live size before copying
if newss.LiveSize() > 0 { if newss.LiveSize() > 0 {
newSnapshot.segment = append(newSnapshot.segment, newss) newSnapshot.segment = append(newSnapshot.segment, newss)
@ -241,7 +241,7 @@ func (s *Scorch) introduceMerge(nextMerge *segmentMerge) {
// the root segments would be the obsolete segment set // the root segments would be the obsolete segment set
delete(nextMerge.old, segmentID) delete(nextMerge.old, segmentID)
} else if s.root.segment[i].LiveSize() > 0 { } else if s.root.segment[i].LiveSize() > 0 {
// this segment is staying // this segment is staying
newSnapshot.segment = append(newSnapshot.segment, &SegmentSnapshot{ newSnapshot.segment = append(newSnapshot.segment, &SegmentSnapshot{
id: s.root.segment[i].id, id: s.root.segment[i].id,
@ -269,7 +269,7 @@ func (s *Scorch) introduceMerge(nextMerge *segmentMerge) {
} }
} }
} }
// In case where all the docs in the newly merged segment getting // In case where all the docs in the newly merged segment getting
// deleted by the time we reach here, can skip the introduction. // deleted by the time we reach here, can skip the introduction.
if nextMerge.new != nil && if nextMerge.new != nil &&
nextMerge.new.Count() > newSegmentDeleted.GetCardinality() { nextMerge.new.Count() > newSegmentDeleted.GetCardinality() {

View File

@ -16,7 +16,7 @@ package scorch
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"os" "os"

View File

@ -68,7 +68,6 @@ OUTER:
persistWatchers = s.pausePersisterForMergerCatchUp(lastPersistedEpoch, persistWatchers = s.pausePersisterForMergerCatchUp(lastPersistedEpoch,
&lastMergedEpoch, persistWatchers) &lastMergedEpoch, persistWatchers)
var ourSnapshot *IndexSnapshot var ourSnapshot *IndexSnapshot
var ourPersisted []chan error var ourPersisted []chan error

View File

@ -316,10 +316,12 @@ func persistMergedRest(segments []*SegmentBase, dropsIn []*roaring.Bitmap,
return nil, 0, err2 return nil, 0, err2
} }
newDocNumsI := newDocNums[itrI]
postItr = postings.iterator(postItr) postItr = postings.iterator(postItr)
next, err2 := postItr.Next() next, err2 := postItr.Next()
for next != nil && err2 == nil { for next != nil && err2 == nil {
hitNewDocNum := newDocNums[itrI][next.Number()] hitNewDocNum := newDocNumsI[next.Number()]
if hitNewDocNum == docDropped { if hitNewDocNum == docDropped {
return nil, 0, fmt.Errorf("see hit with dropped doc num") return nil, 0, fmt.Errorf("see hit with dropped doc num")
} }