Class Segment
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.Segment
-
public class Segment extends java.lang.Object
A list of records.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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Segment.RecordConsumer
A consumer of record data.
-
Field Summary
Fields Modifier and Type Field Description static int
MEDIUM_LIMIT
The size limit for medium values.
-
Constructor Summary
Constructors Constructor Description Segment(@NotNull SegmentIdProvider idProvider, @NotNull SegmentReader reader, @NotNull SegmentId id, @NotNull Buffer data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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, java.util.UUID segmentId)
Determine the gc generation a segment from its data.java.util.UUID
getReferencedSegmentId(int index)
int
getReferencedSegmentIdCount()
SegmentId
getSegmentId()
@Nullable java.lang.String
getSegmentInfo()
Returns the segment meta data of this segment ornull
if none is present.SegmentVersion
getSegmentVersion()
int
size()
java.lang.String
toString()
void
writeTo(java.io.OutputStream stream)
-
-
-
Field Detail
-
MEDIUM_LIMIT
public static final int MEDIUM_LIMIT
The size limit for medium values. The variable length of medium values is encoded as two bytes with the highest bits of the first byte set to one and zero, which gives us 14 bits for encoding the length of the value. And since small values are never stored as medium ones, we can extend the size range to cover that many longer values.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Segment
public Segment(@NotNull @NotNull SegmentIdProvider idProvider, @NotNull @NotNull SegmentReader reader, @NotNull @NotNull SegmentId id, @NotNull @NotNull Buffer data)
-
-
Method Detail
-
getSegmentVersion
public SegmentVersion getSegmentVersion()
-
getSegmentId
public SegmentId getSegmentId()
-
getReferencedSegmentIdCount
public int getReferencedSegmentIdCount()
-
getReferencedSegmentId
public java.util.UUID getReferencedSegmentId(int index)
-
getGcGeneration
public static GCGeneration getGcGeneration(SegmentData data, java.util.UUID segmentId)
Determine the gc generation a segment from its data. Note that bulk segments don't have generations (i.e. stay at 0).- Parameters:
data
- the data of the segmentsegmentId
- the id of the segment- Returns:
- the gc generation of this segment or
GCGeneration.NULL
if this is bulk segment.
-
getGcGeneration
@NotNull public @NotNull GCGeneration getGcGeneration()
Determine the gc generation of this segment. Note that bulk segments don't have generations (i.e. stay at 0).- Returns:
- the gc generation of this segment or 0 if this is bulk segment.
-
getSegmentInfo
@Nullable public @Nullable java.lang.String getSegmentInfo()
Returns the segment meta data of this segment ornull
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 idwid
,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 toSystem.currentTimeMillis()
.
- Returns:
- the segment meta data
-
size
public int size()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
writeTo
public void writeTo(java.io.OutputStream stream) throws java.io.IOException
- Throws:
java.io.IOException
-
getAddress
public int getAddress(int offset)
Convert an offset into an address.- Parameters:
offset
-- Returns:
- the address corresponding the
offset
-
forEachRecord
public void forEachRecord(Segment.RecordConsumer consumer)
Iterate over the records contained in this segment.- Parameters:
consumer
- an instance ofSegment.RecordConsumer
.
-
-