Class ContentCache
The file-content caching is initiated by calling tryCache(InputFile)
.
Given a FileIO, a file location string, and file length that is within allowed limit,
ContentCache will return a ContentCache.CachingInputFile
that is backed by the cache. Calling InputFile.newStream()
will return a ByteBufferInputStream
backed by list of
ByteBuffer
from the cache if such file-content exist in the cache. If the file-content
does not exist in the cache yet, a regular InputFile will be instantiated, read-ahead, and loaded
into the cache before returning ByteBufferInputStream. The regular InputFile is also used as a
fallback if cache loading fail.
-
Constructor Summary
ConstructorDescriptionContentCache
(long expireAfterAccessMs, long maxTotalBytes, long maxContentLength) Constructor for ContentCache class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanUp()
long
long
org.apache.iceberg.io.ContentCache.CacheEntry
Deprecated.org.apache.iceberg.io.ContentCache.CacheEntry
getIfPresent
(String location) Deprecated.will be removed in 1.7; usetryCache(InputFile)
insteadvoid
invalidate
(String key) void
long
long
com.github.benmanes.caffeine.cache.stats.CacheStats
stats()
toString()
Deprecated.will be removed in 1.7; usetryCache(InputFile)
insteadTry cache the file-content of file in the given location upon stream reading.
-
Constructor Details
-
ContentCache
public ContentCache(long expireAfterAccessMs, long maxTotalBytes, long maxContentLength) Constructor for ContentCache class.- Parameters:
expireAfterAccessMs
- controls the duration for which entries in the ContentCache are hold since last access. Must be greater or equal than 0. Setting 0 means cache entries expire only if it gets evicted due to memory pressure.maxTotalBytes
- controls the maximum total amount of bytes to cache in ContentCache. Must be greater than 0.maxContentLength
- controls the maximum length of file to be considered for caching. Must be greater than 0.
-
-
Method Details
-
expireAfterAccess
public long expireAfterAccess() -
maxContentLength
public long maxContentLength() -
maxTotalBytes
public long maxTotalBytes() -
stats
public com.github.benmanes.caffeine.cache.stats.CacheStats stats() -
get
@Deprecated public org.apache.iceberg.io.ContentCache.CacheEntry get(String key, Function<String, org.apache.iceberg.io.ContentCache.FileContent> mappingFunction) Deprecated.will be removed in 1.7; usetryCache(InputFile)
instead -
getIfPresent
Deprecated.will be removed in 1.7; usetryCache(InputFile)
instead -
tryCache
Deprecated.will be removed in 1.7; usetryCache(InputFile)
instead -
tryCache
Try cache the file-content of file in the given location upon stream reading.If length is longer than maximum length allowed by ContentCache, a regular
InputFile
and no caching will be done for that file. Otherwise, this method will return aContentCache.CachingInputFile
that serve file reads backed by ContentCache.- Parameters:
input
- an InputFile to cache- Returns:
- a
ContentCache.CachingInputFile
if length is within allowed limit. Otherwise, a regularInputFile
for given location.
-
invalidate
-
invalidateAll
public void invalidateAll() -
cleanUp
public void cleanUp() -
estimatedCacheSize
public long estimatedCacheSize() -
toString
-
tryCache(InputFile)
instead