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.
|
DataAccess |
copyTo(DataAccess da)
Copies the content from this object into the specified one.
|
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() |
boolean |
loadExisting() |
void |
rename(String newName)
Renames the underlying DataAccess object.
|
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
|
void |
trimTo(long capacity)
Reduces the allocate space to the specified bytes.
|
checkBeforeRename, copyHeader, getFullName, getHeader, getName, getSegmentSize, isClosed, isIntBased, isStoring, readHeader, setHeader, setSegmentSize, toString, writeHeader
public static boolean jreIsMinimumJava9()
public static void cleanMappedByteBuffer(ByteBuffer buffer)
public MMapDataAccess create(long bytes)
DataAccess
public DataAccess copyTo(DataAccess da)
DataAccess
copyTo
in interface DataAccess
copyTo
in class AbstractDataAccess
public boolean ensureCapacity(long bytes)
DataAccess
DataAccess.create(long)
public boolean loadExisting()
public void flush()
Storable
public void close()
Storable
close
in interface Storable<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 void trimTo(long capacity)
DataAccess
public void rename(String newName)
DataAccess
rename
in interface DataAccess
rename
in class AbstractDataAccess
public DAType getType()
Copyright © 2012–2020. All rights reserved.