public class RecordInputStream
extends java.lang.Object
RECORD STRUCTURE:
Uncompressed Compressed
+----------------------------------+ +----------------------------------+
| General Record Header | | General Record Header |
+----------------------------------+ +----------------------------------+
+----------------------------------+ ---------> +----------------------------------+
| Index Array | | Compressed Data |
+----------------------------------+ | Record |
| |
+----------------------------------+ | |
| User Header | | ----------------|
| (Optional) | | | Pad 3 |
| ----------------| +----------------------------------+
| | Pad 1 | ^
+----------------------------------+ /
/
+----------------------------------+ /
| Data Record | /
| | /
| ----------------| /
| | Pad 2 | /
+----------------------------------+
GENERAL RECORD HEADER STRUCTURE ( see RecordHeader.java )
+----------------------------------+
1 | Record Length | // 32bit words, inclusive
+----------------------------------+
2 + Record Number |
+----------------------------------+
3 + Header Length | // 14 (words)
+----------------------------------+
4 + Event (Index) Count |
+----------------------------------+
5 + Index Array Length | // bytes
+-----------------------+---------+
6 + Bit Info | Version | // version (8 bits)
+-----------------------+----------+
7 + User Header Length | // bytes
+----------------------------------+
8 + Magic Number | // 0xc0da0100
+----------------------------------+
9 + Uncompressed Data Length | // bytes
+------+---------------------------+
10 + CT | Data Length Compressed | // CT = compression type (4 bits)
+----------------------------------+
11 + General Register 1 | // UID 1st (64 bits)
+-- --+
12 + |
+----------------------------------+
13 + General Register 2 | // UID 2nd (64 bits)
+-- --+
14 + |
+----------------------------------+
Constructor and Description |
---|
RecordInputStream()
Default, no-arg constructor.
|
RecordInputStream(java.nio.ByteOrder order)
Constructor with arguments.
|
Modifier and Type | Method and Description |
---|---|
java.nio.ByteOrder |
getByteOrder()
Get the byte order of the internal buffers.
|
int |
getEntries()
Returns number of the events packed in the record.
|
java.nio.ByteBuffer |
getEvent(java.nio.ByteBuffer buffer,
int index)
Get the event at the given index and write it into the given byte buffer.
|
java.nio.ByteBuffer |
getEvent(java.nio.ByteBuffer buffer,
int bufOffset,
int index)
Get the event at the given index and write it into the given byte buffer.
|
byte[] |
getEvent(int index)
Get the event at the given index and return it in an allocated array.
|
int |
getEventLength(int index)
Returns the length of the event with given index.
|
RecordHeader |
getHeader()
Get the header of this record.
|
java.nio.ByteBuffer |
getUncompressedDataBuffer()
Get the buffer with all uncompressed data in it.
|
byte[] |
getUserHeader()
Get the user header contained in this record.
|
java.nio.ByteBuffer |
getUserHeader(java.nio.ByteBuffer buffer,
int bufOffset)
Get any existing user header and write it into the given byte buffer.
|
RecordInputStream |
getUserHeaderAsRecord(java.nio.ByteBuffer buffer,
int bufOffset)
Get any existing user header and write it into the given byte buffer.
|
boolean |
hasIndex()
Does this record contain an event index?
|
boolean |
hasUserHeader()
Does this record contain a user header?
|
static void |
main(java.lang.String[] args)
test main program
|
void |
readRecord(java.nio.ByteBuffer buffer,
int offset)
Reads a record from the buffer at the given offset.
|
void |
readRecord(java.io.RandomAccessFile file,
long position)
Reads record from the file at given position.
|
public RecordInputStream()
public RecordInputStream(java.nio.ByteOrder order)
order
- byte order of record byte arrays.public RecordHeader getHeader()
public java.nio.ByteOrder getByteOrder()
public java.nio.ByteBuffer getUncompressedDataBuffer()
public boolean hasIndex()
public boolean hasUserHeader()
public byte[] getEvent(int index)
index
- index of event starting at 0. If index too large, it's
set to last index. If negative, it's set to 0.public int getEventLength(int index)
index
- index of the eventpublic java.nio.ByteBuffer getEvent(java.nio.ByteBuffer buffer, int index) throws HipoException
buffer
- buffer to be filled with event starting at position = 0index
- index of event starting at 0. Negative value = 0.HipoException
- if buffer has insufficient space to contain event
(buffer.capacity() < event size).public java.nio.ByteBuffer getEvent(java.nio.ByteBuffer buffer, int bufOffset, int index) throws HipoException
buffer
- buffer to be filled with event.bufOffset
- offset into buffer to place event.index
- index of event starting at 0. Negative value = 0.HipoException
- if buffer has insufficient space to contain event
(buffer.capacity() - bufOffset < event size).public byte[] getUserHeader()
public java.nio.ByteBuffer getUserHeader(java.nio.ByteBuffer buffer, int bufOffset) throws HipoException
buffer
- buffer to be filled with user header. If null, create one and
return that.bufOffset
- offset into buffer to place user header.HipoException
- if buffer has insufficient space to contain user header
(buffer.capacity() - bufOffset < user header size).
If buffer is not null and offset negative.public RecordInputStream getUserHeaderAsRecord(java.nio.ByteBuffer buffer, int bufOffset) throws HipoException
buffer
- buffer to be filled with user headerbufOffset
- offset into buffer to place user header.HipoException
- if non-null buffer has insufficient space to contain user header
(buffer.capacity() - bufOffset < user header size).
If offset negative.public void readRecord(java.io.RandomAccessFile file, long position) throws HipoException
readRecord(ByteBuffer, int)
before calling any other.
Any compressed data is decompressed. Memory is allocated as needed.
First the header is read, then the length of
the record is read from header, then
following bytes are read and decompressed.file
- opened file descriptorposition
- position in the fileHipoException
- if file not in hipo format or if bad argument(s)public void readRecord(java.nio.ByteBuffer buffer, int offset) throws HipoException
readRecord(RandomAccessFile, long)
before calling any other.
Any compressed data is decompressed. Memory is allocated as needed.buffer
- buffer containing record data.offset
- offset into buffer to beginning of record data.HipoException
- if buffer not in hipo format or if bad argument(s)public int getEntries()
public static void main(java.lang.String[] args)
args
- args.