From ab52a803b849bc43efd13d3afc9304314a4eb64a Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Mon, 27 Feb 2017 12:42:36 -0600 Subject: [PATCH] rank cache update after count --- fragment.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/fragment.go b/fragment.go index d6eead246..8337dbb96 100644 --- a/fragment.go +++ b/fragment.go @@ -398,9 +398,10 @@ func (f *Fragment) setBit(bitmapID, profileID uint64) (changed bool, bool error) } // Update the cache. - if f.bitmap(bitmapID, true).SetBit(profileID) { - changed = true - } + bm := f.bitmap(bitmapID, true) + bm.SetBit(profileID) + bm.InvalidateCount() //maybe a perf opportunity? + f.cache.Add(bitmapID, bm.Count()) f.stats.Count("setN", 1) @@ -442,9 +443,10 @@ func (f *Fragment) clearBit(bitmapID, profileID uint64) (bool, error) { } // Update the cache. - if f.bitmap(bitmapID, true).ClearBit(profileID) { - return true, nil - } + bm := f.bitmap(bitmapID, true) + bm.ClearBit(profileID) + bm.InvalidateCount() //maybe a perf opportunity? + f.cache.Add(bitmapID, bm.Count()) f.stats.Count("clearN", 1)