Package uk.ac.bristol.star.cdf.record
Class RecordMap
- java.lang.Object
-
- uk.ac.bristol.star.cdf.record.RecordMap
-
public class RecordMap extends java.lang.Object
Keeps track of where a variable's record data is stored.To work out the buffer and offset from which to read a record value, you can do something like this:
int ient = recMap.getEntryIndex(irec); Object value = ient >= 0 ? readBuffer(recMap.getBuf(ient), recMap.getOffset(ient,irec)) : NO_STORED_VALUE;
- Since:
- 21 Jun 2013
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RecordMap
createRecordMap(VariableDescriptorRecord vdr, RecordFactory recFact, int recSize)
Returns a record map for a given variable.Buf
getBuf(int ient)
Returns the data buffer for a given entry.int
getEntryCount()
Returns the number of entries managed by this map.int
getEntryIndex(int irec)
Returns the index of the entry containing a given record.long
getFinalOffsetInEntry(int ient)
Returns the offset of the last record in a given entry.long
getOffset(int ient, int irec)
Returns the byte offset for a record in a given entry.
-
-
-
Method Detail
-
getEntryCount
public int getEntryCount()
Returns the number of entries managed by this map.- Returns:
- entry count
-
getEntryIndex
public int getEntryIndex(int irec)
Returns the index of the entry containing a given record. If one of the entries contains the given record, return its index. If no entry contains it (the record is in a sparse region), return(-fr-2)
, wherefr
is the index of the previous entry. A value of -1 indicates that the requested record is in a sparse region before the first stored record.If non-negative, the result can be used with the
getBuf
andgetOffset
methods.- Parameters:
irec
- record index- Returns:
- index of entry covering
irec
, or a negative value if no entry covers it
-
getBuf
public Buf getBuf(int ient)
Returns the data buffer for a given entry. The entry index must correspond to an actual entry, that is it must not be negative.- Parameters:
ient
- entry index- Returns:
- buf
- See Also:
getEntryIndex(int)
-
getOffset
public long getOffset(int ient, int irec)
Returns the byte offset for a record in a given entry. Theient
parameter must reference an actual entry (it must be non-negative), and that entry must contain the given recordirec
,- Parameters:
ient
- entry index for entry containingirec
irec
- record index- Returns:
- offset into the entry's buffer at which
irec
can be found - See Also:
getEntryIndex(int)
-
getFinalOffsetInEntry
public long getFinalOffsetInEntry(int ient)
Returns the offset of the last record in a given entry.- Parameters:
ient
- non-negative entry index- Returns:
- offset into ient's buffer of ient's final record
-
createRecordMap
public static RecordMap createRecordMap(VariableDescriptorRecord vdr, RecordFactory recFact, int recSize) throws java.io.IOException
Returns a record map for a given variable.- Parameters:
vdr
- variable descriptor recordrecFact
- record factoryrecSize
- size in bytes of each variable value record- Returns:
- record map
- Throws:
java.io.IOException
-
-