public final class MMapDataAccess extends AbstractDataAccess
Java presents the mapped memory as a ByteBuffer, and ByteBuffer is not thread-safe, which means that access to a ByteBuffer must be externally synchronized.
This class itself is intended to be as thread-safe as other DataAccess implementations are.
The exact behavior of memory-mapping is reported to be wildly platform-dependent.
bitUtil, byteOrder, closed, EMPTY, header, HEADER_OFFSET, indexDivisor, name, SEGMENT_SIZE_MIN, segmentSizeInBytes, segmentSizePower
Modifier and Type | Method and Description |
---|---|
static void |
cleanMappedByteBuffer(ByteBuffer buffer) |
void |
close()
This method makes sure that the underlying used resources are released.
|
MMapDataAccess |
create(long bytes)
The first time you use a DataAccess object after configuring it you need to call this method.
|
boolean |
ensureCapacity(long bytes)
Ensures that the capacity of this object is at least the specified bytes.
|
void |
flush()
This method makes sure that the underlying data is written to the storage.
|
byte |
getByte(long bytePos) |
void |
getBytes(long bytePos,
byte[] values,
int length)
Get bytes from position 'index'
|
long |
getCapacity() |
int |
getInt(long bytePos)
Get 4 bytes from position 'bytePos'
|
int |
getSegments() |
short |
getShort(long bytePos)
Get 2 bytes from position 'index'
|
DAType |
getType() |
static boolean |
jreIsMinimumJava9() |
void |
load(int percentage)
Load memory mapped files into physical memory.
|
boolean |
loadExisting() |
void |
setByte(long bytePos,
byte value) |
void |
setBytes(long bytePos,
byte[] values,
int length)
Set bytes from position 'index' to the specified values
|
void |
setInt(long bytePos,
int value)
Set 4 bytes at position 'bytePos' to the specified value
|
void |
setShort(long bytePos,
short value)
Set 2 bytes at position 'index' to the specified value
|
copyHeader, getFullName, getHeader, getName, getSegmentSize, isClosed, isIntBased, isStoring, readHeader, setHeader, toString, writeHeader
public static boolean jreIsMinimumJava9()
public static void cleanMappedByteBuffer(ByteBuffer buffer)
public MMapDataAccess create(long bytes)
DataAccess
public boolean ensureCapacity(long bytes)
DataAccess
DataAccess.create(long)
public boolean loadExisting()
public void flush()
DataAccess
public void load(int percentage)
public void close()
DataAccess
close
in interface DataAccess
close
in interface Closeable
close
in interface AutoCloseable
close
in class AbstractDataAccess
public final void setInt(long bytePos, int value)
DataAccess
public final int getInt(long bytePos)
DataAccess
public final void setShort(long bytePos, short value)
DataAccess
public final short getShort(long bytePos)
DataAccess
public void setBytes(long bytePos, byte[] values, int length)
DataAccess
public void getBytes(long bytePos, byte[] values, int length)
DataAccess
values
- acts as outputpublic void setByte(long bytePos, byte value)
public byte getByte(long bytePos)
public long getCapacity()
public int getSegments()
public DAType getType()
Copyright © 2012–2022. All rights reserved.