From 3ea07ae3a741435db2532846abd04036868cf843 Mon Sep 17 00:00:00 2001 From: Matt Jaffee Date: Wed, 12 Sep 2018 17:07:46 -0500 Subject: [PATCH] use cache.Recalculate instead of Invalidate for imports Invalidate does not always rebuild the cache - if the last rebuild is < 10s ago, it does nothing. We always want to rebuild the cache after imports. Also updated the comments around recalculate/invalidate to clarify. --- cache.go | 4 ++-- fragment.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cache.go b/cache.go index c6821c393..8ae8caefc 100644 --- a/cache.go +++ b/cache.go @@ -40,10 +40,10 @@ type cache interface { // Returns a list of all IDs. IDs() []uint64 - // Updates the cache, if necessary. + // Soft ask for the cache to be rebuilt - may not if it has been done recently. Invalidate() - // Rebuilds the cache + // Rebuilds the cache. Recalculate() // Returns an ordered list of the top ranked bitmaps. diff --git a/fragment.go b/fragment.go index 827dda6e2..ef2a5bfab 100644 --- a/fragment.go +++ b/fragment.go @@ -1386,7 +1386,7 @@ func (f *fragment) bulkImport(rowIDs, columnIDs []uint64) error { f.cache.BulkAdd(rowID, n) } - f.cache.Invalidate() + f.cache.Recalculate() return snapshot(f, results) } @@ -1462,7 +1462,7 @@ func (f *fragment) importRoaringBytes(roaringBytes []byte) error { n := bm.CountRange(rowID*ShardWidth, (rowID+1)*ShardWidth) f.cache.BulkAdd(rowID, n) } - f.cache.Invalidate() + f.cache.Recalculate() err = snapshot(f, bm) return err