Interface SegmentData
-
public interface SegmentDataAccess the data of a segment.A segment is composed of a header and the proper data. The header has a fixed- and a variable-length part.
The fixed-length part of the header contains a
signature, which is a string that uniquely identifies the rest of the content as a segment; agetVersion(), which specifies the version of the binary format used to serialize the content of the segment; afull generation, which describes the generation of the segment with regards to full compaction; ageneration, which identifies the generation of the segment with regards to full or tail compaction; acompacted flag, which determines if the segment was written by a compaction operation; thenumber of record references, which is the number of record entries in the segment; thenumber of segment references, which is the number of identifiers of other segments used by this segment.The variable part of the header contains the list of segment references and the list of record references. A segment references is composed by the
most significant bitsandlsbof the segment identifier. A record reference is composed of arecord number, arecord typeand arecord offset.The most prominent use for a segment is to hold record data. Many methods of this class allows access to the record data. These methods accept an integer representing an absolute position pointing to the record data. The absolute position, though, is virtual: it is computed on a virtual segment 256K long. This offset is usually obtained by accessing the
record offsetof a record reference entry. The class will normalize the offset for the actual size of the segment, which can be smaller than 256K. It is acceptable to displace the offset of a record reference entry by a positive amount. This can be useful to access a field of a composite record saved at a specific offset.
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_MEDIUM_LENGTH_VALUEstatic intMAX_SMALL_LENGTH_VALUE
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidbinDump(OutputStream stream)intestimateMemoryUsage()intgetFullGeneration()intgetGeneration()intgetRecordReferenceNumber(int i)intgetRecordReferenceOffset(int i)intgetRecordReferencesCount()bytegetRecordReferenceType(int i)longgetSegmentReferenceLsb(int i)longgetSegmentReferenceMsb(int i)intgetSegmentReferencesCount()StringgetSignature()bytegetVersion()voidhexDump(OutputStream stream)booleanisCompacted()static SegmentDatanewRawSegmentData(Buffer buffer)static SegmentDatanewSegmentData(Buffer buffer)bytereadByte(int recordReferenceOffset)BufferreadBytes(int recordReferenceOffset, int size)intreadInt(int recordReferenceOffset)default longreadLength(int recordReferenceOffset)longreadLong(int recordReferenceOffset)default RecordIdDatareadRecordId(int recordReferenceOffset)shortreadShort(int recordReferenceOffset)default StringDatareadString(int recordReferenceOffset)intsize()
-
-
-
Field Detail
-
MAX_SMALL_LENGTH_VALUE
static final int MAX_SMALL_LENGTH_VALUE
- See Also:
- Constant Field Values
-
MAX_MEDIUM_LENGTH_VALUE
static final int MAX_MEDIUM_LENGTH_VALUE
- See Also:
- Constant Field Values
-
-
Method Detail
-
newSegmentData
static SegmentData newSegmentData(Buffer buffer)
-
newRawSegmentData
static SegmentData newRawSegmentData(Buffer buffer)
-
getVersion
byte getVersion()
-
getSignature
String getSignature()
-
getFullGeneration
int getFullGeneration()
-
isCompacted
boolean isCompacted()
-
getGeneration
int getGeneration()
-
getSegmentReferencesCount
int getSegmentReferencesCount()
-
getRecordReferencesCount
int getRecordReferencesCount()
-
getRecordReferenceNumber
int getRecordReferenceNumber(int i)
-
getRecordReferenceType
byte getRecordReferenceType(int i)
-
getRecordReferenceOffset
int getRecordReferenceOffset(int i)
-
getSegmentReferenceMsb
long getSegmentReferenceMsb(int i)
-
getSegmentReferenceLsb
long getSegmentReferenceLsb(int i)
-
readLength
default long readLength(int recordReferenceOffset)
-
readString
default StringData readString(int recordReferenceOffset)
-
readRecordId
default RecordIdData readRecordId(int recordReferenceOffset)
-
readByte
byte readByte(int recordReferenceOffset)
-
readInt
int readInt(int recordReferenceOffset)
-
readShort
short readShort(int recordReferenceOffset)
-
readLong
long readLong(int recordReferenceOffset)
-
readBytes
Buffer readBytes(int recordReferenceOffset, int size)
-
size
int size()
-
hexDump
void hexDump(OutputStream stream) throws IOException
- Throws:
IOException
-
binDump
void binDump(OutputStream stream) throws IOException
- Throws:
IOException
-
estimateMemoryUsage
int estimateMemoryUsage()
-
-