[CARBONDATA-2476][DataMap] Fix bug in bloom datamap cache Since the cache is used by all bloomfilter datamaps, the cache will be evicted only for specified keys only if loading the specified cache is failed. Previous bug will cause all the cache be evicted after it is loaded.
This closes #2303 Project: http://git-wip-us.apache.org/repos/asf/carbondata/repo Commit: http://git-wip-us.apache.org/repos/asf/carbondata/commit/3087323a Tree: http://git-wip-us.apache.org/repos/asf/carbondata/tree/3087323a Diff: http://git-wip-us.apache.org/repos/asf/carbondata/diff/3087323a Branch: refs/heads/branch-1.4 Commit: 3087323a9e57b46ad17f33915075478727f7777f Parents: 3f33276 Author: xuchuanyin <[email protected]> Authored: Mon May 14 10:46:33 2018 +0800 Committer: Jacky Li <[email protected]> Committed: Sat May 19 08:00:32 2018 +0800 ---------------------------------------------------------------------- .../apache/carbondata/datamap/bloom/BloomDataMapCache.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/carbondata/blob/3087323a/datamap/bloom/src/main/java/org/apache/carbondata/datamap/bloom/BloomDataMapCache.java ---------------------------------------------------------------------- diff --git a/datamap/bloom/src/main/java/org/apache/carbondata/datamap/bloom/BloomDataMapCache.java b/datamap/bloom/src/main/java/org/apache/carbondata/datamap/bloom/BloomDataMapCache.java index fc23f33..2411cf4 100644 --- a/datamap/bloom/src/main/java/org/apache/carbondata/datamap/bloom/BloomDataMapCache.java +++ b/datamap/bloom/src/main/java/org/apache/carbondata/datamap/bloom/BloomDataMapCache.java @@ -151,10 +151,10 @@ public class BloomDataMapCache implements Serializable { this.bloomDMCache.put(cacheKey, bloomDMModels); return bloomDMModels; } catch (ClassNotFoundException | IOException e) { + clear(cacheKey); LOGGER.error(e, "Error occurs while reading bloom index"); throw new RuntimeException("Error occurs while reading bloom index", e); } finally { - clear(); CarbonUtil.closeStreams(objectInStream, dataInStream); } } @@ -191,10 +191,10 @@ public class BloomDataMapCache implements Serializable { /** * clear this cache */ - private void clear() { + private void clear(CacheKey cacheKey) { LOGGER.info(String.format("Current meta cache statistic: %s", getCacheStatus())); - LOGGER.info("Trigger invalid all the cache for bloom datamap"); - this.bloomDMCache.invalidateAll(); + LOGGER.info("Trigger invalid cache for bloom datamap, key is " + cacheKey); + this.bloomDMCache.invalidate(cacheKey); } public static class CacheKey {
