-
- All Superinterfaces:
java.lang.AutoCloseable,java.io.Closeable
- Enclosing interface:
- Store
public static interface Store.Viewer extends java.io.CloseableReads an entry's metadata block and data stream.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidclose()Closes this viewer.longdataSize()Returns the size in bytes of the data stream.default java.util.Optional<Store.Editor>edit()Synchronous variant ofedit(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.longentrySize()Returns the size in bytes of the metadata block and data stream.java.lang.Stringkey()Returns the entry's key.java.nio.ByteBuffermetadata()Returns the entry's metadata as a readonly buffer.Store.EntryReadernewReader()Returns a newStore.EntryReaderthat reads the entry's data stream from the start.booleanremoveEntry()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 newStore.EntryReaderthat 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 ofedit(Executor).- Throws:
java.lang.IllegalStateException- if closedjava.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.IOExceptionRemoves the entry associated with this viewer only if it hasn't changed since this viewer was opened.- Throws:
java.lang.IllegalStateException- if closedjava.io.IOException
-
close
void close()
Closes this viewer.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
-