public interface SegmentData
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; a getVersion()
, which specifies the version of
the binary format used to serialize the content of the segment; a full generation
, which describes the generation of the
segment with regards to full compaction; a generation
, which identifies the generation of the segment with regards to
full or tail compaction; a compacted flag
, which
determines if the segment was written by a compaction operation; the number of record references
, which is the number
of record entries in the segment; the number 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 bits
and lsb
of the segment identifier. A record
reference is composed of a record
number
, a record type
and a record 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 offset
of 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.
Modifier and Type | Method and Description |
---|---|
void |
binDump(java.io.OutputStream stream) |
int |
estimateMemoryUsage() |
int |
getFullGeneration() |
int |
getGeneration() |
int |
getRecordReferenceNumber(int i) |
int |
getRecordReferenceOffset(int i) |
int |
getRecordReferencesCount() |
byte |
getRecordReferenceType(int i) |
long |
getSegmentReferenceLsb(int i) |
long |
getSegmentReferenceMsb(int i) |
int |
getSegmentReferencesCount() |
java.lang.String |
getSignature() |
byte |
getVersion() |
void |
hexDump(java.io.OutputStream stream) |
boolean |
isCompacted() |
static SegmentData |
newRawSegmentData(Buffer buffer) |
static SegmentData |
newSegmentData(Buffer buffer) |
byte |
readByte(int recordReferenceOffset) |
Buffer |
readBytes(int recordReferenceOffset,
int size) |
int |
readInt(int recordReferenceOffset) |
long |
readLength(int recordReferenceOffset) |
long |
readLong(int recordReferenceOffset) |
RecordIdData |
readRecordId(int recordReferenceOffset) |
short |
readShort(int recordReferenceOffset) |
StringData |
readString(int recordReferenceOffset) |
int |
size() |
static SegmentData newSegmentData(Buffer buffer)
static SegmentData newRawSegmentData(Buffer buffer)
byte getVersion()
java.lang.String getSignature()
int getFullGeneration()
boolean isCompacted()
int getGeneration()
int getSegmentReferencesCount()
int getRecordReferencesCount()
int getRecordReferenceNumber(int i)
byte getRecordReferenceType(int i)
int getRecordReferenceOffset(int i)
long getSegmentReferenceMsb(int i)
long getSegmentReferenceLsb(int i)
long readLength(int recordReferenceOffset)
StringData readString(int recordReferenceOffset)
RecordIdData readRecordId(int recordReferenceOffset)
byte readByte(int recordReferenceOffset)
int readInt(int recordReferenceOffset)
short readShort(int recordReferenceOffset)
long readLong(int recordReferenceOffset)
Buffer readBytes(int recordReferenceOffset, int size)
int size()
void hexDump(java.io.OutputStream stream) throws java.io.IOException
java.io.IOException
void binDump(java.io.OutputStream stream) throws java.io.IOException
java.io.IOException
int estimateMemoryUsage()
Copyright © 2012–2022 The Apache Software Foundation. All rights reserved.