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 |
GC_GENERATION_OFFSET |
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 |
REFERENCED_SEGMENT_ID_COUNT_OFFSET |
Constructor and Description |
---|
Segment(SegmentStore store,
SegmentReader reader,
SegmentId id,
ByteBuffer data) |
Modifier and Type | Method and Description |
---|---|
static int |
align(int address,
int boundary)
Align an
address on the given boundary |
int |
getGcGeneration()
Determine the gc generation of this segment.
|
static int |
getGcGeneration(ByteBuffer data,
UUID segmentId)
Determine the gc generation a segment from its data.
|
UUID |
getReferencedSegmentId(int index) |
int |
getReferencedSegmentIdCount() |
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. |
SegmentVersion |
getSegmentVersion() |
static short |
pack(int offset)
Packs a segment offset into a 4 byte aligned address packed into a
short . |
int |
size() |
String |
toString() |
static int |
unpack(short offset)
Unpacks a 4 byte aligned segment offset.
|
void |
writeTo(OutputStream 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 GC_GENERATION_OFFSET
public static final int REFERENCED_SEGMENT_ID_COUNT_OFFSET
public Segment(@Nonnull SegmentStore store, @Nonnull SegmentReader reader, @Nonnull SegmentId id, @Nonnull ByteBuffer data)
public static int unpack(short offset)
offset
- 4 byte aligned segment offsetpublic static short pack(int offset)
short
.offset
- segment offsetshort
public static int align(int address, int boundary)
address
on the given boundary
address
- address to alignboundary
- boundary to align ton = address + a
such that n % boundary == 0
and
0 <= a < boundary
.public SegmentVersion getSegmentVersion()
public SegmentId getSegmentId()
public int getRootCount()
public int getReferencedSegmentIdCount()
public UUID getReferencedSegmentId(int index)
public static int getGcGeneration(ByteBuffer data, UUID segmentId)
data
- the date of the segmentsegmentId
- the id of the segmentpublic int getGcGeneration()
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 void writeTo(OutputStream stream) throws IOException
IOException
Copyright © 2012-2016 The Apache Software Foundation. All Rights Reserved.