Module methanol

Interface Store.Viewer

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable
    Enclosing interface:
    Store

    public static interface Store.Viewer
    extends java.io.Closeable
    Reads an entry's metadata block and data stream.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void close()
      Closes this viewer.
      long dataSize()
      Returns the size in bytes of the data stream.
      default java.util.Optional<Store.Editor> edit()
      Synchronous variant of edit(Executor).
      java.util.concurrent.CompletableFuture<java.util.Optional<Store.Editor>> edit​(java.util.concurrent.Executor executor)
      Opens an editor for the entry this viewer was opened for.
      long entrySize()
      Returns the size in bytes of the metadata block and data stream.
      java.lang.String key()
      Returns the entry's key.
      java.nio.ByteBuffer metadata()
      Returns the entry's metadata as a readonly buffer.
      Store.EntryReader newReader()
      Returns a new Store.EntryReader that reads the entry's data stream from the start.
      boolean removeEntry()
      Removes the entry associated with this viewer only if it hasn't changed since this viewer was opened.
    • Method Detail

      • key

        java.lang.String key()
        Returns the entry's key.
      • metadata

        java.nio.ByteBuffer metadata()
        Returns the entry's metadata as a readonly buffer.
      • newReader

        Store.EntryReader newReader()
        Returns a new Store.EntryReader that reads the entry's data stream from the start. A viewer can have multiple concurrent readers, each with an independent position.
      • dataSize

        long dataSize()
        Returns the size in bytes of the data stream.
      • entrySize

        long entrySize()
        Returns the size in bytes of the metadata block and data stream.
      • edit

        default java.util.Optional<Store.Editor> edit()
                                               throws java.io.IOException
        Synchronous variant of edit(Executor).
        Throws:
        java.lang.IllegalStateException - if closed
        java.io.IOException
      • edit

        java.util.concurrent.CompletableFuture<java.util.Optional<Store.Editor>> edit​(java.util.concurrent.Executor executor)
        Opens an editor for the entry this viewer was opened for. An empty optional is returned if another edit is in progress or if the entry has been modified since this viewer was created. Changes made by the returned editor are not reflected by this viewer.
        Throws:
        java.lang.IllegalStateException - if closed
      • removeEntry

        boolean removeEntry()
                     throws java.io.IOException
        Removes the entry associated with this viewer only if it hasn't changed since this viewer was opened.
        Throws:
        java.lang.IllegalStateException - if closed
        java.io.IOException
      • close

        void close()
        Closes this viewer.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable