Skip to content

Commit 1a319cd

Browse files
author
Steve Yen
authored
Merge pull request #784 from steveyen/drops-loop-optimization
scorch zap merge optimize drops lookup to outside of loop
2 parents b8bb792 + 3f1dcb6 commit 1a319cd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index/scorch/segment/zap/merge.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,12 @@ func mergeStoredAndRemap(segments []*SegmentBase, drops []*roaring.Bitmap,
462462
for segI, segment := range segments {
463463
segNewDocNums := make([]uint64, segment.numDocs)
464464

465+
dropsI := drops[segI]
466+
465467
// optimize when the field mapping is the same across all
466468
// segments and there are no deletions, via byte-copying
467469
// of stored docs bytes directly to the writer
468-
if fieldsSame && (drops[segI] == nil || drops[segI].GetCardinality() == 0) {
470+
if fieldsSame && (dropsI == nil || dropsI.GetCardinality() == 0) {
469471
err := segment.copyStoredDocs(newDocNum, docNumOffsets, w)
470472
if err != nil {
471473
return 0, nil, err
@@ -483,7 +485,7 @@ func mergeStoredAndRemap(segments []*SegmentBase, drops []*roaring.Bitmap,
483485
// for each doc num
484486
for docNum := uint64(0); docNum < segment.numDocs; docNum++ {
485487
// TODO: roaring's API limits docNums to 32-bits?
486-
if drops[segI] != nil && drops[segI].Contains(uint32(docNum)) {
488+
if dropsI != nil && dropsI.Contains(uint32(docNum)) {
487489
segNewDocNums[docNum] = docDropped
488490
continue
489491
}

0 commit comments

Comments
 (0)