public class StoreDirect extends Store
| Modifier and Type | Class and Description |
|---|---|
static class |
StoreDirect.Snapshot |
Store.Cache, Store.LongList, Store.LongLongMap, Store.LongObjectMap<V>, Store.LongObjectObjectMap<V1,V2>, Store.LongQueue, Store.MemoryBarrierLessLock, Store.ReadWriteSingleLockEngine.CloseOnJVMShutdown, Engine.ReadOnly, Engine.ReadOnlyWrapper| Modifier and Type | Field and Description |
|---|---|
protected static long[] |
EMPTY_LONGS |
protected ScheduledExecutorService |
executor |
protected static long |
FREE_RECID_STACK |
protected AtomicLong |
freeSize |
protected static long |
HEAD_END |
protected static int |
HEADER
4 byte file header
|
protected Volume |
headVol |
protected static long |
INDEX_VAL_SIZE |
protected long[] |
indexPages |
protected static long |
INITCRC_INDEX_PAGE |
protected static long |
LAST_PHYS_ALLOCATED_DATA_OFFSET |
protected static long |
LONG_STACK_MAX_SIZE |
protected static long |
LONG_STACK_MIN_SIZE |
protected static long |
LONG_STACK_PREF_SIZE |
protected static long |
MARCHIVE |
protected static int |
MAX_REC_SIZE |
protected static long |
MAX_RECID_OFFSET
Maximal allocated recid.
|
protected static long |
MLINKED |
protected static long |
MOFFSET |
protected static long |
MPARITY |
protected static long |
MUNUSED |
protected static long |
PAGE_MASK |
protected static long |
PAGE_MASK_INVERSE |
protected static long |
PAGE_SIZE |
protected boolean |
recidReuseDisable |
protected long |
sizeIncrement |
protected int |
sliceShift |
protected static int |
SLOTS_COUNT
number of free physical slots
|
protected List<StoreDirect.Snapshot> |
snapshots |
protected long |
startSize |
protected static long |
STORE_SIZE |
protected static int |
STORE_VERSION
2 byte store version
|
protected static long |
UNUSED1 |
protected static long |
UNUSED2 |
protected static long |
UNUSED3 |
protected static long |
UNUSED4 |
protected static long |
UNUSED5 |
protected Volume |
vol |
caches, checksum, closed, commitLock, compress, deserializeExtra, encrypt, encryptionXTEA, FEAT_COMP_LZF, FEAT_CRC, FEAT_ENC_XTEA, fileLockDisable, fileLockHeartbeat, fileName, HEAD_CHECKSUM, HEAD_FEATURES, LOCKING_STRATEGY_NOLOCK, LOCKING_STRATEGY_READWRITELOCK, LOCKING_STRATEGY_WRITELOCK, lockMask, locks, lockScale, LOG, LZF, metricsDataRead, metricsDataWrite, metricsRecordRead, metricsRecordWrite, NOLOCK, readonly, recycledDataOut, snapshotEnable, structuralLock, volumeFactoryCLOSED_ENGINE, RECID_CLASS_CATALOG, RECID_FIRST, RECID_LAST_RESERVED, RECID_NAME_CATALOG, RECID_RECORD_CHECK| Constructor and Description |
|---|
StoreDirect(String fileName) |
StoreDirect(String fileName,
Volume.VolumeFactory volumeFactory,
Store.Cache cache,
int lockScale,
int lockingStrategy,
boolean checksum,
boolean compress,
byte[] password,
boolean readonly,
boolean snapshotEnable,
boolean fileLockDisable,
DataIO.HeartbeatFileLock fileLockHeartbeat,
ScheduledExecutorService executor,
long startSize,
long sizeIncrement,
boolean recidReuseDisable) |
| Modifier and Type | Method and Description |
|---|---|
void |
backup(OutputStream out,
boolean incremental) |
void |
backupRestore(InputStream[] ins) |
boolean |
canRollback() |
void |
clearCache()
clears any underlying cache
|
void |
close()
Close store/cache.
|
protected void |
closeFilesIgnoreException()
will try to close opened files.
|
void |
commit()
Makes all changes made since the previous commit/rollback permanent.
|
void |
compact() |
protected void |
compactIndexPage(StoreDirect target,
int indexPageI,
long maxRecid) |
protected void |
compactIndexPages(StoreDirect target,
AtomicLong maxRecid) |
protected boolean |
compactOldFilesExists() |
protected static long |
composeIndexVal(int size,
long offset,
boolean linked,
boolean unused,
boolean archive) |
protected <A> void |
delete2(long recid,
Serializer<A> serializer) |
boolean |
fileLoad()
If underlying storage is memory-mapped-file, this method will try to
load and precache all file data into disk cache.
|
protected void |
flush() |
protected void |
freeDataPut(int segment,
long[] linkedOffsets) |
protected void |
freeDataPut(int segment,
long offset,
int size) |
protected long[] |
freeDataTake(int size) |
protected long |
freeDataTakeSingle(int size,
boolean recursive) |
protected long |
freeRecidTake()
returns new recid, recid slot is allocated and ready to use
|
protected void |
freeSizeIncrement(int increment) |
protected <A> A |
get2(long recid,
Serializer<A> serializer) |
long |
getCurrSize() |
long |
getFreeSize() |
protected <A> A |
getFromOffset(Serializer<A> serializer,
long[] offsets) |
protected int |
headChecksum(Volume vol2) |
protected void |
indexLongPut(long offset,
long val) |
protected long |
indexValGet(long recid) |
protected long |
indexValGetRaw(long recid) |
protected void |
indexValPut(long recid,
int size,
long offset,
boolean linked,
boolean unused) |
void |
init() |
protected void |
initCreate() |
protected void |
initFailedCloseFiles() |
protected void |
initHeadVol() |
protected void |
initOpen() |
protected long |
lastAllocatedDataGet() |
protected void |
lastAllocatedDataSet(long offset) |
protected long |
longStackCount(long masterLinkOffset) |
protected long |
longStackMasterLinkOffset(long masterSize) |
protected void |
longStackNewPage(long masterLinkOffset,
long prevPageOffset,
long value,
boolean recursive) |
protected void |
longStackPut(long masterLinkOffset,
long value,
boolean recursive) |
protected long |
longStackTake(long masterLinkOffset,
boolean recursive) |
protected long |
maxRecidGet() |
protected void |
maxRecidSet(long maxRecid) |
protected long[] |
offsetsGet(int segment,
long indexVal)
return positions of (possibly) linked record
|
protected int |
offsetsTotalSize(long[] offsets) |
protected void |
offsetsVerify(long[] ret) |
protected long |
pageAllocate() |
protected void |
pageIndexEnsurePageForRecidAllocated(long recid) |
protected void |
pageIndexExtend() |
long |
preallocate()
Preallocates recid for not yet created record.
|
<A> long |
put(A value,
Serializer<A> serializer)
Insert new record.
|
protected void |
putData(long recid,
long[] offsets,
byte[] src,
int srcLen) |
protected void |
putDataSingleWithLink(int segment,
long offset,
long link,
byte[] buf,
int bufPos,
int size) |
protected void |
putDataSingleWithoutLink(int segment,
long offset,
byte[] buf,
int bufPos,
int size) |
protected long |
recidToOffset(long recid) |
protected boolean |
recidTooLarge(long recid)
check if recid offset fits into current allocated structure
|
void |
rollback()
Undoes all changes made in the current transaction.
|
protected static int |
round16Up(int pos) |
Engine |
snapshot()
Returns read-only snapshot of data in Engine.
|
protected void |
snapshotCloseAllOnCompact() |
protected long |
storeSizeGet() |
protected void |
storeSizeSet(long storeSize) |
protected void |
update2(long recid,
DataIO.DataOutputByteArray out) |
assertReadLocked, assertWriteLocked, canSnapshot, checkFeaturesBitmap, compareAndSwap, delete, deserialize, forDB, forEngine, get, getWrappedEngine, isClosed, isReadOnly, lockPos, longParityGet, longParitySet, makeFeaturesBitmap, metricsCollect, newDataOut2, serialize, updateprotected static final int STORE_VERSION
protected static final int HEADER
protected static final long PAGE_SIZE
protected static final long PAGE_MASK
protected static final long PAGE_MASK_INVERSE
protected static final long MOFFSET
protected static final long MLINKED
protected static final long MUNUSED
protected static final long MARCHIVE
protected static final long MPARITY
protected static final long STORE_SIZE
protected static final long MAX_RECID_OFFSET
protected static final long LAST_PHYS_ALLOCATED_DATA_OFFSET
protected static final long FREE_RECID_STACK
protected static final long UNUSED1
protected static final long UNUSED2
protected static final long UNUSED3
protected static final long UNUSED4
protected static final long UNUSED5
protected static final int MAX_REC_SIZE
protected static final int SLOTS_COUNT
protected static final long HEAD_END
protected static final long INITCRC_INDEX_PAGE
protected static final long[] EMPTY_LONGS
protected volatile Volume vol
protected volatile Volume headVol
protected volatile long[] indexPages
protected final ScheduledExecutorService executor
protected final List<StoreDirect.Snapshot> snapshots
protected static final long INDEX_VAL_SIZE
protected final long startSize
protected final long sizeIncrement
protected final boolean recidReuseDisable
protected final int sliceShift
protected final AtomicLong freeSize
protected static final long LONG_STACK_PREF_SIZE
protected static final long LONG_STACK_MIN_SIZE
protected static final long LONG_STACK_MAX_SIZE
public StoreDirect(String fileName, Volume.VolumeFactory volumeFactory, Store.Cache cache, int lockScale, int lockingStrategy, boolean checksum, boolean compress, byte[] password, boolean readonly, boolean snapshotEnable, boolean fileLockDisable, DataIO.HeartbeatFileLock fileLockHeartbeat, ScheduledExecutorService executor, long startSize, long sizeIncrement, boolean recidReuseDisable)
public StoreDirect(String fileName)
protected void initFailedCloseFiles()
protected void storeSizeSet(long storeSize)
protected long storeSizeGet()
protected void initOpen()
protected void initCreate()
protected void initHeadVol()
protected int headChecksum(Volume vol2)
protected <A> A get2(long recid,
Serializer<A> serializer)
protected <A> A getFromOffset(Serializer<A> serializer, long[] offsets)
protected int offsetsTotalSize(long[] offsets)
protected void update2(long recid,
DataIO.DataOutputByteArray out)
protected void offsetsVerify(long[] ret)
protected long[] offsetsGet(int segment,
long indexVal)
protected void indexValPut(long recid,
int size,
long offset,
boolean linked,
boolean unused)
protected <A> void delete2(long recid,
Serializer<A> serializer)
public long getCurrSize()
getCurrSize in class Storepublic long getFreeSize()
getFreeSize in class Storepublic boolean fileLoad()
Store
If underlying storage is memory-mapped-file, this method will try to
load and precache all file data into disk cache.
Most likely it will call MappedByteBuffer.load(),
but could also read content of entire file etc
This method will not pin data into memory, they might be removed at any time.
protected void freeSizeIncrement(int increment)
public long preallocate()
Enginepublic <A> long put(A value,
Serializer<A> serializer)
Enginevalue - records to be addedserializer - used to convert record into/from binary formprotected void putData(long recid,
long[] offsets,
byte[] src,
int srcLen)
protected void putDataSingleWithoutLink(int segment,
long offset,
byte[] buf,
int bufPos,
int size)
protected void putDataSingleWithLink(int segment,
long offset,
long link,
byte[] buf,
int bufPos,
int size)
protected void freeDataPut(int segment,
long[] linkedOffsets)
protected void freeDataPut(int segment,
long offset,
int size)
protected long[] freeDataTake(int size)
protected long freeDataTakeSingle(int size,
boolean recursive)
protected void longStackPut(long masterLinkOffset,
long value,
boolean recursive)
protected void longStackNewPage(long masterLinkOffset,
long prevPageOffset,
long value,
boolean recursive)
protected long longStackTake(long masterLinkOffset,
boolean recursive)
protected long longStackCount(long masterLinkOffset)
public void close()
EngineClose store/cache. This method must be called before JVM exits to flush all caches and prevent store corruption. Also it releases resources used by MapDB (disk, memory..).
Engine can no longer be used after this method was called. If Engine is used after closing, it may
throw any exception including NullPointerException
There is an configuration option DBMaker.Maker.closeOnJvmShutdown() which uses shutdown hook to automatically
close Engine when JVM shutdowns.
public void commit()
Engineprotected void flush()
public void rollback()
throws UnsupportedOperationException
EngineUnsupportedOperationException.UnsupportedOperationException - if transactions are disabledpublic boolean canRollback()
public Engine snapshot() throws UnsupportedOperationException
EngineUnsupportedOperationException - if snapshots are not supported/enabledpublic void clearCache()
EngineclearCache in interface EngineclearCache in class Storepublic void backup(OutputStream out, boolean incremental)
public void backupRestore(InputStream[] ins)
backupRestore in class Storepublic void compact()
protected boolean compactOldFilesExists()
protected void snapshotCloseAllOnCompact()
protected void compactIndexPages(StoreDirect target, AtomicLong maxRecid)
protected void compactIndexPage(StoreDirect target, int indexPageI, long maxRecid)
protected long indexValGet(long recid)
protected long indexValGetRaw(long recid)
protected final long recidToOffset(long recid)
protected boolean recidTooLarge(long recid)
protected static long composeIndexVal(int size,
long offset,
boolean linked,
boolean unused,
boolean archive)
protected long freeRecidTake()
protected void indexLongPut(long offset,
long val)
protected void pageIndexEnsurePageForRecidAllocated(long recid)
protected void pageIndexExtend()
protected long pageAllocate()
protected static int round16Up(int pos)
protected long longStackMasterLinkOffset(long masterSize)
protected void closeFilesIgnoreException()
protected void maxRecidSet(long maxRecid)
protected long maxRecidGet()
protected void lastAllocatedDataSet(long offset)
protected long lastAllocatedDataGet()
Copyright © 2015. All Rights Reserved.