当前位置: 首页>>代码示例>>Java>>正文


Java Weigher类代码示例

本文整理汇总了Java中com.googlecode.concurrentlinkedhashmap.Weigher的典型用法代码示例。如果您正苦于以下问题:Java Weigher类的具体用法?Java Weigher怎么用?Java Weigher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Weigher类属于com.googlecode.concurrentlinkedhashmap包,在下文中一共展示了Weigher类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: SerializingCache

import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
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();
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:SerializingCache.java

示例2: Cache

import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
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();
        }
    });
}
 
开发者ID:jordw,项目名称:heftydb,代码行数:23,代码来源:IndexBlock.java

示例3: Cache

import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
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();
        }
    });
}
 
开发者ID:jordw,项目名称:heftydb,代码行数:23,代码来源:TupleBlock.java

示例4: TableBlockCache

import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
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;
}
 
开发者ID:jordw,项目名称:heftydb,代码行数:12,代码来源:TableBlockCache.java

示例5: create

import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
public static <K, V> SerializingCache<K, V> create(long weightedCapacity, Weigher<RefCountedMemory> weigher, ISerializer<V> serializer)
{
    return new SerializingCache<>(weightedCapacity, weigher, serializer);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:5,代码来源:SerializingCache.java

示例6: create

import com.googlecode.concurrentlinkedhashmap.Weigher; //导入依赖的package包/类
public static <K, V> SerializingCache<K, V> create(long weightedCapacity, Weigher<RefCountedMemory> weigher, ISerializer<V> serializer)
{
    return new SerializingCache<K, V>(weightedCapacity, weigher, serializer);
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:5,代码来源:SerializingCache.java


注:本文中的com.googlecode.concurrentlinkedhashmap.Weigher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。