public class Segment extends Object
Record data is not kept in memory, but some entries are cached (templates, all strings in the segment).
This class includes method to read records from the raw bytes.
| Modifier and Type | Field and Description |
|---|---|
static int |
BLOB_ID_SMALL_LIMIT
Maximum size of small blob IDs.
|
static int |
MAX_SEGMENT_SIZE
Maximum segment size.
|
static int |
MEDIUM_LIMIT
The size limit for medium values.
|
static int |
RECORD_ALIGN_BITS
The number of bytes (or bits of address space) to use for the
alignment boundary of segment records.
|
static int |
REF_COUNT_OFFSET |
| Constructor and Description |
|---|
Segment(SegmentTracker tracker,
SegmentId id,
ByteBuffer data) |
Segment(SegmentTracker tracker,
SegmentId id,
ByteBuffer data,
SegmentVersion version) |
| Modifier and Type | Method and Description |
|---|---|
static int |
align(int address,
int boundary)
Align an
address on the given boundary |
static int |
decode(short offset)
Decode a 4 byte aligned segment offset.
|
static short |
encode(int offset)
Encode a segment offset into a 4 byte aligned address packed into a
short. |
long |
getCacheSize() |
List<SegmentId> |
getReferencedIds() |
int |
getRootCount() |
int |
getRootOffset(int index) |
RecordType |
getRootType(int index) |
SegmentId |
getSegmentId() |
String |
getSegmentInfo()
Returns the segment meta data of this segment or
null if none is present. |
int |
size() |
String |
toString() |
void |
writeTo(OutputStream stream)
Writes this segment to the given output stream.
|
public static final int RECORD_ALIGN_BITS
public static final int MAX_SEGMENT_SIZE
public static final int MEDIUM_LIMIT
public static final int BLOB_ID_SMALL_LIMIT
public static final int REF_COUNT_OFFSET
public Segment(SegmentTracker tracker, SegmentId id, ByteBuffer data)
public Segment(SegmentTracker tracker, SegmentId id, ByteBuffer data, SegmentVersion version)
public static int decode(short offset)
offset - 4 byte aligned segment offsetpublic static short encode(int offset)
short.offset - segment offsetshortpublic static int align(int address,
int boundary)
address on the given boundaryaddress - address to alignboundary - boundary to align ton = address + a such that n % boundary == 0 and
0 <= a < boundary.public SegmentId getSegmentId()
public int getRootCount()
public RecordType getRootType(int index)
public int getRootOffset(int index)
@CheckForNull public String getSegmentInfo()
null if none is present.
The segment meta data is a string of the format "{wid=W,sno=S,gc=G,t=T}"
where:
W is the writer id wid, S is a unique, increasing sequence number corresponding to the allocation order
of the segments in this store, G is the garbage collection generation (i.e. the number of compaction cycles
that have been run),T is a time stamp according to System.currentTimeMillis().public int size()
public long getCacheSize()
public void writeTo(OutputStream stream) throws IOException
stream - stream to which this segment will be writtenIOException - on an IO errorCopyright © 2012-2016 The Apache Software Foundation. All Rights Reserved.