public class MappedBytes 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(java.nio.channels.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 MappedBytes |
allocate(File file,
FileChannel.MapMode mode,
long size)
Allocates a mapped buffer.
|
static MappedBytes |
allocate(File file,
long size)
Allocates a mapped buffer in
FileChannel.MapMode.READ_WRITE mode. |
MappedBytes |
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.
|
close, read, read, readBoolean, readByte, readChar, readDouble, readFloat, readInt, readLong, readMedium, readShort, readString, readUnsignedByte, readUnsignedInt, readUnsignedMedium, readUnsignedShort, readUTF8, resize, size, write, write, writeBoolean, writeByte, writeChar, writeDouble, writeFloat, writeInt, writeLong, writeMedium, writeShort, writeString, writeUnsignedByte, writeUnsignedInt, writeUnsignedMedium, writeUnsignedShort, writeUTF8, zero, zero, zeroorder, orderpublic static MappedBytes allocate(File file, long 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(java.nio.channels.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(java.io.File, java.nio.channels.FileChannel.MapMode, long)public static MappedBytes allocate(File file, FileChannel.MapMode mode, long 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(java.nio.channels.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(java.io.File, long)public MappedBytes copy()
MappedBytes 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 NativeBytespublic void delete()
Copyright © 2013–2015. All rights reserved.