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 | Class and Description |
---|---|
static interface |
Segment.RecordConsumer
A consumer of record data.
|
Constructor and Description |
---|
Segment(@NotNull SegmentIdProvider idProvider,
@NotNull SegmentReader reader,
@NotNull SegmentId id,
@NotNull org.apache.jackrabbit.oak.commons.Buffer data) |
Modifier and Type | Method and Description |
---|---|
void |
forEachRecord(Segment.RecordConsumer consumer)
Iterate over the records contained in this segment.
|
int |
getAddress(int offset)
Convert an offset into an address.
|
@NotNull GCGeneration |
getGcGeneration()
Determine the gc generation of this segment.
|
static GCGeneration |
getGcGeneration(SegmentData data,
UUID segmentId)
Determine the gc generation a segment from its data.
|
UUID |
getReferencedSegmentId(int index) |
int |
getReferencedSegmentIdCount() |
SegmentId |
getSegmentId() |
@Nullable String |
getSegmentInfo()
Returns the segment meta data of this segment or
null if none is present. |
SegmentVersion |
getSegmentVersion() |
int |
size() |
String |
toString() |
void |
writeTo(OutputStream stream) |
public Segment(@NotNull @NotNull SegmentIdProvider idProvider, @NotNull @NotNull SegmentReader reader, @NotNull @NotNull SegmentId id, @NotNull @NotNull org.apache.jackrabbit.oak.commons.Buffer data)
public SegmentVersion getSegmentVersion()
public SegmentId getSegmentId()
public int getReferencedSegmentIdCount()
public UUID getReferencedSegmentId(int index)
public static GCGeneration getGcGeneration(SegmentData data, UUID segmentId)
data
- the data of the segmentsegmentId
- the id of the segmentGCGeneration.NULL
if
this is bulk segment.@NotNull public @NotNull GCGeneration getGcGeneration()
@Nullable public @Nullable 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
public int getAddress(int offset)
offset
- offset
public void forEachRecord(Segment.RecordConsumer consumer)
consumer
- an instance of Segment.RecordConsumer
.Copyright © 2012–2020 The Apache Software Foundation. All rights reserved.