Package uk.ac.starlink.fits
Class BlockManager
- java.lang.Object
-
- uk.ac.starlink.fits.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.
-
-
-
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 channeloffset
- offset into file of start of mapped regionsize
- length of mapped regionlogName
- description of mapped region suitable for use in logging messagesunmapper
- used to unmap buffers, may be null for safetyblockSize
- 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.
-
-