public class UnsafeMappedBytes extends NativeBytes
Mapped bytes provide direct access to memory from allocated by a MappedByteBuffer. Memory is allocated
by opening and expanding the given File to the desired count and mapping the file contents into memory
via FileChannel.map(FileChannel.MapMode, long, long).
Closing the bytes via Bytes.close() will result in BytesOutput.flush()
being automatically called.
| Modifier and Type | Method and Description |
|---|---|
static UnsafeMappedBytes |
allocate(File file,
FileChannel.MapMode mode,
int size)
Allocates a mapped buffer.
|
static UnsafeMappedBytes |
allocate(File file,
int size)
Allocates a mapped buffer in
FileChannel.MapMode#READ_WRITE mode. |
void |
close() |
UnsafeMappedBytes |
copy()
Copies the bytes to a new byte array.
|
void |
delete()
Deletes the underlying file.
|
Bytes |
flush()
Flushes the bytes to the underlying persistence layer.
|
boolean |
isDirect()
Returns a boolean value indicating whether the bytes are direct.
|
boolean |
isFile()
Returns a boolean value indicating whether the bytes are backed by a file.
|
read, read, readByte, readChar, readDouble, readFloat, readInt, readLong, readMedium, readShort, readUnsignedMedium, resize, size, write, write, writeByte, writeChar, writeDouble, writeFloat, writeInt, writeLong, writeMedium, writeShort, writeUnsignedMedium, zero, zero, zeroorder, order, readBoolean, readString, readString, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF8, writeBoolean, writeString, writeString, writeUnsignedByte, writeUnsignedInt, writeUnsignedShort, writeUTF8public static UnsafeMappedBytes allocate(File file, int size)
FileChannel.MapMode#READ_WRITE mode.
Memory will be mapped by opening and expanding the given File to the desired count and mapping the
file contents into memory via FileChannel.map(FileChannel.MapMode, long, long).
file - The file to map into memory. If the file doesn't exist it will be automatically created.size - The count of the buffer to allocate (in bytes).NullPointerException - If file is nullIllegalArgumentException - If count is greater than MappedMemory.MAX_SIZEallocate(File, FileChannel.MapMode, int)public static UnsafeMappedBytes allocate(File file, FileChannel.MapMode mode, int size)
Memory will be mapped by opening and expanding the given File to the desired count and mapping the
file contents into memory via FileChannel.map(FileChannel.MapMode, long, long).
file - The file to map into memory. If the file doesn't exist it will be automatically created.mode - The mode with which to map the file.size - The count of the buffer to allocate (in bytes).NullPointerException - If file is nullIllegalArgumentException - If count is greater than MappedMemory.MAX_SIZEallocate(File, int)public UnsafeMappedBytes copy()
UnsafeMappedBytes instance backed by a copy of this instance's memory.public boolean isDirect()
BytesisDirect in interface BytesisDirect in class NativeBytespublic boolean isFile()
BytesisFile in interface BytesisFile in class AbstractBytespublic Bytes flush()
BytesOutputflush in interface BytesOutput<Bytes>flush in class AbstractBytespublic void close()
close in interface Bytesclose in interface AutoCloseableclose in class NativeBytespublic void delete()
Copyright © 2013–2017. All rights reserved.