Class FileDataIndexCache<T extends FileDataIndexRegionHelper.Region>
java.lang.Object
org.apache.flink.runtime.io.network.partition.hybrid.index.FileDataIndexCache<T>
A cache layer of hybrid data index. This class encapsulates the logic of the index's put and get,
and automatically caches some indexes in memory. When there are too many cached indexes, it is
this class's responsibility to decide and eliminate some indexes to disk.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFileDataIndexCache(int numSubpartitions, Path indexFilePath, long numRetainedInMemoryRegionsMax, FileDataIndexSpilledRegionManager.Factory<T> spilledRegionManagerFactory) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()CloseFileDataIndexCache, this will delete the index file.get(int subpartitionId, int bufferIndex) Get a region contains target bufferIndex and belong to target subpartition.voidPut regions to cache.
-
Field Details
-
PLACEHOLDER
Placeholder of cache entry's value. Because the cache is only used for managing region's elimination, does not need the real region as value.
-
-
Constructor Details
-
FileDataIndexCache
public FileDataIndexCache(int numSubpartitions, Path indexFilePath, long numRetainedInMemoryRegionsMax, FileDataIndexSpilledRegionManager.Factory<T> spilledRegionManagerFactory)
-
-
Method Details
-
get
Get a region contains target bufferIndex and belong to target subpartition.- Parameters:
subpartitionId- the subpartition that target buffer belong to.bufferIndex- the index of target buffer.- Returns:
- If target region can be founded from memory or disk, return optional contains target
region. Otherwise, return
Optional#empty();
-
put
Put regions to cache.- Parameters:
subpartition- the subpartition's id of regions.fileRegions- regions to be cached.
-
close
CloseFileDataIndexCache, this will delete the index file. After that, the index can no longer be read or written.- Throws:
IOException
-