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 Details

    • 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 Details

  • Method Details

    • 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 IOException
      Close FileDataIndexCache, this will delete the index file. After that, the index can no longer be read or written.
      Throws:
      IOException