public class UnsafeDataAccess extends AbstractDataAccess
1. Highly experimental. Still some bugs and access through file/MMAP should work at some point
2. Compared to MMAP no syncDAWrapper is need to make it read and write safe from multiple threads
3. Cannot be used on Android as no memory allocation methods are available there
bitUtil, byteOrder, closed, EMPTY, header, HEADER_OFFSET, indexDivisor, name, SEGMENT_SIZE_MIN, segmentSizeInBytes, segmentSizePower| Modifier and Type | Method and Description |
|---|---|
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.
|
UnsafeDataAccess |
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.
|
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() |
boolean |
loadExisting() |
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 bytes)
Reduces the allocate space to the specified bytes.
|
checkBeforeRename, copyHeader, getFullName, getHeader, getName, getSegmentSize, isClosed, isIntBased, isStoring, readHeader, rename, setHeader, setSegmentSize, toString, writeHeaderpublic UnsafeDataAccess create(long bytes)
DataAccesspublic final boolean ensureCapacity(long bytes)
DataAccessDataAccess.create(long)public DataAccess copyTo(DataAccess da)
DataAccesscopyTo in interface DataAccesscopyTo in class AbstractDataAccesspublic boolean loadExisting()
public void flush()
Storablepublic void close()
Storableclose in interface Storable<DataAccess>close in interface Closeableclose in interface AutoCloseableclose in class AbstractDataAccesspublic final void setInt(long bytePos,
int value)
DataAccesspublic final int getInt(long bytePos)
DataAccesspublic short getShort(long bytePos)
DataAccesspublic void setShort(long bytePos,
short value)
DataAccesspublic final void setBytes(long bytePos,
byte[] values,
int length)
DataAccesspublic final void getBytes(long bytePos,
byte[] values,
int length)
DataAccessvalues - acts as outputpublic final long getCapacity()
public final int getSegments()
public final void trimTo(long bytes)
DataAccesspublic DAType getType()
Copyright © 2012–2018. All rights reserved.