Class FileDataIndexCache<T extends FileDataIndexRegionHelper.Region>


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