本文整理汇总了Java中com.google.common.cache.AbstractCache.StatsCounter类的典型用法代码示例。如果您正苦于以下问题:Java StatsCounter类的具体用法?Java StatsCounter怎么用?Java StatsCounter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StatsCounter类属于com.google.common.cache.AbstractCache包,在下文中一共展示了StatsCounter类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Segment
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
Segment(
LocalCache<K, V> map,
int initialCapacity,
long maxSegmentWeight,
StatsCounter statsCounter) {
this.map = map;
this.maxSegmentWeight = maxSegmentWeight;
this.statsCounter = checkNotNull(statsCounter);
initTable(newEntryArray(initialCapacity));
keyReferenceQueue = map.usesKeyReferences() ? new ReferenceQueue<K>() : null;
valueReferenceQueue = map.usesValueReferences() ? new ReferenceQueue<V>() : null;
recencyQueue =
map.usesAccessQueue()
? new ConcurrentLinkedQueue<ReferenceEntry<K, V>>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
writeQueue =
map.usesWriteQueue()
? new WriteQueue<K, V>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
accessQueue =
map.usesAccessQueue()
? new AccessQueue<K, V>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
}
示例2: Segment
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
Segment(
LocalCache<K, V> map,
int initialCapacity,
long maxSegmentWeight,
StatsCounter statsCounter) {
this.map = map;
this.maxSegmentWeight = maxSegmentWeight;
this.statsCounter = checkNotNull(statsCounter);
initTable(newEntryArray(initialCapacity));
keyReferenceQueue = map.usesKeyReferences() ? new ReferenceQueue<K>() : null;
valueReferenceQueue = map.usesValueReferences() ? new ReferenceQueue<V>() : null;
recencyQueue = map.usesAccessQueue()
? new ConcurrentLinkedQueue<ReferenceEntry<K, V>>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
writeQueue =
map.usesWriteQueue()
? new WriteQueue<K, V>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
accessQueue =
map.usesAccessQueue()
? new AccessQueue<K, V>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
}
示例3: Segment
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
Segment(LocalCache<K, V> map, int initialCapacity, long maxSegmentWeight, StatsCounter statsCounter) {
this.map = map;
this.maxSegmentWeight = maxSegmentWeight;
this.statsCounter = checkNotNull(statsCounter);
initTable(newEntryArray(initialCapacity));
keyReferenceQueue = map.usesKeyReferences() ? new ReferenceQueue<K>() : null;
valueReferenceQueue = map.usesValueReferences() ? new ReferenceQueue<V>() : null;
recencyQueue =
map.usesAccessQueue()
? new ConcurrentLinkedQueue<ReferenceEntry<K, V>>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
writeQueue =
map.usesWriteQueue()
? new WriteQueue<K, V>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
accessQueue =
map.usesAccessQueue()
? new AccessQueue<K, V>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
}
示例4: Segment
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
Segment(LocalCache<K, V> map, int initialCapacity, long maxSegmentWeight,
StatsCounter statsCounter) {
this.map = map;
this.maxSegmentWeight = maxSegmentWeight;
this.statsCounter = checkNotNull(statsCounter);
initTable(newEntryArray(initialCapacity));
keyReferenceQueue = map.usesKeyReferences()
? new ReferenceQueue<K>() : null;
valueReferenceQueue = map.usesValueReferences()
? new ReferenceQueue<V>() : null;
recencyQueue = map.usesAccessQueue()
? new ConcurrentLinkedQueue<ReferenceEntry<K, V>>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
writeQueue = map.usesWriteQueue()
? new WriteQueue<K, V>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
accessQueue = map.usesAccessQueue()
? new AccessQueue<K, V>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
}
示例5: Segment
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
Segment(LocalCache<K, V> map, int initialCapacity, long maxSegmentWeight, StatsCounter statsCounter) {
this.map = map;
this.maxSegmentWeight = maxSegmentWeight;
this.statsCounter = checkNotNull(statsCounter);
initTable(newEntryArray(initialCapacity));
// 构造队列,可以看到如果在builder没有配置,则不创建queue或者为空queue
keyReferenceQueue = map.usesKeyReferences() ? new ReferenceQueue<K>() : null;
valueReferenceQueue = map.usesValueReferences() ? new ReferenceQueue<V>() : null;
recencyQueue = map.usesAccessQueue() ? new ConcurrentLinkedQueue<ReferenceEntry<K, V>>() : LocalCache
.<ReferenceEntry<K, V>> discardingQueue();
writeQueue = map.usesWriteQueue() ? new WriteQueue<K, V>() : LocalCache
.<ReferenceEntry<K, V>> discardingQueue();
accessQueue = map.usesAccessQueue() ? new AccessQueue<K, V>() : LocalCache
.<ReferenceEntry<K, V>> discardingQueue();
}
示例6: Segment
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
Segment(
LocalCache<K, V> map,
int initialCapacity,
long maxSegmentWeight,
StatsCounter statsCounter) {
this.map = map;
this.maxSegmentWeight = maxSegmentWeight;
this.statsCounter = checkNotNull(statsCounter);
initTable(newEntryArray(initialCapacity));
keyReferenceQueue = map.usesKeyReferences() ? new ReferenceQueue<K>() : null;
valueReferenceQueue = map.usesValueReferences() ? new ReferenceQueue<V>() : null;
recencyQueue =
map.usesAccessQueue()
? new ConcurrentLinkedQueue<ReferenceEntry<K, V>>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
writeQueue =
map.usesWriteQueue()
? new WriteQueue<K, V>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
accessQueue =
map.usesAccessQueue()
? new AccessQueue<K, V>()
: LocalCache.<ReferenceEntry<K, V>>discardingQueue();
}
示例7: CapacityEnforcingLinkedHashMap
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
public CapacityEnforcingLinkedHashMap(
int initialCapacity,
float loadFactor,
boolean accessOrder,
long maximumSize,
StatsCounter statsCounter,
@Nullable RemovalListener removalListener) {
super(initialCapacity, loadFactor, accessOrder);
this.maximumSize = maximumSize;
this.statsCounter = statsCounter;
this.removalListener = removalListener;
}
示例8: testEmptySimpleStats
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
public void testEmptySimpleStats() {
StatsCounter counter = new SimpleStatsCounter();
CacheStats stats = counter.snapshot();
assertEquals(0, stats.requestCount());
assertEquals(0, stats.hitCount());
assertEquals(1.0, stats.hitRate());
assertEquals(0, stats.missCount());
assertEquals(0.0, stats.missRate());
assertEquals(0, stats.loadSuccessCount());
assertEquals(0, stats.loadExceptionCount());
assertEquals(0, stats.loadCount());
assertEquals(0, stats.totalLoadTime());
assertEquals(0.0, stats.averageLoadPenalty());
assertEquals(0, stats.evictionCount());
}
示例9: testSingleSimpleStats
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
public void testSingleSimpleStats() {
StatsCounter counter = new SimpleStatsCounter();
for (int i = 0; i < 11; i++) {
counter.recordHits(1);
}
for (int i = 0; i < 13; i++) {
counter.recordLoadSuccess(i);
}
for (int i = 0; i < 17; i++) {
counter.recordLoadException(i);
}
for (int i = 0; i < 23; i++) {
counter.recordMisses(1);
}
for (int i = 0; i < 27; i++) {
counter.recordEviction();
}
CacheStats stats = counter.snapshot();
int requestCount = 11 + 23;
assertEquals(requestCount, stats.requestCount());
assertEquals(11, stats.hitCount());
assertEquals(11.0 / requestCount, stats.hitRate());
int missCount = 23;
assertEquals(missCount, stats.missCount());
assertEquals(((double) missCount) / requestCount, stats.missRate());
assertEquals(13, stats.loadSuccessCount());
assertEquals(17, stats.loadExceptionCount());
assertEquals(13 + 17, stats.loadCount());
assertEquals(214, stats.totalLoadTime());
assertEquals(214.0 / (13 + 17), stats.averageLoadPenalty());
assertEquals(27, stats.evictionCount());
}
示例10: CapacityEnforcingLinkedHashMap
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
public CapacityEnforcingLinkedHashMap(
int initialCapacity,
float loadFactor,
boolean accessOrder,
long maximumSize,
StatsCounter statsCounter,
@NullableDecl RemovalListener removalListener) {
super(initialCapacity, loadFactor, accessOrder);
this.maximumSize = maximumSize;
this.statsCounter = statsCounter;
this.removalListener = removalListener;
}
示例11: createSegment
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
Segment<K, V> createSegment(
int initialCapacity, long maxSegmentWeight, StatsCounter statsCounter) {
return new Segment<K, V>(this, initialCapacity, maxSegmentWeight, statsCounter);
}
示例12: getStatsCounterSupplier
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
Supplier<? extends StatsCounter> getStatsCounterSupplier() {
return statsCounterSupplier;
}
示例13: createSegment
import com.google.common.cache.AbstractCache.StatsCounter; //导入依赖的package包/类
Segment<K, V> createSegment(int initialCapacity, long maxSegmentWeight, StatsCounter statsCounter) {
return new Segment<K, V>(this, initialCapacity, maxSegmentWeight, statsCounter);
}