Interface SegmentArchiveWriter

    • 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.
      void flush()
      Flush all the data to the storage.
      int getEntryCount()
      Get the number of entries currently contained in the archive.
      long getLength()
      Get the current length of the archive.
      @NotNull java.lang.String getName()
      Get the name of the archive.
      boolean isCreated()
      Check if the archive has been created (eg.
      boolean isRemote()
      This method returns true if the storage is accessed via a network protocol, not tight to the traditional storage technology, for example, HTTP.
      @Nullable Buffer readSegment​(long msb, long lsb)
      Read the segment.
      void writeBinaryReferences​(@org.jetbrains.annotations.NotNull byte[] data)
      Write the binary references data.
      void writeGraph​(@org.jetbrains.annotations.NotNull byte[] data)
      Write the graph data.
      void writeSegment​(long msb, long lsb, @org.jetbrains.annotations.NotNull byte[] data, int offset, int size, int generation, int fullGeneration, boolean isCompacted)
      Write the new segment to the archive.
    • Method Detail

      • writeSegment

        @NotNull
        void writeSegment​(long msb,
                          long lsb,
                          @NotNull
                          @org.jetbrains.annotations.NotNull byte[] data,
                          int offset,
                          int size,
                          int generation,
                          int fullGeneration,
                          boolean isCompacted)
                   throws java.io.IOException
        Write the new segment to the archive.
        Parameters:
        msb - the most significant bits of the identifier of the segment
        lsb - the least significant bits of the identifier of the segment
        data - the data.
        offset - the start offset in the data.
        size - the number of bytes to write.
        generation - the segment generation, see SegmentArchiveEntry.getGeneration()
        fullGeneration - the segment full generation, see SegmentArchiveEntry.getFullGeneration()
        isCompacted - the segment compaction property, see SegmentArchiveEntry.isCompacted()
        Throws:
        java.io.IOException
      • readSegment

        @Nullable
        @Nullable Buffer readSegment​(long msb,
                                     long lsb)
                              throws java.io.IOException
        Read the segment.
        Parameters:
        msb - the most significant bits of the identifier of the segment
        lsb - the least significant bits of the identifier of the segment
        Returns:
        byte buffer containing the segment data or null if segment doesn't exist
        Throws:
        java.io.IOException
      • containsSegment

        boolean containsSegment​(long msb,
                                long lsb)
        Check if the segment exists.
        Parameters:
        msb - the most significant bits of the identifier of the segment
        lsb - the least significant bits of the identifier of the segment
        Returns:
        true if the segment exists
      • writeGraph

        void writeGraph​(@NotNull
                        @org.jetbrains.annotations.NotNull byte[] data)
                 throws java.io.IOException
        Write the graph data.
        Parameters:
        data - serialized segment graph data
        Throws:
        java.io.IOException
      • writeBinaryReferences

        void writeBinaryReferences​(@NotNull
                                   @org.jetbrains.annotations.NotNull byte[] data)
                            throws java.io.IOException
        Write the binary references data.
        Parameters:
        data - serialized binary references data
        Throws:
        java.io.IOException
      • getLength

        long getLength()
        Get the current length of the archive.
        Returns:
        length of the archive, in bytes
      • getEntryCount

        int getEntryCount()
        Get the number of entries currently contained in the archive.
        Returns:
        number of entries
      • close

        void close()
            throws java.io.IOException
        Close the archive.
        Throws:
        java.io.IOException
      • isCreated

        boolean isCreated()
        Check if the archive has been created (eg. something has been written).
        Returns:
        true if the archive has been created, false otherwise
      • getName

        @NotNull
        @NotNull java.lang.String getName()
        Get the name of the archive.
        Returns:
        archive name
      • isRemote

        boolean isRemote()
        This method returns true if the storage is accessed via a network protocol, not tight to the traditional storage technology, for example, HTTP. Based on that info, for instance, calling classes can decide to update archive metadata (graph, binary references, index) more frequently, and not only when the archive is being closed. With that multiple Oak processes can access the storage simultaneously, with one process in read-write mode and one or more processes in read-only mode.
        Returns: