Interface SegmentArchiveReader

    • 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 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 Buffer getGraph()
      Load the segment graph.
      @NotNull java.lang.String getName()
      Get the name of the archive.
      boolean hasGraph()
      Check if the segment graph has been persisted for this archive.
      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.
      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.
      @Nullable Buffer readSegment​(long msb, long lsb)
      Read the segment.
    • Method Detail

      • 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 the 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
      • listSegments

        java.util.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 Buffer getGraph()
                           throws java.io.IOException
        Load the segment graph.
        Returns:
        byte buffer representing the graph or null if the graph hasn't been persisted.
        Throws:
        java.io.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 Buffer getBinaryReferences()
                                     throws java.io.IOException
        Load binary references.
        Returns:
        byte buffer representing the binary references structure.
        Throws:
        java.io.IOException
      • length

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

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

        void close()
            throws java.io.IOException
        Close the archive.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.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
      • 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: