accumulo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ben-manes <...@git.apache.org>
Subject [GitHub] accumulo pull request #251: ACCUMULO-4626 added weak reference value map for...
Date Wed, 26 Apr 2017 05:22:14 GMT
Github user ben-manes commented on a diff in the pull request:

    https://github.com/apache/accumulo/pull/251#discussion_r113367686
  
    --- Diff: core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/TinyLfuBlockCache.java
---
    @@ -48,12 +52,13 @@
       private final Cache<String,Block> cache;
       private final Policy.Eviction<String,Block> policy;
       private final ScheduledExecutorService statsExecutor;
    +  private final Map<String,CacheEntry> weakEvictionMap = new MapMaker().weakValues().makeMap();
     
       public TinyLfuBlockCache(long maxSize, long blockSize) {
         cache = Caffeine.newBuilder().initialCapacity((int) Math.ceil(1.2 * maxSize / blockSize)).weigher((String
blockName, Block block) -> {
           int keyWeight = ClassSize.align(blockName.length()) + ClassSize.STRING;
           return keyWeight + block.weight();
    -    }).maximumWeight(maxSize).recordStats().build();
    +    }).maximumWeight(maxSize).recordStats().removalListener((String key, Block block,
RemovalCause cause) -> weakEvictionMap.put(key, block)).build();
    --- End diff --
    
    It is called after, asynchronously. I think using a CacheWriter would be preferable, as
it is called within the atomic operation.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message