Class DefaultSegmentWriter

  • All Implemented Interfaces:
    SegmentWriter

    public class DefaultSegmentWriter
    extends Object
    implements SegmentWriter
    Converts nodes, properties, values, etc. to records and persists them with the help of a WriteOperationHandler. All public methods of this class are thread safe if and only if the WriteOperationHandler passed to the constructor is thread safe.
    • Constructor Detail

      • DefaultSegmentWriter

        public DefaultSegmentWriter​(@NotNull
                                    @NotNull SegmentStore store,
                                    @NotNull
                                    @NotNull SegmentReader reader,
                                    @NotNull
                                    @NotNull SegmentIdProvider idProvider,
                                    @Nullable
                                    @Nullable org.apache.jackrabbit.oak.spi.blob.BlobStore blobStore,
                                    @NotNull
                                    @NotNull WriterCacheManager cacheManager,
                                    @NotNull
                                    @NotNull org.apache.jackrabbit.oak.segment.WriteOperationHandler writeOperationHandler)
        Create a new instance of a SegmentWriter. Note the thread safety properties pointed out in the class comment.
        Parameters:
        store - store to write to
        reader - segment reader for the store
        idProvider - segment id provider for the store
        blobStore - the blog store or null for inlined blobs
        cacheManager - cache manager instance for the de-duplication caches used by this writer
        writeOperationHandler - handler for write operations.
    • Method Detail

      • writeBlob

        @NotNull
        public @NotNull RecordId writeBlob​(@NotNull
                                           @NotNull org.apache.jackrabbit.oak.api.Blob blob)
                                    throws IOException
        Description copied from interface: SegmentWriter
        Write a blob (as list of block records)
        Specified by:
        writeBlob in interface SegmentWriter
        Parameters:
        blob - blob to write
        Returns:
        the record id of the blob written
        Throws:
        IOException
      • writeStream

        @NotNull
        public @NotNull RecordId writeStream​(@NotNull
                                             @NotNull InputStream stream)
                                      throws IOException
        Description copied from interface: SegmentWriter
        Writes a stream value record. The given stream is consumed and closed by this method.
        Specified by:
        writeStream in interface SegmentWriter
        Parameters:
        stream - stream to be written
        Returns:
        the record id of the stream written
        Throws:
        IOException - if the input stream could not be read or the output could not be written
      • writeNode

        @NotNull
        public @NotNull RecordId writeNode​(@NotNull
                                           @NotNull org.apache.jackrabbit.oak.spi.state.NodeState state,
                                           @Nullable
                                           @Nullable org.apache.jackrabbit.oak.commons.Buffer stableIdBytes)
                                    throws IOException
        Description copied from interface: SegmentWriter
        Write a node state. If non null, the passed stableId will be assigned to the persisted node. Otherwise the stable id will be inferred from state.
        Specified by:
        writeNode in interface SegmentWriter
        Parameters:
        state - node state to write
        stableIdBytes - the stableId that should be assigned to the node or null.
        Returns:
        the record id of the segment node state written
        Throws:
        IOException