Interface SegmentArchiveReader
-
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
SegmentTarReader
public interface SegmentArchiveReader extends Closeable
This interface represents a read-only segment archive. Since the underlying data structure is immutable, the implementation should be thread safe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Close the archive.boolean
containsSegment(long msb, long lsb)
Check if the segment exists.@NotNull org.apache.jackrabbit.oak.commons.Buffer
getBinaryReferences()
Load binary references.int
getEntrySize(int size)
Transforms the segment size in bytes into the effective size on disk for the given entry (eg.@Nullable org.apache.jackrabbit.oak.commons.Buffer
getGraph()
Load the segment graph.@NotNull String
getName()
Get the name of the archive.boolean
hasGraph()
Check if the segment graph has been persisted for this archive.long
length()
Get the current length of the archive.List<SegmentArchiveEntry>
listSegments()
List all the segments, in the order as they have been written to the archive.@Nullable org.apache.jackrabbit.oak.commons.Buffer
readSegment(long msb, long lsb)
Read the segment.
-
-
-
Method Detail
-
readSegment
@Nullable @Nullable org.apache.jackrabbit.oak.commons.Buffer readSegment(long msb, long lsb) throws IOException
Read the segment.- Parameters:
msb
- the most significant bits of the identifier of the segmentlsb
- the least significant bits of the identifier of the segment- Returns:
- byte buffer containing the segment data or null if the segment doesn't exist
- Throws:
IOException
-
containsSegment
boolean containsSegment(long msb, long lsb)
Check if the segment exists.- Parameters:
msb
- the most significant bits of the identifier of the segmentlsb
- the least significant bits of the identifier of the segment- Returns:
true
if the segment exists
-
listSegments
List<SegmentArchiveEntry> listSegments()
List all the segments, in the order as they have been written to the archive.- Returns:
- segment list, ordered by their position in the archive
-
getGraph
@Nullable @Nullable org.apache.jackrabbit.oak.commons.Buffer getGraph() throws IOException
Load the segment graph.- Returns:
- byte buffer representing the graph or null if the graph hasn't been persisted.
- Throws:
IOException
-
hasGraph
boolean hasGraph()
Check if the segment graph has been persisted for this archive.- Returns:
true
if the graph exists, false otherwise
-
getBinaryReferences
@NotNull @NotNull org.apache.jackrabbit.oak.commons.Buffer getBinaryReferences() throws IOException
Load binary references.- Returns:
- byte buffer representing the binary references structure.
- Throws:
IOException
-
length
long length()
Get the current length of the archive.- Returns:
- length of the archive, in bytes
-
getName
@NotNull @NotNull String getName()
Get the name of the archive.- Returns:
- archive name
-
close
void close() throws IOException
Close the archive.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
getEntrySize
int getEntrySize(int size)
Transforms the segment size in bytes into the effective size on disk for the given entry (eg. by adding the number of padding bytes, header, etc.)- Parameters:
size
- the segment size in bytes- Returns:
- the number of bytes effectively used on the storage to save the segment
-
-