Class StoreHeap
- java.lang.Object
-
- org.mapdb.Store
-
- org.mapdb.StoreHeap
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classStoreHeap.Snapshot-
Nested classes/interfaces inherited from class org.mapdb.Store
Store.Cache, Store.LongLongMap, Store.LongObjectMap<V>, Store.LongObjectObjectMap<V1,V2>, Store.LongQueue, Store.MemoryBarrierLessLock, Store.ReadWriteSingleLock
-
Nested classes/interfaces inherited from interface org.mapdb.Engine
Engine.CloseOnJVMShutdown, Engine.ReadOnly, Engine.ReadOnlyWrapper
-
-
Field Summary
-
Fields inherited from class org.mapdb.Store
LOCKING_STRATEGY_NOLOCK, LOCKING_STRATEGY_READWRITELOCK, LOCKING_STRATEGY_WRITELOCK, NOLOCK
-
Fields inherited from interface org.mapdb.Engine
CLOSED_ENGINE, RECID_CLASS_CATALOG, RECID_FIRST, RECID_LAST_RESERVED, RECID_NAME_CATALOG, RECID_RECORD_CHECK
-
-
Constructor Summary
Constructors Constructor and Description StoreHeap(boolean txDisabled, int lockScale, int lockingStrategy, boolean snapshotEnable)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidbackup(java.io.OutputStream out, boolean incremental)voidbackupRestore(java.io.InputStream[] in)booleancanRollback()voidclose()Close store/cache.voidcommit()Makes all changes made since the previous commit/rollback permanent.voidcompact()<A> booleancompareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer)Updates existing record in atomic (Compare And Swap) manner.booleanfileLoad()If underlying storage is memory-mapped-file, this method will try to load and precache all file data into disk cache.longgetCurrSize()longgetFreeSize()longpreallocate()Preallocates recid for not yet created record.<A> longput(A value, Serializer<A> serializer)Insert new record.voidrollback()Undoes all changes made in the current transaction.Enginesnapshot()Returns read-only snapshot of data in Engine.<A> voidupdate(long recid, A value, Serializer<A> serializer)Update existing record with new value.-
Methods inherited from class org.mapdb.Store
canSnapshot, clearCache, delete, forDB, forEngine, get, getWrappedEngine, init, isClosed, isReadOnly, metricsCollect
-
-
-
-
Constructor Detail
-
StoreHeap
public StoreHeap(boolean txDisabled, int lockScale, int lockingStrategy, boolean snapshotEnable)
-
-
Method Detail
-
update
public <A> void update(long recid, A value, Serializer<A> serializer)Description copied from interface:EngineUpdate existing record with new value.
Recid must be a number returned by 'put' method. Behaviour for invalid recid (random number or already deleted record) is not defined, typically it throws 'EndOfFileException', but it may also corrupt store.
-
compareAndSwap
public <A> boolean compareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer)Description copied from interface:EngineUpdates existing record in atomic (Compare And Swap) manner. Value is modified only if old value matches expected value. There are three ways to match values, MapDB may use any of them:
- Equality check
oldValue==expectedOldValuewhen old value is found in instance cache - Deserializing
oldValueusingserializerand checkingoldValue.equals(expectedOldValue) - Serializing
expectedOldValueusingserializerand comparing binary array with already serializedoldValue
Recid must be a number returned by 'put' method. Behaviour for invalid recid (random number or already deleted record) is not defined, typically it throws 'EndOfFileException', but it may also corrupt store.
- Specified by:
compareAndSwapin interfaceEngine- Overrides:
compareAndSwapin classStore- Parameters:
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 form- Returns:
- true if values matched and newValue was written
- Equality check
-
getCurrSize
public long getCurrSize()
- Specified by:
getCurrSizein classStore
-
getFreeSize
public long getFreeSize()
- Specified by:
getFreeSizein classStore
-
fileLoad
public boolean fileLoad()
Description copied from class:StoreIf 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.
-
backup
public void backup(java.io.OutputStream out, boolean incremental)
-
backupRestore
public void backupRestore(java.io.InputStream[] in)
- Specified by:
backupRestorein classStore
-
preallocate
public long preallocate()
Description copied from interface:EnginePreallocates recid for not yet created record. It does not insert any data into it.- Returns:
- new recid
-
put
public <A> long put(A value, Serializer<A> serializer)Description copied from interface:EngineInsert new record.- Parameters:
value- records to be addedserializer- used to convert record into/from binary form- Returns:
- recid (record identifier) under which record is stored.
-
close
public void close()
Description copied from interface: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
NullPointerExceptionThere is an configuration option
DBMaker.Maker.closeOnJvmShutdown()which uses shutdown hook to automatically close Engine when JVM shutdowns.
-
commit
public void commit()
Description copied from interface:EngineMakes all changes made since the previous commit/rollback permanent. In transactional mode (on by default) it means creating journal file and replaying it to storage. In other modes it may flush disk caches or do nothing at all (check your config options)
-
rollback
public void rollback() throws java.lang.UnsupportedOperationExceptionDescription copied from interface:EngineUndoes all changes made in the current transaction. If transactions are disabled it throwsUnsupportedOperationException.- Throws:
java.lang.UnsupportedOperationException- if transactions are disabled
-
canRollback
public boolean canRollback()
- Returns:
- true if engine supports rollback
-
snapshot
public Engine snapshot() throws java.lang.UnsupportedOperationException
Description copied from interface:EngineReturns read-only snapshot of data in Engine.- Throws:
java.lang.UnsupportedOperationException- if snapshots are not supported/enabled
-
compact
public void compact()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG