-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use caffeine for iceberg-specific caches
- Loading branch information
Showing
12 changed files
with
228 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
presto-iceberg/src/main/java/com/facebook/presto/iceberg/cache/CaffeineCacheStatsMBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.facebook.presto.iceberg.cache; | ||
|
||
import com.github.benmanes.caffeine.cache.Cache; | ||
import org.weakref.jmx.Managed; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public class CaffeineCacheStatsMBean | ||
{ | ||
private final Cache<?, ?> cache; | ||
|
||
public CaffeineCacheStatsMBean(Cache<?, ?> cache) | ||
{ | ||
this.cache = requireNonNull(cache, "cache is null"); | ||
} | ||
|
||
@Managed | ||
public long getEstimatedSize() | ||
{ | ||
return cache.estimatedSize(); | ||
} | ||
|
||
@Managed | ||
public long getHitCount() | ||
{ | ||
return cache.stats().hitCount(); | ||
} | ||
|
||
@Managed | ||
public long getMissCount() | ||
{ | ||
return cache.stats().missCount(); | ||
} | ||
|
||
@Managed | ||
public double getHitRate() | ||
{ | ||
return cache.stats().hitRate(); | ||
} | ||
|
||
@Managed | ||
public double getMissRate() | ||
{ | ||
return cache.stats().missRate(); | ||
} | ||
|
||
@Managed | ||
public double getEvictionCount() | ||
{ | ||
return cache.stats().evictionCount(); | ||
} | ||
|
||
@Managed | ||
public double getEvictionWeight() | ||
{ | ||
return cache.stats().evictionWeight(); | ||
} | ||
|
||
@Managed | ||
public double getLoadCount() | ||
{ | ||
return cache.stats().loadCount(); | ||
} | ||
|
||
@Managed | ||
public double getRequestCount() | ||
{ | ||
return cache.stats().requestCount(); | ||
} | ||
|
||
@Managed | ||
public double getAverageLoadPenalty() | ||
{ | ||
return cache.stats().averageLoadPenalty(); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
presto-iceberg/src/main/java/com/facebook/presto/iceberg/cache/SimpleForwardingCache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.facebook.presto.iceberg.cache; | ||
|
||
import com.github.benmanes.caffeine.cache.Cache; | ||
import com.github.benmanes.caffeine.cache.Policy; | ||
import com.github.benmanes.caffeine.cache.stats.CacheStats; | ||
import org.checkerframework.checker.index.qual.NonNegative; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentMap; | ||
import java.util.function.Function; | ||
|
||
public class SimpleForwardingCache<K, V> implements Cache<K, V> | ||
{ | ||
private final Cache<K, V> delegate; | ||
|
||
public SimpleForwardingCache(Cache<K, V> delegate) | ||
{ | ||
this.delegate = delegate; | ||
} | ||
|
||
@Override | ||
public @Nullable V getIfPresent(@NonNull Object key) | ||
{ | ||
return delegate.getIfPresent(key); | ||
} | ||
|
||
@Override | ||
public @Nullable V get(@NonNull K key, @NonNull Function<? super K, ? extends V> mappingFunction) | ||
{ | ||
return delegate.get(key, mappingFunction); | ||
} | ||
|
||
@Override | ||
public @NonNull Map<@NonNull K, @NonNull V> getAllPresent(@NonNull Iterable<@NonNull ?> keys) | ||
{ | ||
return delegate.getAllPresent(keys); | ||
} | ||
|
||
@Override | ||
public void put(@NonNull K key, @NonNull V value) | ||
{ | ||
delegate.put(key, value); | ||
} | ||
|
||
@Override | ||
public void putAll(@NonNull Map<? extends @NonNull K, ? extends @NonNull V> map) | ||
{ | ||
delegate.putAll(map); | ||
} | ||
|
||
@Override | ||
public void invalidate(@NonNull Object key) | ||
{ | ||
delegate.invalidate(key); | ||
} | ||
|
||
@Override | ||
public void invalidateAll(@NonNull Iterable<@NonNull ?> keys) | ||
{ | ||
delegate.invalidateAll(keys); | ||
} | ||
|
||
@Override | ||
public void invalidateAll() | ||
{ | ||
delegate.invalidateAll(); | ||
} | ||
|
||
@Override | ||
public @NonNegative long estimatedSize() | ||
{ | ||
return delegate.estimatedSize(); | ||
} | ||
|
||
@Override | ||
public @NonNull CacheStats stats() | ||
{ | ||
return delegate.stats(); | ||
} | ||
|
||
@Override | ||
public @NonNull ConcurrentMap<@NonNull K, @NonNull V> asMap() | ||
{ | ||
return delegate.asMap(); | ||
} | ||
|
||
@Override | ||
public void cleanUp() | ||
{ | ||
delegate.cleanUp(); | ||
} | ||
|
||
@Override | ||
public @NonNull Policy<K, V> policy() | ||
{ | ||
return delegate.policy(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.