public class SimpleMappedMemoryHandler
extends java.lang.Object
Just a note about synchronization. This object is NOT thread-safe.
Constructor and Description |
---|
SimpleMappedMemoryHandler(java.nio.ByteBuffer buf)
Constructor.
|
SimpleMappedMemoryHandler(java.io.File file,
java.nio.ByteOrder order)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close unneeded file channel object.
|
byte |
getByteAtBytePos(long bytePosition)
Get the byte value in the file at the given byte index.
|
int |
getExtraByteCount()
Get the number of extra bytes at the very end of
this file beyond an integral number of ints.
|
java.nio.channels.FileChannel |
getFileChannel()
Get the file channel object.
|
org.jlab.coda.hipo.FileHeader |
getFileHeader()
Get the file header of a version 6 evio file.
|
java.nio.ByteBuffer |
getFileHeaderData()
Get the file header data of a version 6 evio file including index and user header.
|
long |
getFileSize()
Get the file size in bytes.
|
int |
getFirstDataIndex()
Get the number of 32 bit words comprising the
file and first record headers for evio version 6 files, or
comprising the first block header for evio versions < 6.
|
java.nio.ByteBuffer |
getFirstMap()
Get the first memory map - used to map the beginning of the file.
|
int |
getInt(long wordPosition)
Get the int value in the file at the given word (4 byte) position.
|
int |
getIntAtBytePos(long bytePosition)
Get the int value in the file at the given byte index.
|
java.nio.ByteBuffer |
getMap(int mapIndex)
Get the indicated memory map.
|
int |
getMapCount()
Get the number of memory maps used to fully map file.
|
int |
getMapIndex(long wordIndex)
Get the index of the map for a given word index.
|
int |
getMapSize(int mapIndex)
Get the size of the given map.
|
long |
getMaxMapSize()
Get the maximum byte size of each memory map (last one will be smaller).
|
java.nio.ByteOrder |
getOrder()
Get the byte order of the data.
|
short |
getShortAtBytePos(long bytePosition)
Get the short value in the file at the given byte index.
|
int |
getTotalFileHeaderBytes()
Get the total number of bytes in file header + index + user header for evio version 6 file.
|
boolean |
haveExtraBytes()
Does this file have 1, 2, or 3 bytes more
than an integral number of integers?
|
boolean |
isCompressed()
Does the first record of the first map contain compressed data?
|
void |
setByteOrder(java.nio.ByteOrder order)
Set the byte order of the data.
|
public SimpleMappedMemoryHandler(java.io.File file, java.nio.ByteOrder order) throws java.io.IOException
file
- file's file channel objectorder
- byte order of the datajava.io.IOException
- if could not map filepublic SimpleMappedMemoryHandler(java.nio.ByteBuffer buf)
buf
- buffer to analyzepublic boolean isCompressed()
true
if data in first record of the first
memory map is compressed, else false
.public int getFirstDataIndex()
public int getTotalFileHeaderBytes()
public java.nio.ByteBuffer getFileHeaderData()
public org.jlab.coda.hipo.FileHeader getFileHeader()
public void close()
public boolean haveExtraBytes()
public int getExtraByteCount()
public long getMaxMapSize()
public java.nio.channels.FileChannel getFileChannel()
public long getFileSize()
public int getMapSize(int mapIndex)
mapIndex
- index of map.public int getMapCount()
public java.nio.ByteBuffer getFirstMap()
public void setByteOrder(java.nio.ByteOrder order)
order
- byte order of the data.public java.nio.ByteOrder getOrder()
public java.nio.ByteBuffer getMap(int mapIndex)
mapIndex
- index into map holding memory mapped ByteBufferspublic int getInt(long wordPosition)
wordPosition
- word position in filepublic int getIntAtBytePos(long bytePosition)
bytePosition
- byte index into filepublic short getShortAtBytePos(long bytePosition)
bytePosition
- byte index into filepublic byte getByteAtBytePos(long bytePosition)
bytePosition
- byte index into filepublic int getMapIndex(long wordIndex)
wordIndex
- index of word