Class FileDataIndexCache<T extends FileDataIndexRegionHelper.Region>
- java.lang.Object
-
- org.apache.flink.runtime.io.network.partition.hybrid.index.FileDataIndexCache<T>
-
public class FileDataIndexCache<T extends FileDataIndexRegionHelper.Region> extends Object
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 Modifier and Type Field Description static ObjectPLACEHOLDERPlaceholder of cache entry's value.
-
Constructor Summary
Constructors Constructor Description FileDataIndexCache(int numSubpartitions, Path indexFilePath, long numRetainedInMemoryRegionsMax, FileDataIndexSpilledRegionManager.Factory<T> spilledRegionManagerFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()CloseFileDataIndexCache, this will delete the index file.Optional<T>get(int subpartitionId, int bufferIndex)Get a region contains target bufferIndex and belong to target subpartition.voidput(int subpartition, List<T> fileRegions)Put regions to cache.
-
-
-
Field Detail
-
PLACEHOLDER
public static final Object 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 Detail
-
FileDataIndexCache
public FileDataIndexCache(int numSubpartitions, Path indexFilePath, long numRetainedInMemoryRegionsMax, FileDataIndexSpilledRegionManager.Factory<T> spilledRegionManagerFactory)
-
-
Method Detail
-
get
public Optional<T> get(int subpartitionId, int bufferIndex)
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
public void put(int subpartition, List<T> fileRegions)Put regions to cache.- Parameters:
subpartition- the subpartition's id of regions.fileRegions- regions to be cached.
-
close
public void close() throws IOExceptionCloseFileDataIndexCache, this will delete the index file. After that, the index can no longer be read or written.- Throws:
IOException
-
-