From 9356086d5609c45c5d6c39b37e3e606e5069b6f8 Mon Sep 17 00:00:00 2001 From: Ben Manes Date: Tue, 27 Feb 2024 11:08:23 -0800 Subject: [PATCH] fix minor warnings (grammar, code, test stabilization) --- README.md | 4 ++-- .../github/benmanes/caffeine/cache/AsyncCache.java | 14 +++++++------- .../benmanes/caffeine/cache/BoundedLocalCache.java | 2 +- .../benmanes/caffeine/cache/CacheLoader.java | 2 +- .../github/benmanes/caffeine/cache/Caffeine.java | 4 ++-- .../github/benmanes/caffeine/cache/Interner.java | 2 +- .../benmanes/caffeine/cache/LinkedDeque.java | 4 ++-- .../benmanes/caffeine/cache/LocalAsyncCache.java | 2 +- .../com/github/benmanes/caffeine/cache/Policy.java | 2 +- .../caffeine/cache/UnboundedLocalCache.java | 4 ++-- .../benmanes/caffeine/cache/AsyncCacheTest.java | 10 ++++++---- examples/coalescing-bulkloader-reactor/README.md | 2 +- .../java-library-caffeine-conventions.gradle.kts | 2 +- .../errorprone-caffeine-conventions.gradle.kts | 2 +- .../benmanes/caffeine/jcache/CacheProxy.java | 4 ++-- .../configuration/CaffeineConfiguration.java | 2 +- .../caffeine/jcache/event/EventDispatcher.java | 2 +- .../caffeine/jcache/event/JCacheEntryEvent.java | 2 +- .../countmin4/IndicatorResetCountMin4.java | 2 +- .../table/RandomRemovalFrequencyTable.java | 4 ++-- .../admission/tinycache/TinySetIndexing.java | 2 +- .../cache/simulator/policy/PolicyActor.java | 2 +- .../simulator/policy/greedy_dual/GdsfPolicy.java | 2 +- .../simulator/policy/irr/ClockProPlusPolicy.java | 2 +- .../cache/simulator/policy/irr/ClockProPolicy.java | 2 +- .../simulator/policy/irr/ClockProSimplePolicy.java | 4 ++-- .../cache/simulator/policy/linked/S4LruPolicy.java | 2 +- .../cache/simulator/policy/sketch/Indicator.java | 4 ++-- 28 files changed, 47 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 03b585d41a..c25d156f58 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Powering infrastructure near you: * An in-depth description of Caffeine's architecture. * [Design of a Modern Cache: part #1][modern-cache-1], [part #2][modern-cache-2] - ([slides][modern-cache-slides]) at [HighScalability][HighScalability] + ([slides][modern-cache-slides]) at [HighScalability][] * Caffeine is presented as part of research papers evaluating its novel eviction policy. * [TinyLFU: A Highly Efficient Cache Admission Policy][tinylfu] by Gil Einziger, Roy Friedman, Ben Manes @@ -136,7 +136,7 @@ Snapshots of the development version are available in [modern-cache-1]: http://highscalability.com/blog/2016/1/25/design-of-a-modern-cache.html [modern-cache-2]: http://highscalability.com/blog/2019/2/25/design-of-a-modern-cachepart-deux.html [modern-cache-slides]: https://docs.google.com/presentation/d/1NlDxyXsUG1qlVHMl4vsUUBQfAJ2c2NsFPNPr2qymIBs -[highscalability]: http://highscalability.com +[HighScalability]: http://highscalability.com [spring]: https://docs.spring.io/spring/docs/current/spring-framework-reference/integration.html#cache-store-configuration-caffeine [scala-cache]: https://github.com/cb372/scalacache [scaffeine]: https://github.com/blemale/scaffeine diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncCache.java index ecc1ef3d8e..6fd3e1174d 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/AsyncCache.java @@ -100,9 +100,9 @@ CompletableFuture get(K key, BiFunction * A single request to the {@code mappingFunction} is performed for all keys which are not already * present in the cache. If another call to {@link #get} tries to load the value for a key in @@ -128,10 +128,10 @@ CompletableFuture> getAll(Iterable keys, /** * Returns the future of a map of the values associated with the {@code keys}, creating or * retrieving those values if necessary. The returned map contains entries that were already - * cached, combined with newly loaded entries; it will never contain null keys or values. If the - * any of the asynchronous computations fail, those entries will be automatically removed from - * this cache. The instances returned from the {@code mappingFunction} will be stored directly - * into the cache. + * cached, combined with newly loaded entries; it will never contain null keys or values. If any + * of the asynchronous computations fail, those entries will be automatically removed from this + * cache. The instances returned from the {@code mappingFunction} will be stored directly into the + * cache. *

