Class FitsHeap
java.lang.Object
nom.tam.fits.FitsHeap
- All Implemented Interfaces:
FitsElement
This class supports the FITS heap. This is currently used for variable length
columns in binary tables.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BufferedDataInputStreamA stream used to read the heap dataprivate byte[]The storage bufferprivate intOur current offset into the heap.private intThe current used size of the buffer invalid input: '<'= heap.lengthprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidallocate()(package private) FitsHeapcopy()Add a copy constructor to allow us to duplicate a heap.(package private) voidexpandHeap(int need) Check if the Heap can accommodate a given requirement.voidGet data from the heap.longGet the file offset of the heaplonggetSize()Return the size of the heap using the more bean compatible format(package private) intAdd some data to the heap.voidread(ArrayDataInput str) Read the heapbooleanreset()Reset the input stream to point to the beginning of this elementvoidrewrite()Rewrite the contents of the element in place.booleanintsize()voidwrite(ArrayDataOutput str) Write the heap
-
Field Details
-
MINIMUM_HEAP_SIZE
private static final int MINIMUM_HEAP_SIZE- See Also:
-
heap
private byte[] heapThe storage buffer -
heapSize
private int heapSizeThe current used size of the buffer invalid input: '<'= heap.length -
heapOffset
private int heapOffsetOur current offset into the heap. When we read from the heap we use a byte array input stream. So long as we continue to read further into the heap, we can continue to use the same stream, but we need to recreate the stream whenever we skip backwards. -
bstr
A stream used to read the heap data
-
-
Constructor Details
-
FitsHeap
FitsHeap(int size) Create a heap of a given size.
-
-
Method Details
-
allocate
private void allocate() -
copy
FitsHeap copy()Add a copy constructor to allow us to duplicate a heap. This would be necessary if we wanted to copy an HDU that included variable length columns. -
expandHeap
void expandHeap(int need) Check if the Heap can accommodate a given requirement. If not expand the heap. -
getData
Get data from the heap.- Parameters:
offset- The offset at which the data begins.array- The array to be extracted.- Throws:
FitsException- if the operation failed
-
getFileOffset
public long getFileOffset()Get the file offset of the heap- Specified by:
getFileOffsetin interfaceFitsElement- Returns:
- the byte at which this element begins. This is only available if the data is originally read from a random access medium.
-
getSize
public long getSize()Return the size of the heap using the more bean compatible format- Specified by:
getSizein interfaceFitsElement- Returns:
- The size of this element in bytes
-
putData
-
read
Read the heap- Specified by:
readin interfaceFitsElement- Parameters:
str- The input data stream- Throws:
FitsException- if the read was unsuccessful.
-
reset
public boolean reset()Description copied from interface:FitsElementReset the input stream to point to the beginning of this element- Specified by:
resetin interfaceFitsElement- Returns:
- True if the reset succeeded.
-
rewrite
Description copied from interface:FitsElementRewrite the contents of the element in place. The data must have been originally read from a random access device, and the size of the element may not have changed.- Specified by:
rewritein interfaceFitsElement- Throws:
IOException- if the rewrite was unsuccessful.FitsException- if the rewrite was unsuccessful.
-
rewriteable
public boolean rewriteable()- Specified by:
rewriteablein interfaceFitsElement- Returns:
trueif this element can be rewritten?
-
size
public int size()- Returns:
- the size of the Heap
-
write
Write the heap- Specified by:
writein interfaceFitsElement- Parameters:
str- The data sink.- Throws:
FitsException- if the write was unsuccessful.
-