ctubbsii removed a comment on issue #1975:
URL: https://github.com/apache/accumulo/issues/1975#issuecomment-859029202


   Would the following change solve the problem?
   
   ```diff
   --- 
a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java
   +++ 
b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/tinylfu/TinyLfuBlockCache.java
   @@ -199,13 +199,9 @@ public final class TinyLfuBlockCache implements 
BlockCache {
        }
      }
    
   -  private Block load(Loader loader, Map<String,byte[]> resolvedDeps) {
   -    byte[] data = loader.load((int) Math.min(Integer.MAX_VALUE, 
policy.getMaximum()), resolvedDeps);
   -    if (data == null) {
   -      return null;
   -    }
   -
   -    return new Block(data);
   +  private Block load(Loader loader, Map<String,byte[]> resolvedDeps, long 
policyMax) {
   +    byte[] data = loader.load((int) Math.min(Integer.MAX_VALUE, policyMax), 
resolvedDeps);
   +    return data == null ? null : new Block(data);
      }
    
      private Map<String,byte[]> resolveDependencies(Map<String,Loader> deps) {
   @@ -233,8 +229,9 @@ public final class TinyLfuBlockCache implements 
BlockCache {
      public CacheEntry getBlock(String blockName, Loader loader) {
        Map<String,Loader> deps = loader.getDependencies();
        Block block;
   +    final long policyMax = policy.getMaximum();
        if (deps.isEmpty()) {
   -      block = cache.get(blockName, k -> load(loader, 
Collections.emptyMap()));
   +      block = cache.get(blockName, k -> load(loader, 
Collections.emptyMap(), policyMax));
        } else {
          // This code path exist to handle the case where dependencies may 
need to be loaded. Loading
          // dependencies will access the cache. Cache load functions
   @@ -251,7 +248,8 @@ public final class TinyLfuBlockCache implements 
BlockCache {
            // Use asMap because it will not increment stats, getIfPresent 
recorded a miss above. Use
            // computeIfAbsent because it is possible another thread loaded
            // the data since this thread called getIfPresent.
   -        block = cache.asMap().computeIfAbsent(blockName, k -> load(loader, 
resolvedDeps));
   +        block =
   +            cache.asMap().computeIfAbsent(blockName, k -> load(loader, 
resolvedDeps, policyMax));
          }
        }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to