* A single request to the {@code mappingFunction} is performed for all keys which are not already * present in the cache. If another call to {@link #get} tries to load the value for a key in diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java index 3dd867609b..f0748f8244 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/BoundedLocalCache.java @@ -3864,7 +3864,7 @@ static final class PerformCleanupTask extends ForkJoinTask implements Runn final WeakReference> reference; PerformCleanupTask(BoundedLocalCache cache) { - reference = new WeakReference>(cache); + reference = new WeakReference<>(cache); } @Override diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/CacheLoader.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/CacheLoader.java index 3853e25273..42bdfd02fa 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/CacheLoader.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/CacheLoader.java @@ -225,7 +225,7 @@ default CompletableFuture asyncReload( static CacheLoader bulk(Function, ? extends Map> mappingFunction) { requireNonNull(mappingFunction); - return new CacheLoader() { + return new CacheLoader<>() { @Override public @Nullable V load(K key) { return loadAll(Set.of(key)).get(key); } diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java index bada3969e4..fa0f5512c7 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Caffeine.java @@ -1163,8 +1163,8 @@ public AsyncLoadingCache buildAsync( @SuppressWarnings("unchecked") Caffeine self = (Caffeine) this; return isBounded() || refreshAfterWrite() - ? new BoundedLocalCache.BoundedLocalAsyncLoadingCache(self, loader) - : new UnboundedLocalCache.UnboundedLocalAsyncLoadingCache(self, loader); + ? new BoundedLocalCache.BoundedLocalAsyncLoadingCache<>(self, loader) + : new UnboundedLocalCache.UnboundedLocalAsyncLoadingCache<>(self, loader); } void requireNonLoadingCache() { diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Interner.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Interner.java index 2cdcd95c0c..f995c60ccb 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Interner.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Interner.java @@ -153,7 +153,7 @@ final class Interned extends Node implements NodeFactory { return new LookupKeyEqualsReference<>(key); } @Override public Object newReferenceKey(K key, ReferenceQueue referenceQueue) { - return new WeakKeyEqualsReference(key, referenceQueue); + return new WeakKeyEqualsReference<>(key, referenceQueue); } @Override public boolean isAlive() { Object keyRef = keyReference; diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LinkedDeque.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LinkedDeque.java index 379e2733e5..28b35c38ff 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LinkedDeque.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LinkedDeque.java @@ -109,7 +109,7 @@ interface PeekingIterator extends Iterator { /** Returns an iterator that returns the first iteration followed by the second iteration. */ static PeekingIterator concat(PeekingIterator first, PeekingIterator second) { - return new PeekingIterator() { + return new PeekingIterator<>() { @Override public boolean hasNext() { return first.hasNext() || second.hasNext(); } @@ -130,7 +130,7 @@ static PeekingIterator concat(PeekingIterator first, PeekingIterator PeekingIterator comparing(PeekingIterator first, PeekingIterator second, Comparator comparator) { - return new PeekingIterator() { + return new PeekingIterator<>() { @Override public boolean hasNext() { return first.hasNext() || second.hasNext(); } diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java index 367398d459..998a794c50 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/LocalAsyncCache.java @@ -1102,7 +1102,7 @@ public void forEach(Consumer action) { @Override public Iterator iterator() { - return new Iterator() { + return new Iterator<>() { final Iterator> iterator = entrySet().iterator(); @Override diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Policy.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Policy.java index 0f78860af0..6aea53eef9 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Policy.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/Policy.java @@ -835,7 +835,7 @@ default void setRefreshesAfter(Duration duration) { * A key-value pair that may include policy metadata for the cached entry. Unless otherwise * specified, this is a value-based class, it can be assumed that the implementation is an * immutable snapshot of the cached data at the time of this entry's creation, and it will not - * reflect changes afterwards. + * reflect changes afterward. */ interface CacheEntry extends Map.Entry { diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java index f4001d2f05..5d6b649922 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/cache/UnboundedLocalCache.java @@ -990,7 +990,7 @@ static final class EntrySpliterator implements Spliterator> { public void forEachRemaining(Consumer> action) { requireNonNull(action); spliterator.forEachRemaining(entry -> { - var e = new WriteThroughEntry(cache, entry.getKey(), entry.getValue()); + var e = new WriteThroughEntry<>(cache, entry.getKey(), entry.getValue()); action.accept(e); }); } @@ -999,7 +999,7 @@ public void forEachRemaining(Consumer> action) { public boolean tryAdvance(Consumer> action) { requireNonNull(action); return spliterator.tryAdvance(entry -> { - var e = new WriteThroughEntry(cache, entry.getKey(), entry.getValue()); + var e = new WriteThroughEntry<>(cache, entry.getKey(), entry.getValue()); action.accept(e); }); } diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/AsyncCacheTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/AsyncCacheTest.java index 0c2d91eea9..eccfb5ca61 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/AsyncCacheTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/AsyncCacheTest.java @@ -488,7 +488,7 @@ public void getAllFunction_exceeds(AsyncCache cache, CacheContext cont for (int i = 0; i < 10; i++) { moreKeys.add(Int.valueOf(ThreadLocalRandom.current().nextInt())); } - return Maps.toMap(moreKeys, Int::negate); + return CacheContext.intern(Maps.toMap(moreKeys, Int::negate)); }).join(); assertThat(result).containsExactlyKeys(context.absentKeys()); @@ -580,7 +580,7 @@ public void getAllFunction_present_ordered_exceeds( for (int i = 0; i < 10; i++) { moreKeys.add(Int.valueOf(ThreadLocalRandom.current().nextInt())); } - return Maps.toMap(moreKeys, Int::negate); + return CacheContext.intern(Maps.toMap(moreKeys, Int::negate)); }).join(); assertThat(result).containsExactlyKeys(keys).inOrder(); } @@ -808,7 +808,8 @@ public void getAllBifunction_exceeds(AsyncCache cache, CacheContext co for (int i = 0; i < 10; i++) { moreKeys.add(Int.valueOf(ThreadLocalRandom.current().nextInt())); } - return CompletableFuture.completedFuture(Maps.toMap(moreKeys, Int::negate)); + var results = CacheContext.intern(Maps.toMap(moreKeys, Int::negate)); + return CompletableFuture.completedFuture(results); }).join(); assertThat(result).containsExactlyKeys(context.absentKeys()); @@ -958,7 +959,8 @@ public void getAllBifunction_present_ordered_exceeds( for (int i = 0; i < 10; i++) { moreKeys.add(Int.valueOf(ThreadLocalRandom.current().nextInt())); } - return CompletableFuture.completedFuture(Maps.toMap(moreKeys, Int::negate)); + var results = CacheContext.intern(Maps.toMap(moreKeys, Int::negate)); + return CompletableFuture.completedFuture(results); }).join(); assertThat(result).containsExactlyKeys(keys).inOrder(); } diff --git a/examples/coalescing-bulkloader-reactor/README.md b/examples/coalescing-bulkloader-reactor/README.md index c1995a86eb..15baa0a132 100644 --- a/examples/coalescing-bulkloader-reactor/README.md +++ b/examples/coalescing-bulkloader-reactor/README.md @@ -64,7 +64,7 @@ while the optimistic reloads are instead submitted to the sink. It's worth notin } ``` -The subscriber receives a batch of requests, each comprising of a key and a pending future result. +The subscriber receives a batch of requests, each consisting of a key and a pending future result. It performs the synchronous load and then either completes the key's future with the corresponding value or an exception if a failure occurs. diff --git a/gradle/plugins/src/main/kotlin/lifecycle/java-library-caffeine-conventions.gradle.kts b/gradle/plugins/src/main/kotlin/lifecycle/java-library-caffeine-conventions.gradle.kts index a1c4055d7f..1fbae9ef22 100644 --- a/gradle/plugins/src/main/kotlin/lifecycle/java-library-caffeine-conventions.gradle.kts +++ b/gradle/plugins/src/main/kotlin/lifecycle/java-library-caffeine-conventions.gradle.kts @@ -78,7 +78,7 @@ tasks.jar { } tasks.withType().configureEach { - setFailOnError(false) + isFailOnError = false javadocOptions { links( "https://checkerframework.org/api/", diff --git a/gradle/plugins/src/main/kotlin/quality/errorprone-caffeine-conventions.gradle.kts b/gradle/plugins/src/main/kotlin/quality/errorprone-caffeine-conventions.gradle.kts index ea90028275..6b9e5e51b5 100644 --- a/gradle/plugins/src/main/kotlin/quality/errorprone-caffeine-conventions.gradle.kts +++ b/gradle/plugins/src/main/kotlin/quality/errorprone-caffeine-conventions.gradle.kts @@ -21,7 +21,7 @@ dependencies { } // Gradle rewrites ErrorProne's dependency on Caffeine to a project dependency, which then fails. -// Instead we have to download and trick the build to put the jar on the compiler's classpath. +// Instead, we have to download and trick the build to put the jar on the compiler's classpath. val downloadCaffeine by tasks.registering { val version = libs.versions.caffeine.get() inputs.property("version", version) diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java index 28a9357444..3c7d231cd6 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/CacheProxy.java @@ -212,7 +212,7 @@ public Map getAll(Set keys) { */ protected Map> getAndFilterExpiredEntries( Set keys, boolean updateAccessTime) { - var result = new HashMap>(cache.getAllPresent(keys)); + var result = new HashMap<>(cache.getAllPresent(keys)); int[] expired = { 0 }; long[] millis = { 0L }; @@ -1238,7 +1238,7 @@ public Cache.Entry next() { current = cursor; cursor = null; @SuppressWarnings("NullAway") - var entry = new EntryProxy(copyOf(current.getKey()), copyValue(current.getValue())); + var entry = new EntryProxy<>(copyOf(current.getKey()), copyValue(current.getValue())); return entry; } diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/configuration/CaffeineConfiguration.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/configuration/CaffeineConfiguration.java index cd1fb235ab..64cef3fcaa 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/configuration/CaffeineConfiguration.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/configuration/CaffeineConfiguration.java @@ -638,7 +638,7 @@ private UnmodifiableIterable(Iterable delegate) { } @Override public Iterator iterator() { var iterator = delegate.iterator(); - return new Iterator() { + return new Iterator<>() { @Override public boolean hasNext() { return iterator.hasNext(); } diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/EventDispatcher.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/EventDispatcher.java index 561e51d5a0..175d50e194 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/EventDispatcher.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/EventDispatcher.java @@ -99,7 +99,7 @@ public void register(CacheEntryListenerConfiguration configuration) { configuration.getCacheEntryEventFilterFactory().create()); } - var registration = new Registration(configuration, filter, listener); + var registration = new Registration<>(configuration, filter, listener); dispatchQueues.putIfAbsent(registration, new ConcurrentHashMap<>()); } diff --git a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/JCacheEntryEvent.java b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/JCacheEntryEvent.java index be5dde40fa..0ea9941329 100644 --- a/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/JCacheEntryEvent.java +++ b/jcache/src/main/java/com/github/benmanes/caffeine/jcache/event/JCacheEntryEvent.java @@ -82,7 +82,7 @@ public T unwrap(Class clazz) { @Override public Iterator> iterator() { - return new Iterator>() { + return new Iterator<>() { boolean hasNext = true; @Override diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/countmin4/IndicatorResetCountMin4.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/countmin4/IndicatorResetCountMin4.java index 3dbc449cd6..4a97b70fea 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/countmin4/IndicatorResetCountMin4.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/countmin4/IndicatorResetCountMin4.java @@ -30,7 +30,7 @@ public final class IndicatorResetCountMin4 implements Frequency { private final ClimberResetCountMin4 sketch; - Indicator indicator; + final Indicator indicator; public IndicatorResetCountMin4(Config config) { this.sketch = new ClimberResetCountMin4(config); diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/table/RandomRemovalFrequencyTable.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/table/RandomRemovalFrequencyTable.java index 5b003c2a2f..aaaf6a94e8 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/table/RandomRemovalFrequencyTable.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/table/RandomRemovalFrequencyTable.java @@ -30,7 +30,7 @@ * maximum frequency of an element. The size of the sample in relation to the cache size can be * controlled with a sample factor. Instead of halving the popularity of elements a random element * is dropped when table is full. - * + *

* This class is used to check the feasibility of using TinyTable instead of CountMin Sketch. * * @author gilg1983@gmail.com (Gil Einziger) @@ -39,7 +39,7 @@ public final class RandomRemovalFrequencyTable implements Frequency { /** controls both the max count and how many items are remembered (the sum) */ private static final int sampleFactor = 8; - /** a place holder for TinyTable */ + /** a placeholder for TinyTable */ private final Map table; /** used to dropped items at random */ private final Random random; diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/tinycache/TinySetIndexing.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/tinycache/TinySetIndexing.java index 4d1531378d..2890adddcb 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/tinycache/TinySetIndexing.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/admission/tinycache/TinySetIndexing.java @@ -24,7 +24,7 @@ * empty) isLastIndex (set bit for last in chain/empty bit for not last in chain). Both indexes are * assumed to be 64 bits, (longs) for efficiency and simplicity. The technique update the indexes * upon addition/removal. - * + *

* Paper link: * http://www.cs.technion.ac.il/users/wwwb/cgi-bin/tr-get.cgi/2015/CS/CS-2015-03.pdf * Presentation: diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/PolicyActor.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/PolicyActor.java index e3b0f4d541..b51d54529b 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/PolicyActor.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/PolicyActor.java @@ -107,7 +107,7 @@ private final class Execute extends Command { } } - /** A command to shutdown the policy and finalize the statistics. */ + /** A command to shut down the policy and finalize the statistics. */ private final class Finish extends Command { @Override public void execute() { policy.finished(); diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GdsfPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GdsfPolicy.java index 7c403ca49d..b91d84af49 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GdsfPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/greedy_dual/GdsfPolicy.java @@ -130,7 +130,7 @@ private void evict(Node candidate) { // If f is among {f1, f2, ... fk}, it is simply not cached and removed from the priority // queue, while none of the files already in the cache is evicted. This happens when the value // of Pr(f) is so low that it would put f (if cached) among the first candidates for - // replacement, e.g. when the file size is very large. Thus the proposed procedure will + // replacement, e.g. when the file size is very large. Thus, the proposed procedure will // automatically limit the cases when such files are cached policyStats.recordRejection(); remove(candidate); diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProPlusPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProPlusPolicy.java index ca6bc7d4d0..a96e251940 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProPlusPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProPlusPolicy.java @@ -32,7 +32,7 @@ * with the utility-driven adaption idea borrowed from CAR. The algorithm is explained by the * authors in CLOCK-Pro+: improving * CLOCK-Pro cache replacement with utility-driven adaptation. - * + *

* Implementation here differs from ClockProPolicy only in adjusting coldTarget and tracking for * demoted status part. Below is a summary of coldTarget adjusting differences between ClockPro * and ClockPro+. diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProPolicy.java index 3904dccde5..cf8a2730a2 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProPolicy.java @@ -34,7 +34,7 @@ * scanned. *

* ClockPro uses three hands that scan the queue. The hot hand points to the largest recency, the - * cold hand to the cold entry furthest from the hot hand, and the test hand to the last cold entry + * cold hand to the cold entry farthest from the hot hand, and the test hand to the last cold entry * in the test period. This policy is adaptive by adjusting the percentage of hot and cold entries * that may reside in the cache. It uses non-resident (ghost) entries to retain additional history, * which are removed during the test hand's scan. The algorithm is explained by the authors in diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProSimplePolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProSimplePolicy.java index 3f3d6ca758..e7743bedf0 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProSimplePolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/irr/ClockProSimplePolicy.java @@ -35,7 +35,7 @@ * scanned. *

* ClockPro uses three hands that scan the queue. The hot hand points to the largest recency, the - * cold hand to the cold entry furthest from the hot hand, and the test hand to the last cold entry + * cold hand to the cold entry farthest from the hot hand, and the test hand to the last cold entry * in the test period. This policy is adaptive by adjusting the percentage of hot and cold entries * that may reside in the cache. It uses non-resident (ghost) entries to retain additional history, * which are removed during the test hand's scan. The algorithm is explained by the authors in @@ -43,7 +43,7 @@ * Effective Improvement of the CLOCK Replacement and * Clock-Pro: An Effective Replacement in OS * Kernel. - * + *

* This implementation works exactly like ClockPro, but pursues the simplicity of the code. * It divides a single list of ClockPro into three lists: hot, cold, and non-resident. * For maintaining a test period of each entry, it uses epoch. diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/linked/S4LruPolicy.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/linked/S4LruPolicy.java index 0df3b8856f..5063aecb12 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/linked/S4LruPolicy.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/linked/S4LruPolicy.java @@ -40,7 +40,7 @@ * higher queue (items in queue 3 move to the head of queue 3). Each queue is allocated 1/4 of the * total cache size and items are evicted from the tail of a queue to the head of the next lower * queue to maintain the size invariants. Items evicted from queue 0 are evicted from the cache." - * + *

* For more details, see An * Analysis of Facebook Photo Caching. * diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/Indicator.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/Indicator.java index 11dd6d750d..2195d1ddf4 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/Indicator.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/policy/sketch/Indicator.java @@ -108,7 +108,7 @@ private final class EstSkew { StreamSummary stream; public EstSkew() { - this.stream = new StreamSummary(ssSize); + this.stream = new StreamSummary<>(ssSize); } public void record(long key) { @@ -116,7 +116,7 @@ public void record(long key) { } public void reset() { - this.stream = new StreamSummary(ssSize); + this.stream = new StreamSummary<>(ssSize); } public IntStream getTopK(int k) {