@InterfaceAudience.Private public class FileMmapEngine extends Object implements IOEngine
| Modifier and Type | Field and Description |
|---|---|
private ByteBufferArray |
bufferArray |
private FileChannel |
fileChannel |
(package private) static org.slf4j.Logger |
LOG |
private String |
path |
private RandomAccessFile |
raf |
private long |
size |
| Constructor and Description |
|---|
FileMmapEngine(String filePath,
long capacity) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
isPersistent()
File IO engine is always able to support persistent storage for the cache
|
Cacheable |
read(long offset,
int length,
CacheableDeserializer<Cacheable> deserializer)
Transfers data from IOEngine to a Cacheable object.
|
private long |
roundUp(long n,
long to) |
void |
shutdown()
Close the file
|
void |
sync()
Sync the data to file after writing
|
String |
toString() |
void |
write(ByteBuffer srcBuffer,
long offset)
Transfers data from the given byte buffer to file
|
void |
write(ByteBuff srcBuffer,
long offset)
Transfers the data from the given MultiByteBuffer to IOEngine
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitusesSharedMemorystatic final org.slf4j.Logger LOG
private long size
private ByteBufferArray bufferArray
private final FileChannel fileChannel
private RandomAccessFile raf
public FileMmapEngine(String filePath, long capacity) throws IOException
IOExceptionprivate long roundUp(long n, long to)
public boolean isPersistent()
isPersistent in interface IOEnginepublic Cacheable read(long offset, int length, CacheableDeserializer<Cacheable> deserializer) throws IOException
IOEngineread in interface IOEngineoffset - The offset in the IO engine where the first byte to be readlength - How many bytes to be read from the offsetdeserializer - The deserializer to be used to make a Cacheable from the data.IOExceptionpublic void write(ByteBuffer srcBuffer, long offset) throws IOException
write in interface IOEnginesrcBuffer - the given byte buffer from which bytes are to be readoffset - The offset in the file where the first byte to be writtenIOExceptionpublic void write(ByteBuff srcBuffer, long offset) throws IOException
IOEnginewrite in interface IOEnginesrcBuffer - the given MultiBytebufffers from which bytes are to be readoffset - the offset in the IO engine where the first byte to be writtenIOExceptionpublic void sync() throws IOException
sync in interface IOEngineIOExceptionCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.