public class StoreWAL extends StoreDirect
Modifier and Type | Field and Description |
---|---|
protected long[] |
indexVals |
protected boolean[] |
indexValsModified |
protected Volume |
log |
protected static long |
LOG_MASK_OFFSET |
protected static long |
LOG_SEAL
added to offset 8 into log file, indicates that log was synced and closed
|
protected AtomicInteger |
logChecksum |
protected long |
logSize |
protected LongMap<byte[]> |
longStackPages |
protected LongConcurrentHashMap<long[]> |
modified |
protected static long[] |
PREALLOC |
protected boolean |
replayPending |
protected static long[] |
TOMBSTONE |
static String |
TRANS_LOG_FILE_EXT |
protected Volume.Factory |
volFac |
protected static byte |
WAL_INDEX_LONG |
protected static byte |
WAL_LONGSTACK_PAGE |
protected static byte |
WAL_PHYS_ARRAY |
protected static byte |
WAL_PHYS_ARRAY_ONE_LONG |
protected static byte |
WAL_SEAL
last instruction in log file
|
protected static byte |
WAL_SKIP_REST_OF_BLOCK |
DATA_FILE_EXT, deleteFilesAfterClose, freeSize, HEADER, index, indexSize, IO_FREE_RECID, IO_FREE_SIZE, IO_INDEX_SIZE, IO_INDEX_SUM, IO_PHYS_SIZE, IO_USER_START, LONG_STACK_PREF_COUNT, LONG_STACK_PREF_COUNT_ALTER, LONG_STACK_PREF_SIZE, LONG_STACK_PREF_SIZE_ALTER, MASK_ARCHIVE, MASK_DISCARD, MASK_LINKED, MASK_OFFSET, MAX_REC_SIZE, maxUsedIoList, phys, PHYS_FREE_SLOTS_COUNT, physSize, readOnly, sizeLimit, spaceReclaimReuse, spaceReclaimSplit, spaceReclaimTrack, STORE_VERSION, syncOnCommitDisabled
checksum, CHECKSUM_FLAG_MASK, CHUNK_SIZE, CHUNK_SIZE_MOD_MASK, compress, COMPRESS_FLAG_MASK, encrypt, ENCRYPT_FLAG_MASK, encryptionXTEA, locks, LOG, LZF, newRecidLock, password, recycledDataOuts, serializerPojo, serializerPojoInitLock, structuralLock
CATALOG_RECID, CHECK_RECORD, CLASS_INFO_RECID, LAST_RESERVED_RECID
Constructor and Description |
---|
StoreWAL(Volume.Factory volFac) |
StoreWAL(Volume.Factory volFac,
boolean readOnly,
boolean deleteFilesAfterClose,
int spaceReclaimMode,
boolean syncOnCommitDisabled,
long sizeLimit,
boolean checksum,
boolean compress,
byte[] password,
boolean disableLocks,
int sizeIncrement) |
Modifier and Type | Method and Description |
---|---|
boolean |
canRollback() |
protected void |
checkHeaders() |
protected void |
checkLogRounding() |
void |
close()
Close store/cache.
|
void |
commit()
Makes all changes made since the previous commit/rollback permanent.
|
protected void |
compactPostUnderLock()
subclasses put additional cleanup after compaction finishes here
|
protected void |
compactPreUnderLock()
subclasses put additional checks before compaction starts here
|
<A> boolean |
compareAndSwap(long recid,
A expectedOldValue,
A newValue,
Serializer<A> serializer)
Updates existing record in atomic (Compare And Swap) manner.
|
<A> void |
delete(long recid,
Serializer<A> serializer)
Remove existing record from store/cache
Recid must be a number returned by 'put' method.
|
<A> A |
get(long recid,
Serializer<A> serializer)
Get existing record.
|
protected <A> A |
get2(long ioRecid,
Serializer<A> serializer) |
protected long[] |
getLinkedRecordsFromLog(long ioRecid) |
protected long |
indexHeaderChecksumUncommited() |
protected long[] |
logAllocate(long[] physPos) |
protected void |
logChecksumAdd(int cs) |
protected boolean |
logDirty() |
protected void |
logReset() |
protected byte[] |
longStackGetPage(long offset) |
protected static long |
longStackGetSixLong(byte[] page,
int pos) |
protected void |
longStackPut(long ioList,
long offset,
boolean recursive) |
protected static void |
longStackPutSixLong(byte[] page,
int pos,
long value) |
protected long |
longStackTake(long ioList,
boolean recursive) |
long |
preallocate()
Preallocates recid for not yet created record.
|
void |
preallocate(long[] recids)
Preallocates recids for not yet created record.
|
<A> long |
put(A value,
Serializer<A> serializer)
Insert new record.
|
protected void |
reloadIndexFile() |
protected void |
replayLogFile() |
void |
rollback()
Undoes all changes made in the current transaction.
|
<A> void |
update(long recid,
A value,
Serializer<A> serializer)
Update existing record with new value.
|
protected boolean |
verifyLogFile() |
protected void |
walIndexVal(long logPos,
long ioRecid,
long indexVal) |
protected void |
walPhysArray(DataOutput2 out,
long[] physPos,
long[] logPos) |
calculateStatistics, clearCache, compact, countLongStackItems, createStructure, freeIoRecidPut, freeIoRecidTake, freePhysPut, freePhysTake, getCurrSize, getFreeRecids, getFreeSize, getLinkedRecordsIndexVals, getMaxRecid, getRaw, getSizeLimit, indexHeaderChecksum, isClosed, isReadOnly, physAllocate, put2, roundTo16, size2ListIoRecid, update2, updateRaw
canSnapshot, closeListenerRegister, closeListenerUnregister, deserialize, expectedMasks, forDB, forEngine, getSerializerPojo, lockAllWrite, lockPos, newDataOut2, printStatistics, serialize, snapshot, unlockAllWrite
protected static final long LOG_MASK_OFFSET
protected static final byte WAL_INDEX_LONG
protected static final byte WAL_LONGSTACK_PAGE
protected static final byte WAL_PHYS_ARRAY_ONE_LONG
protected static final byte WAL_PHYS_ARRAY
protected static final byte WAL_SKIP_REST_OF_BLOCK
protected static final byte WAL_SEAL
protected static final long LOG_SEAL
public static final String TRANS_LOG_FILE_EXT
protected static final long[] TOMBSTONE
protected static final long[] PREALLOC
protected final Volume.Factory volFac
protected Volume log
protected volatile long logSize
protected final LongConcurrentHashMap<long[]> modified
protected final LongMap<byte[]> longStackPages
protected final long[] indexVals
protected final boolean[] indexValsModified
protected boolean replayPending
protected final AtomicInteger logChecksum
public StoreWAL(Volume.Factory volFac)
public StoreWAL(Volume.Factory volFac, boolean readOnly, boolean deleteFilesAfterClose, int spaceReclaimMode, boolean syncOnCommitDisabled, long sizeLimit, boolean checksum, boolean compress, byte[] password, boolean disableLocks, int sizeIncrement)
protected void checkHeaders()
checkHeaders
in class StoreDirect
protected void reloadIndexFile()
protected void logReset()
public long preallocate()
Engine
preallocate
in interface Engine
preallocate
in class StoreDirect
public void preallocate(long[] recids)
Engine
preallocate
in interface Engine
preallocate
in class StoreDirect
recids
- array to put result intopublic <A> long put(A value, Serializer<A> serializer)
Engine
put
in interface Engine
put
in class StoreDirect
value
- records to be addedserializer
- used to convert record into/from binary formprotected void walPhysArray(DataOutput2 out, long[] physPos, long[] logPos)
protected void walIndexVal(long logPos, long ioRecid, long indexVal)
protected long[] logAllocate(long[] physPos)
protected void checkLogRounding()
public <A> A get(long recid, Serializer<A> serializer)
Engine
get
in interface Engine
get
in class StoreDirect
recid
- (record identifier) under which record was persistedserializer
- used to deserialize record from binary formprotected <A> A get2(long ioRecid, Serializer<A> serializer) throws IOException
get2
in class StoreDirect
IOException
public <A> void update(long recid, A value, Serializer<A> serializer)
Engine
update
in interface Engine
update
in class StoreDirect
recid
- (record identifier) under which record was persisted.value
- new record value to be storedserializer
- used to serialize record into binary formpublic <A> boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer)
Engine
oldValue==expectedOldValue
when old value is found in instance cacheoldValue
using serializer
and checking oldValue.equals(expectedOldValue)
expectedOldValue
using serializer
and comparing binary array with already serialized oldValue
compareAndSwap
in interface Engine
compareAndSwap
in class StoreDirect
recid
- (record identifier) under which record was persisted.expectedOldValue
- old value to be compared with existing recordnewValue
- to be written if values are matchingserializer
- used to serialize record into binary formpublic <A> void delete(long recid, Serializer<A> serializer)
Engine
delete
in interface Engine
delete
in class StoreDirect
recid
- (record identifier) under which was record persistedserializer
- which may be used in some circumstances to deserialize and store old objectpublic void commit()
Engine
commit
in interface Engine
commit
in class StoreDirect
protected boolean logDirty()
protected long indexHeaderChecksumUncommited()
protected boolean verifyLogFile()
protected void replayLogFile()
public void rollback() throws UnsupportedOperationException
Engine
UnsupportedOperationException
.rollback
in interface Engine
rollback
in class StoreDirect
UnsupportedOperationException
- if transactions are disabledprotected long[] getLinkedRecordsFromLog(long ioRecid)
protected long longStackTake(long ioList, boolean recursive)
longStackTake
in class StoreDirect
protected void longStackPut(long ioList, long offset, boolean recursive)
longStackPut
in class StoreDirect
protected static long longStackGetSixLong(byte[] page, int pos)
protected static void longStackPutSixLong(byte[] page, int pos, long value)
protected byte[] longStackGetPage(long offset)
public void close()
Engine
NullPointerException
There is an configuration option DBMaker.closeOnJvmShutdown()
which uses shutdown hook to automatically
close Engine when JVM shutdowns.close
in interface Engine
close
in class StoreDirect
protected void compactPreUnderLock()
StoreDirect
compactPreUnderLock
in class StoreDirect
protected void compactPostUnderLock()
StoreDirect
compactPostUnderLock
in class StoreDirect
public boolean canRollback()
canRollback
in interface Engine
canRollback
in class StoreDirect
protected void logChecksumAdd(int cs)
Copyright © 2016. All rights reserved.