Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

refactor: reuse the slice in MemPostings.Delete() #676

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions index/postings.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,24 +156,11 @@ func (p *MemPostings) Delete(deleted map[uint64]struct{}) {
}
p.mtx.RUnlock()

// For each posting we first analyse whether the postings list is affected by the deletes.
// If yes, we actually reallocate a new postings list.
for _, l := range vals {
// Only lock for processing one postings list so we don't block reads for too long.
p.mtx.Lock()

found := false
for _, id := range p.m[n][l] {
if _, ok := deleted[id]; ok {
found = true
break
}
}
if !found {
p.mtx.Unlock()
continue
}
repl := make([]uint64, 0, len(p.m[n][l]))
repl := p.m[n][l][:0]

for _, id := range p.m[n][l] {
if _, ok := deleted[id]; !ok {
Expand Down