Class BlockManager


  • public class BlockManager
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_BLOCKSIZE
      Default size of a block.
    • Constructor Summary

      Constructors 
      Constructor Description
      BlockManager​(java.nio.channels.FileChannel chan, long offset, long size, java.lang.String logName, Unmapper unmapper, int blockSize)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes all the BufferManagers maintained by this object.
      int getBlockCount()
      Returns the number of blocks used by this mananger.
      int getBlockSize()
      Returns the size of blocks used by this manager.
      BufferManager getBufferManager​(int ib)
      Returns the BufferManager for a given block.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_BLOCKSIZE

        public static final int DEFAULT_BLOCKSIZE
        Default size of a block.
        See Also:
        Constant Field Values
    • Constructor Detail

      • BlockManager

        public BlockManager​(java.nio.channels.FileChannel chan,
                            long offset,
                            long size,
                            java.lang.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 Detail

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