Java 类com.google.common.cache.AbstractCache.StatsCounter 实例源码

项目:codebuff    文件:LocalCache.java   
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();
}
项目:codebuff    文件:LocalCache.java   
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();
}
项目:codebuff    文件:LocalCache.java   
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();
}
项目:codebuff    文件:LocalCache.java   
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();
}
项目:codebuff    文件:LocalCache.java   
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();
}
项目:bts    文件:LocalCache.java   
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();
}
项目:j2objc    文件:LocalCache.java   
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();
}
项目:guava-libraries    文件:LocalCache.java   
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();
}
项目:VectorAttackScanner    文件:LocalCache.java   
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();
}
项目:cnGuava    文件:LocalCache.java   
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();
}
项目:org.openntf.domino    文件:LocalCache.java   
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();
}
项目:guava-mock    文件:LocalCache.java   
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();
}
项目:guava-mock    文件:LocalCache.java   
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;
}
项目:guava-mock    文件:AbstractCacheTest.java   
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());
}
项目:guava-mock    文件:AbstractCacheTest.java   
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());
}
项目:googles-monorepo-demo    文件:LocalCache.java   
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();
}
项目:googles-monorepo-demo    文件:LocalCache.java   
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;
}
项目:googles-monorepo-demo    文件:AbstractCacheTest.java   
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());
}
项目:googles-monorepo-demo    文件:AbstractCacheTest.java   
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());
}
项目:codebuff    文件:LocalCache.java   
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();
}
项目:guava-libraries    文件:LocalCache.java   
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;
}
项目:guava-libraries    文件:AbstractCacheTest.java   
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());
}
项目:guava-libraries    文件:AbstractCacheTest.java   
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());
}
项目:guava    文件:LocalCache.java   
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();
}
项目:guava    文件:LocalCache.java   
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;
}
项目:guava    文件:LocalCache.java   
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();
}
项目:guava    文件:AbstractCacheTest.java   
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());
}
项目:guava    文件:AbstractCacheTest.java   
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());
}
项目:guava    文件:AbstractCacheTest.java   
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());
}
项目:guava    文件:AbstractCacheTest.java   
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());
}
项目:guava-mock    文件:LocalCache.java   
Segment<K, V> createSegment(
    int initialCapacity, long maxSegmentWeight, StatsCounter statsCounter) {
  return new Segment<K, V>(this, initialCapacity, maxSegmentWeight, statsCounter);
}
项目:guava-mock    文件:CacheBuilder.java   
Supplier<? extends StatsCounter> getStatsCounterSupplier() {
  return statsCounterSupplier;
}
项目:googles-monorepo-demo    文件:LocalCache.java   
Segment<K, V> createSegment(
    int initialCapacity, long maxSegmentWeight, StatsCounter statsCounter) {
  return new Segment<K, V>(this, initialCapacity, maxSegmentWeight, statsCounter);
}
项目:googles-monorepo-demo    文件:CacheBuilder.java   
Supplier<? extends StatsCounter> getStatsCounterSupplier() {
  return statsCounterSupplier;
}
项目:codebuff    文件:LocalCache.java   
Segment<K, V> createSegment(int initialCapacity, long maxSegmentWeight, StatsCounter statsCounter) {
  return new Segment<K, V>(this, initialCapacity, maxSegmentWeight, statsCounter);
}
项目:codebuff    文件:CacheBuilder.java   
Supplier<? extends StatsCounter> getStatsCounterSupplier() {
  return statsCounterSupplier;
}
项目:codebuff    文件:LocalCache.java   
Segment<K, V> createSegment(int initialCapacity, long maxSegmentWeight, StatsCounter statsCounter) {
  return new Segment<K, V>(this, initialCapacity, maxSegmentWeight, statsCounter);
}
项目:codebuff    文件:CacheBuilder.java   
Supplier<? extends StatsCounter> getStatsCounterSupplier() {
  return statsCounterSupplier;
}
项目:codebuff    文件:LocalCache.java   
Segment<K, V> createSegment(int initialCapacity, long maxSegmentWeight, StatsCounter statsCounter) {
  return new Segment<K, V>(this, initialCapacity, maxSegmentWeight, statsCounter);
}
项目:codebuff    文件:CacheBuilder.java   
Supplier<? extends StatsCounter> getStatsCounterSupplier() {
  return statsCounterSupplier;
}