Class MultiByteBufferInput
java.lang.Object
uk.ac.starlink.fits.BlockInput
uk.ac.starlink.fits.MultiByteBufferInput
- All Implemented Interfaces:
BasicInput
Random-access BasicInput implementation based on a supplied array
of byte buffers.
- Since:
- 19 Mar 2021
- Author:
- Mark Taylor
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ByteBufferacquireBlock(int iblock) Obtains a buffer corresponding to a named block of the stream.voidclose()Releases resources belonging to this object.longgetBlockOffset(int iblock, int offsetInBlock) Returns the offset into this stream corresponding to a given block index and offset into that block.int[]getBlockPos(long offset) Returns the block location of a given byte offset.Methods inherited from class BlockInput
getBlockCount, getOffset, isRandom, readByte, readBytes, readDouble, readFloat, readInt, readLong, readShort, seek, skip
-
Constructor Details
-
MultiByteBufferInput
Constructor.- Parameters:
bufs- byte buffers holding data
-
-
Method Details
-
getBlockPos
public int[] getBlockPos(long offset) Description copied from class:BlockInputReturns the block location of a given byte offset.This does the opposite of
getBlockOffset.- Specified by:
getBlockPosin classBlockInput- Parameters:
offset- offset into this input stream- Returns:
- 2-element array giving [blockIndex, offsetInBlock]
-
getBlockOffset
public long getBlockOffset(int iblock, int offsetInBlock) Description copied from class:BlockInputReturns the offset into this stream corresponding to a given block index and offset into that block.This does the opposite of
getBlockPos.- Specified by:
getBlockOffsetin classBlockInput- Parameters:
iblock- block indexoffsetInBlock- offset into that block- Returns:
- offset into stream
-
acquireBlock
Description copied from class:BlockInputObtains a buffer corresponding to a named block of the stream. The buffer's position must be zero. This method is called whenever a buffer is required which is not the same as the most recently used one.- Specified by:
acquireBlockin classBlockInput- Parameters:
iblock- block index- Returns:
- byte buffer for given block, positioned at start
-
close
public void close()Description copied from interface:BasicInputReleases resources belonging to this object. Attempts to use it after a call to this method result in undefined behaviour.- Specified by:
closein interfaceBasicInput- Overrides:
closein classBlockInput
-