Skip to content

Switch AVRO InstanceCache to use Caffeine cache #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@
</exclusions>
</dependency>

<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>2.6.1</version>
</dependency>

<!-- include the sources for Parquet -->
<dependency>
<groupId>com.twitter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@
*/
package org.apache.hadoop.hive.serde2.avro;

import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.github.benmanes.caffeine.cache.Cache;

import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
* This is a thread-safe, time-bounded fork of the Hive version.
* This is a thread-safe, size-bounded fork of the Hive version.
* It also includes the correctness fix from HIVE-11288.
*/
public abstract class InstanceCache<K, V>
{
private final Cache<K, V> cache = CacheBuilder.newBuilder()
.expireAfterWrite(1, TimeUnit.MINUTES)
private final Cache<K, V> cache = Caffeine.newBuilder()
.maximumSize(100_000)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to tune Guava cache behavior, if feasible.

.build();

protected InstanceCache() {}
Expand Down