cache update on import adjustment

This commit is contained in:
Todd Gruben 2016-09-15 13:37:10 -05:00
parent 15e425ae8f
commit b7780518cc

View file

@ -883,7 +883,8 @@ func (f *Fragment) Import(bitmapIDs, profileIDs []uint64) error {
}
// Write to storage.
if _, err := f.storage.Add(pos); err != nil {
changed, err := f.storage.Add(pos)
if err != nil {
return err
}
@ -898,13 +899,14 @@ func (f *Fragment) Import(bitmapIDs, profileIDs []uint64) error {
bmCounter = bitmap.Count()
lastID = bitmapID
}
if bitmap.SetBit(profileID) {
if changed {
bmCounter += 1
}
// Invalidate block checksum.
delete(f.checksums, int(bitmapID/HashBlockSize))
}
f.cache.Add(lastID, bmCounter)
f.cache.Invalidate()
return nil