0
0

firestorm gtreap lookup once per snapshot docID

Previously, firestorm would lookup docID's in the inFlight gtreap for
every candidate docNum, and this change moves the lookup to outside of
the loop.
This commit is contained in:
Steve Yen 2016-01-06 16:46:15 -08:00
parent 024848ac91
commit d6a997d8c1

View File

@ -44,9 +44,14 @@ type Snapshot struct {
// returns which doc number is valid
// if none, then 0
func (s *Snapshot) Which(docID []byte, docNumList DocNumberList) uint64 {
sort.Sort(docNumList)
for _, docNum := range docNumList { // docNumList is sorted descending.
if docNum > 0 && s.Valid(docID, docNum) {
inFlightVal := s.inFlight.Get(&InFlightItem{docID: docID})
sort.Sort(docNumList) // Descending ordering.
for _, docNum := range docNumList {
if docNum > 0 && docNum <= s.maxRead &&
(inFlightVal == nil || inFlightVal.(*InFlightItem).docNum == docNum) &&
!s.deletedDocNumbers.Test(uint(docNum)) {
return docNum
}
}