com.googlecode.concurrentlinkedhashmap.Weigher Java Examples
The following examples show how to use
com.googlecode.concurrentlinkedhashmap.Weigher.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SerializingCache.java From stratio-cassandra with Apache License 2.0 | 6 votes |
private SerializingCache(long capacity, Weigher<RefCountedMemory> weigher, ISerializer<V> serializer) { this.serializer = serializer; EvictionListener<K,RefCountedMemory> listener = new EvictionListener<K, RefCountedMemory>() { public void onEviction(K k, RefCountedMemory mem) { mem.unreference(); } }; this.map = new ConcurrentLinkedHashMap.Builder<K, RefCountedMemory>() .weigher(weigher) .maximumWeightedCapacity(capacity) .concurrencyLevel(DEFAULT_CONCURENCY_LEVEL) .listener(listener) .build(); }
Example #2
Source File: IndexBlock.java From heftydb with Apache License 2.0 | 6 votes |
public Cache(long maxSize, Metrics metrics) { cache = new TableBlockCache<IndexBlock>(maxSize, new Weigher<IndexBlock>() { @Override public int weightOf(IndexBlock indexRecord) { return indexRecord.memory().size(); } }); metrics.gauge("cache.indexBlock.entrySize", new Gauge<Long>() { @Override public Long getValue() { return cache.totalEntrySize(); } }); metrics.gauge("cache.indexBlock.utilizationRate", new Gauge<Double>() { @Override public Double getValue() { return cache.utilizationRate(); } }); }
Example #3
Source File: TupleBlock.java From heftydb with Apache License 2.0 | 6 votes |
public Cache(long maxSize, Metrics metrics) { cache = new TableBlockCache<TupleBlock>(maxSize, new Weigher<TupleBlock>() { @Override public int weightOf(TupleBlock tuple) { return tuple.memory().size(); } }); metrics.gauge("cache.tupleBlock.entrySize", new Gauge<Long>() { @Override public Long getValue() { return cache.totalEntrySize(); } }); metrics.gauge("cache.tupleBlock.utilizationRate", new Gauge<Double>() { @Override public Double getValue() { return cache.utilizationRate(); } }); }
Example #4
Source File: TableBlockCache.java From heftydb with Apache License 2.0 | 5 votes |
public TableBlockCache(long maxSize, Weigher<T> weigher) { cache = new ConcurrentLinkedHashMap.Builder<Entry, T>().concurrencyLevel(CONCURRENCY_LEVEL).weigher(weigher) .listener(new EvictionListener<Entry, T>() { @Override public void onEviction(Entry key, T value) { totalSize.addAndGet(-(value.memory().size())); value.memory().release(); } }).maximumWeightedCapacity(maxSize).build(); this.maxSize = maxSize; }
Example #5
Source File: SerializingCache.java From stratio-cassandra with Apache License 2.0 | 4 votes |
public static <K, V> SerializingCache<K, V> create(long weightedCapacity, Weigher<RefCountedMemory> weigher, ISerializer<V> serializer) { return new SerializingCache<>(weightedCapacity, weigher, serializer); }