insertCommittedPostings inserts an old committed posting in the mutable layer. It also updates fields that are cached. This includes deleteAllMarker, length and committedUids map. this should be called while building the list only.
(pl *pb.PostingList)
| 303 | // cached. This includes deleteAllMarker, length and committedUids map. this should be called while |
| 304 | // building the list only. |
| 305 | func (mm *MutableLayer) insertCommittedPostings(pl *pb.PostingList) { |
| 306 | if mm.committedUidsTime == math.MaxUint64 { |
| 307 | mm.committedUidsTime = 0 |
| 308 | } |
| 309 | if mm.length == math.MaxInt64 { |
| 310 | mm.length = 0 |
| 311 | } |
| 312 | if mm.deleteAllMarker == math.MaxUint64 { |
| 313 | mm.deleteAllMarker = 0 |
| 314 | } |
| 315 | |
| 316 | if pl.CommitTs > mm.committedUidsTime { |
| 317 | mm.lastEntry = pl |
| 318 | } |
| 319 | mm.committedUidsTime = x.Max(pl.CommitTs, mm.committedUidsTime) |
| 320 | mm.committedEntries[pl.CommitTs] = pl |
| 321 | |
| 322 | for _, mpost := range pl.Postings { |
| 323 | mpost.CommitTs = pl.CommitTs |
| 324 | if hasDeleteAll(mpost) { |
| 325 | if mpost.CommitTs > mm.deleteAllMarker { |
| 326 | mm.deleteAllMarker = mpost.CommitTs |
| 327 | } |
| 328 | // No need to set the length here as we are reading the list in reverse. |
| 329 | continue |
| 330 | } |
| 331 | // If this posting is less than deleteAllMarker, we don't need to add it to the mutable map results. |
| 332 | if mpost.CommitTs >= mm.deleteAllMarker { |
| 333 | mm.length += getLengthDelta(mpost.Op) |
| 334 | } |
| 335 | // We insert old postings in reverse order. So we only need to read the first update to an UID. |
| 336 | if _, ok := mm.committedUids[mpost.Uid]; !ok { |
| 337 | mm.committedUids[mpost.Uid] = mpost |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | func (mm *MutableLayer) populateUidMap(pl *pb.PostingList) { |
| 343 | if mm.currentUids != nil { |