Class SegmentTarReader
- java.lang.Object
-
- org.apache.jackrabbit.oak.segment.file.tar.SegmentTarReader
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,SegmentArchiveReader
public class SegmentTarReader extends java.lang.Object implements SegmentArchiveReader
-
-
Constructor Summary
Constructors Constructor Description SegmentTarReader(java.io.File file, org.apache.jackrabbit.oak.segment.file.tar.FileAccess access, Index index, IOMonitor ioMonitor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the archive.boolean
containsSegment(long msb, long lsb)
Check if the segment exists.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.org.apache.jackrabbit.oak.commons.Buffer
getGraph()
Load the segment graph.java.lang.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.java.util.List<SegmentArchiveEntry>
listSegments()
List all the segments, in the order as they have been written to the archive.static Index
loadAndValidateIndex(java.io.RandomAccessFile file, java.lang.String name)
org.apache.jackrabbit.oak.commons.Buffer
readSegment(long msb, long lsb)
Read the segment.
-
-
-
Method Detail
-
readSegment
public org.apache.jackrabbit.oak.commons.Buffer readSegment(long msb, long lsb) throws java.io.IOException
Description copied from interface:SegmentArchiveReader
Read the segment.- Specified by:
readSegment
in interfaceSegmentArchiveReader
- 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:
java.io.IOException
-
containsSegment
public boolean containsSegment(long msb, long lsb)
Description copied from interface:SegmentArchiveReader
Check if the segment exists.- Specified by:
containsSegment
in interfaceSegmentArchiveReader
- 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
public java.util.List<SegmentArchiveEntry> listSegments()
Description copied from interface:SegmentArchiveReader
List all the segments, in the order as they have been written to the archive.- Specified by:
listSegments
in interfaceSegmentArchiveReader
- Returns:
- segment list, ordered by their position in the archive
-
loadAndValidateIndex
public static Index loadAndValidateIndex(java.io.RandomAccessFile file, java.lang.String name) throws java.io.IOException
- Throws:
java.io.IOException
-
getGraph
public org.apache.jackrabbit.oak.commons.Buffer getGraph() throws java.io.IOException
Description copied from interface:SegmentArchiveReader
Load the segment graph.- Specified by:
getGraph
in interfaceSegmentArchiveReader
- Returns:
- byte buffer representing the graph or null if the graph hasn't been persisted.
- Throws:
java.io.IOException
-
hasGraph
public boolean hasGraph()
Description copied from interface:SegmentArchiveReader
Check if the segment graph has been persisted for this archive.- Specified by:
hasGraph
in interfaceSegmentArchiveReader
- Returns:
true
if the graph exists, false otherwise
-
getBinaryReferences
public org.apache.jackrabbit.oak.commons.Buffer getBinaryReferences() throws java.io.IOException
Description copied from interface:SegmentArchiveReader
Load binary references.- Specified by:
getBinaryReferences
in interfaceSegmentArchiveReader
- Returns:
- byte buffer representing the binary references structure.
- Throws:
java.io.IOException
-
length
public long length()
Description copied from interface:SegmentArchiveReader
Get the current length of the archive.- Specified by:
length
in interfaceSegmentArchiveReader
- Returns:
- length of the archive, in bytes
-
getName
public java.lang.String getName()
Description copied from interface:SegmentArchiveReader
Get the name of the archive.- Specified by:
getName
in interfaceSegmentArchiveReader
- Returns:
- archive name
-
close
public void close() throws java.io.IOException
Description copied from interface:SegmentArchiveReader
Close the archive.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceSegmentArchiveReader
- Throws:
java.io.IOException
-
getEntrySize
public int getEntrySize(int size)
Description copied from interface:SegmentArchiveReader
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.)- Specified by:
getEntrySize
in interfaceSegmentArchiveReader
- Parameters:
size
- the segment size in bytes- Returns:
- the number of bytes effectively used on the storage to save the segment
-
-