Search in sources :

Example 6 with GCGeneration

use of org.apache.jackrabbit.oak.segment.file.tar.GCGeneration in project jackrabbit-oak by apache.

the class FileStore method writeSegment.

@Override
public void writeSegment(SegmentId id, byte[] buffer, int offset, int length) throws IOException {
    try (ShutDownCloser ignored = shutDown.keepAlive()) {
        Segment segment = null;
        // If the segment is a data segment, create a new instance of Segment to
        // access some internal information stored in the segment and to store
        // in an in-memory cache for later use.
        GCGeneration generation = GCGeneration.NULL;
        Set<UUID> references = null;
        Set<String> binaryReferences = null;
        if (id.isDataSegmentId()) {
            ByteBuffer data;
            if (offset > 4096) {
                data = ByteBuffer.allocate(length);
                data.put(buffer, offset, length);
                data.rewind();
            } else {
                data = ByteBuffer.wrap(buffer, offset, length);
            }
            segment = new Segment(tracker, segmentReader, id, data);
            generation = segment.getGcGeneration();
            references = readReferences(segment);
            binaryReferences = readBinaryReferences(segment);
        }
        tarFiles.writeSegment(id.asUUID(), buffer, offset, length, generation, references, binaryReferences);
        // Keep this data segment in memory as it's likely to be accessed soon.
        if (segment != null) {
            segmentCache.putSegment(segment);
        }
    }
}
Also used : ShutDownCloser(org.apache.jackrabbit.oak.segment.file.ShutDown.ShutDownCloser) UUID(java.util.UUID) ByteBuffer(java.nio.ByteBuffer) Segment(org.apache.jackrabbit.oak.segment.Segment) GCGeneration(org.apache.jackrabbit.oak.segment.file.tar.GCGeneration)

Aggregations

GCGeneration (org.apache.jackrabbit.oak.segment.file.tar.GCGeneration)6 Stopwatch (com.google.common.base.Stopwatch)2 IOException (java.io.IOException)2 ByteBuffer (java.nio.ByteBuffer)2 UUID (java.util.UUID)2 Compactor (org.apache.jackrabbit.oak.segment.Compactor)2 DefaultSegmentWriter (org.apache.jackrabbit.oak.segment.DefaultSegmentWriter)2 Segment (org.apache.jackrabbit.oak.segment.Segment)2 SegmentBufferWriter (org.apache.jackrabbit.oak.segment.SegmentBufferWriter)2 SegmentNodeState (org.apache.jackrabbit.oak.segment.SegmentNodeState)2 SegmentWriter (org.apache.jackrabbit.oak.segment.SegmentWriter)2 WriterCacheManager (org.apache.jackrabbit.oak.segment.WriterCacheManager)2 SegmentGCOptions (org.apache.jackrabbit.oak.segment.compaction.SegmentGCOptions)2 FileStore (org.apache.jackrabbit.oak.segment.file.FileStore)2 FileStoreBuilder (org.apache.jackrabbit.oak.segment.file.FileStoreBuilder)1 ReadOnlyFileStore (org.apache.jackrabbit.oak.segment.file.ReadOnlyFileStore)1 ShutDownCloser (org.apache.jackrabbit.oak.segment.file.ShutDown.ShutDownCloser)1 BasicReadOnlyBlobStore (org.apache.jackrabbit.oak.segment.file.tooling.BasicReadOnlyBlobStore)1