public interface StorageUnit extends Closeable
Modifier and Type | Method and Description |
---|---|
long |
capacity()
Get total maximum capacity of this storage.
|
default boolean |
createEmpty()
Creates this empty unit in the file system
|
default int |
readBlock(byte[] buffer,
long offset)
Try to read a block of data into the provided array, starting with a given offset.
|
int |
readBlock(ByteBuffer buffer,
long offset)
Try to read a block of data into the provided buffer, starting with a given offset.
|
default void |
readBlockFully(ByteBuffer buffer,
long offset) |
long |
size()
Get current amount of data in this storage.
|
default int |
writeBlock(byte[] block,
long offset)
Try to write a block of data to this storage, starting with a given offset.
|
int |
writeBlock(ByteBuffer buffer,
long offset)
Try to write a block of data from the provided buffer to this storage, starting with a given offset.
|
int |
writeBlock(ByteBufferView buffer,
long offset)
Try to write a block of data from the provided buffer to this storage, starting with a given offset.
|
default void |
writeBlockFully(ByteBuffer buffer,
long offset) |
default void |
writeBlockFully(ByteBufferView buffer,
long offset) |
int readBlock(ByteBuffer buffer, long offset)
Buffer.remaining()
.
Storage must throw an exception if
offset > capacity()
- buffer.remaining()
buffer
- Buffer to read bytes into.
Value returned by buffer.remaining() determines
the maximum number of bytes to read.offset
- Index to start reading from (0-based)default void readBlockFully(ByteBuffer buffer, long offset)
default int readBlock(byte[] buffer, long offset)
Buffer.remaining()
.
Storage must throw an exception if
offset > capacity()
- length
buffer
- Array to read bytes into.
Array's length determines the maximum number of bytes to read.offset
- Index to starting reading from (0-based)int writeBlock(ByteBuffer buffer, long offset)
Maximum number of bytes to be written is determined by Buffer.remaining()
.
Storage must throw an exception if
offset > capacity()
- buffer.remaining()
buffer
- Buffer containing the block of data to write to this storage.
Value returned by buffer.remaining() determines
the maximum number of bytes to write.offset
- Offset in this storage's data to start writing to (0-based)default void writeBlockFully(ByteBuffer buffer, long offset)
int writeBlock(ByteBufferView buffer, long offset)
Maximum number of bytes to be written is determined by ByteBufferView.remaining()
.
Storage must throw an exception if
offset > capacity()
- buffer.remaining()
buffer
- Buffer containing the block of data to write to this storage.
Value returned by buffer.remaining() determines
the maximum number of bytes to write.offset
- Offset in this storage's data to start writing to (0-based)default void writeBlockFully(ByteBufferView buffer, long offset)
default int writeBlock(byte[] block, long offset)
Maximum number of bytes to be written is determined by block's length.
Storage must throw an exception if
offset > capacity()
- block.length
block
- Block of data to write to this storage.
Block's length determines the maximum number of bytes to write.offset
- Offset in this storage's data to start writing to (0-based)default boolean createEmpty()
long capacity()
long size()
Copyright © 2016–2021. All rights reserved.