Class BlockManager

java.lang.Object
uk.ac.starlink.fits.BlockManager

public class BlockManager extends Object
Manages access to a region of a file in blocks using multiple BufferManagers to cover it.
Since:
12 May 2022
Author:
Mark Taylor
  • Field Details

    • DEFAULT_BLOCKSIZE

      public static final int DEFAULT_BLOCKSIZE
      Default size of a block.
      See Also:
  • Constructor Details

    • BlockManager

      public BlockManager(FileChannel chan, long offset, long size, String logName, Unmapper unmapper, int blockSize)
      Constructor.
      Parameters:
      chan - file channel
      offset - offset into file of start of mapped region
      size - length of mapped region
      logName - description of mapped region suitable for use in logging messages
      unmapper - used to unmap buffers, may be null for safety
      blockSize - size of each block (except the last)
  • Method Details

    • getBlockCount

      public int getBlockCount()
      Returns the number of blocks used by this mananger.
      Returns:
      block count
    • getBlockSize

      public int getBlockSize()
      Returns the size of blocks used by this manager. All blocks are the same size, except (probably) the last one, which may be shorter.
      Returns:
      block size
    • getBufferManager

      public BufferManager getBufferManager(int ib)
      Returns the BufferManager for a given block.
      Parameters:
      ib - block index
      Returns:
      buffer manager
    • close

      public void close()
      Closes all the BufferManagers maintained by this object. Only use when no buffers will be used any more.