Merge pull request #679 from steveyen/scorch
scorch optimize zap Count()
This commit is contained in:
commit
ed8bbded02
@ -85,10 +85,15 @@ func (p *PostingsList) Iterator() segment.PostingsIterator {
|
|||||||
// Count returns the number of items on this postings list
|
// Count returns the number of items on this postings list
|
||||||
func (p *PostingsList) Count() uint64 {
|
func (p *PostingsList) Count() uint64 {
|
||||||
if p.postings != nil {
|
if p.postings != nil {
|
||||||
|
n := p.postings.GetCardinality()
|
||||||
if p.except != nil {
|
if p.except != nil {
|
||||||
return roaring.AndNot(p.postings, p.except).GetCardinality()
|
e := p.except.GetCardinality()
|
||||||
|
if e > n {
|
||||||
|
e = n
|
||||||
}
|
}
|
||||||
return p.postings.GetCardinality()
|
return n - e
|
||||||
|
}
|
||||||
|
return n
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ type SegmentDictionarySnapshot struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SegmentDictionarySnapshot) PostingsList(term string, except *roaring.Bitmap) (segment.PostingsList, error) {
|
func (s *SegmentDictionarySnapshot) PostingsList(term string, except *roaring.Bitmap) (segment.PostingsList, error) {
|
||||||
|
// TODO: if except is non-nil, perhaps need to OR it with s.s.deleted?
|
||||||
return s.d.PostingsList(term, s.s.deleted)
|
return s.d.PostingsList(term, s.s.deleted)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user