Package uk.ac.starlink.fits
Class BlockManager
java.lang.Object
uk.ac.starlink.fits.BlockManager
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 -
Constructor Summary
ConstructorsConstructorDescriptionBlockManager
(FileChannel chan, long offset, long size, String logName, Unmapper unmapper, int blockSize) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes all the BufferManagers maintained by this object.int
Returns the number of blocks used by this mananger.int
Returns the size of blocks used by this manager.getBufferManager
(int ib) Returns the BufferManager for a given block.
-
Field Details
-
DEFAULT_BLOCKSIZE
public static final int DEFAULT_BLOCKSIZEDefault 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 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 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
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.
-