@Override public CacheStatistics getCacheStatistics() { return new CacheStatistics( cache.size(), cache.getMaxNumItems(), cache.getNumManagedBytes(), cache.getMaxNumManagedBytes()); }
public int size() { if (!isEnabled()) { return 0; } else { synchronized (cache) { return cache.size(); } } }
private void addValueToCache(ByteBuffer location, ByteBuffer value) { cache.put(location, BytesUtils.byteBufferDeepCopy(value)); }
private boolean loadValueFromCache(ByteBuffer location, ReaderResult result) { ByteBuffer value = cache.get(location); if (value != null) { result.deepCopyIntoResultBuffer(value); result.found(); result.setL2CacheHit(true); return true; } else { return false; } }
this.offsetInBlockNumBytes = offsetInBlockNumBytes; this.cacheLastDecompressedBlock = cacheLastDecompressedBlock; this.cache = new SynchronizedMemoryBoundCache<ByteBuffer, ByteBuffer>( cacheNumBytesCapacity > 0 || cacheNumItemsCapacity > 0, cacheNumBytesCapacity,
private boolean loadValueFromCache(ByteBuffer keyHash, ReaderResult result) { ByteBuffer value; value = cache.get(keyHash); if (value != null) { // Compare against the not found marker (note that this is an address equality // and not an object equality on purpose) if (value != NOT_FOUND_MARKER) { // Load cached value into result result.deepCopyIntoResultBuffer(value); result.found(); } else { result.notFound(); } // Was found in cache result.setL1CacheHit(true); return true; } else { // Was not found in cache return false; } } }
maxUncompressedBufferSize = footer.getMaxUncompressedBufferSize(); maxCompressedBufferSize = footer.getMaxCompressedBufferSize(); cache = new SynchronizedMemoryBoundCache<ByteBuffer, ByteBuffer>( cacheNumBytesCapacity > 0 || cacheNumItemsCapacity > 0, cacheNumBytesCapacity,
@Override public CacheStatistics getCacheStatistics() { CacheStatistics keyReaderCacheStatistics = keyFileReader.getCacheStatistics(); return new CacheStatistics( keyReaderCacheStatistics.getNumItems() + cache.size(), keyReaderCacheStatistics.getMaxNumItems() + cache.getMaxNumItems(), keyReaderCacheStatistics.getNumManagedBytes() + cache.getNumManagedBytes(), keyReaderCacheStatistics.getMaxNumManagedBytes() + cache.getMaxNumManagedBytes()); }
public V get(K key) { if (!isEnabled()) { return null; } else { synchronized (cache) { return cache.get(key); } } }
private void addNotFoundToCache(ByteBuffer keyHash) { cache.put(BytesUtils.byteBufferDeepCopy(keyHash), NOT_FOUND_MARKER); }
public int getMaxNumItems() { if(!isEnabled()){ return 0; }else{ return cache.getMaxNumItems(); } }
private void addValueToCache(ByteBuffer keyHash, ByteBuffer value) { cache.put(BytesUtils.byteBufferDeepCopy(keyHash), BytesUtils.byteBufferDeepCopy(value)); }
public void put(K key, V value) { if (isEnabled()) { if (value == null) { throw new IllegalArgumentException("Value to put in cache should not be null."); } synchronized (cache) { cache.putAndEvict(key, value); } } }
public long getNumManagedBytes() { if (!isEnabled()) { return 0; } else { synchronized (cache) { return cache.getNumManagedBytes(); } } }
public long getMaxNumManagedBytes() { if(!isEnabled()){ return 0; }else{ return cache.getMaxNumManagedBytes(); } } }
ByteBuffer locationDeepCopy = cache.isEnabled() ? BytesUtils.byteBufferDeepCopy(location) : null; if (blockCompressionCodec == null) {