Class MmappedRegionsCache

java.lang.Object
org.apache.cassandra.io.util.MmappedRegionsCache
All Implemented Interfaces:
AutoCloseable

@NotThreadSafe public class MmappedRegionsCache extends Object implements AutoCloseable
It is a utility class for caching MmappedRegions primarily used by a FileHandle.Builder when a handle to the same file is created multiple times (as when an sstable is opened early).
  • Constructor Details

    • MmappedRegionsCache

      public MmappedRegionsCache()
  • Method Details

    • getOrCreate

      public MmappedRegions getOrCreate(ChannelProxy channel, long length, int bufferSize)
      Looks for mmapped regions in cache. If found, a shared copy is created and extended to the provided length. If mmapped regions do not exist yet for the provided key, they are created and a shared copy is returned.
      Parameters:
      channel - channel for which the mmapped regions are requested
      length - length of the file
      Returns:
      a shared copy of the cached mmapped regions
    • getOrCreate

      public MmappedRegions getOrCreate(ChannelProxy channel, CompressionMetadata metadata, int bufferSize)
      Looks for mmapped regions in cache. If found, a shared copy is created and extended according to the provided metadata. If mmapped regions do not exist yet for the provided key, they are created and a shared copy is returned.
      Parameters:
      channel - channel for which the mmapped regions are requested
      metadata - compression metadata of the file
      Returns:
      a shared copy of the cached mmapped regions
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable