Class Store
- java.lang.Object
-
- org.mapdb.Store
-
- All Implemented Interfaces:
- java.io.Closeable, java.lang.AutoCloseable, Engine
- Direct Known Subclasses:
- StoreAppend, StoreArchive, StoreDirect, StoreHeap
public abstract class Store extends java.lang.Object implements Engine
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classStore.CacheCache implementation, part ofStoreclass.static classStore.LongLongMapOpen Hash Map which uses primitive long as values and keys.static classStore.LongObjectMap<V>Open Hash Map which uses primitive long as keys.static classStore.LongObjectObjectMap<V1,V2>Open Hash Map which uses primitive long as keys.static classStore.LongQueueQueue of primitive long.static classStore.MemoryBarrierLessLockLock which blocks parallel execution, but does not use MemoryBarrier (and does not flush CPU cache)static classStore.ReadWriteSingleLockfake read/write lock which in fact locks on single write lock-
Nested classes/interfaces inherited from interface org.mapdb.Engine
Engine.CloseOnJVMShutdown, Engine.ReadOnly, Engine.ReadOnlyWrapper
-
-
Field Summary
Fields Modifier and Type Field and Description static intLOCKING_STRATEGY_NOLOCKstatic intLOCKING_STRATEGY_READWRITELOCKstatic intLOCKING_STRATEGY_WRITELOCKstatic java.util.concurrent.locks.LockNOLOCKfake lock-
Fields inherited from interface org.mapdb.Engine
CLOSED_ENGINE, RECID_CLASS_CATALOG, RECID_FIRST, RECID_LAST_RESERVED, RECID_NAME_CATALOG, RECID_RECORD_CHECK
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description abstract voidbackup(java.io.OutputStream out, boolean incremental)abstract voidbackupRestore(java.io.InputStream[] in)booleancanSnapshot()voidclearCache()clears any underlying cache<A> booleancompareAndSwap(long recid, A expectedOldValue, A newValue, Serializer<A> serializer)Updates existing record in atomic (Compare And Swap) manner.<A> voiddelete(long recid, Serializer<A> serializer)Remove existing record from store/cacheabstract booleanfileLoad()If underlying storage is memory-mapped-file, this method will try to load and precache all file data into disk cache.static StoreforDB(DB db)traverses Engine wrappers and returns underlyingStorestatic StoreforEngine(Engine e)traverses Engine wrappers and returns underlyingStore<A> Aget(long recid, Serializer<A> serializer)Get existing record.abstract longgetCurrSize()abstract longgetFreeSize()EnginegetWrappedEngine()if this is wrapper return underlying engine, or nullvoidinit()booleanisClosed()Checks whether Engine was closed.booleanisReadOnly()Check if you can write into this Engine.voidmetricsCollect(java.util.Map<java.lang.String,java.lang.Long> map)puts metrics into given map<A> voidupdate(long recid, A value, Serializer<A> serializer)Update existing record with new value.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.mapdb.Engine
canRollback, close, commit, compact, preallocate, put, rollback, snapshot
-
-
-
-
Field Detail
-
LOCKING_STRATEGY_READWRITELOCK
public static final int LOCKING_STRATEGY_READWRITELOCK
- See Also:
- Constant Field Values
-
LOCKING_STRATEGY_WRITELOCK
public static final int LOCKING_STRATEGY_WRITELOCK
- See Also:
- Constant Field Values
-
LOCKING_STRATEGY_NOLOCK
public static final int LOCKING_STRATEGY_NOLOCK
- See Also:
- Constant Field Values
-
NOLOCK
public static final java.util.concurrent.locks.Lock NOLOCK
fake lock
-
-
Method Detail
-
init
public void init()
-
get
public <A> A get(long recid, Serializer<A> serializer)Description copied from interface:EngineGet existing record.
Recid must be a number returned by 'put' method. Behaviour for invalid recid (random number or already deleted record) is not defined, typically it returns null or throws 'EndOfFileException'
-
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- 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
-
delete
public <A> void delete(long recid, Serializer<A> serializer)Description copied from interface:EngineRemove existing record from store/cache
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.
-
isClosed
public boolean isClosed()
Description copied from interface:EngineChecks whether Engine was closed.
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:EngineCheck if you can write into this Engine. It may be readonly in some cases (snapshot, read-only files).- Specified by:
isReadOnlyin interfaceEngine- Returns:
- true if engine is read-only
-
forEngine
public static Store forEngine(Engine e)
traverses Engine wrappers and returns underlyingStore
-
getCurrSize
public abstract long getCurrSize()
-
getFreeSize
public abstract long getFreeSize()
-
fileLoad
public abstract boolean fileLoad()
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.- Returns:
- true if this method did something, false if underlying storage does not support loading, or is already in-memory
-
clearCache
public void clearCache()
Description copied from interface:Engineclears any underlying cache- Specified by:
clearCachein interfaceEngine
-
metricsCollect
public void metricsCollect(java.util.Map<java.lang.String,java.lang.Long> map)
puts metrics into given map
-
backup
public abstract void backup(java.io.OutputStream out, boolean incremental)
-
backupRestore
public abstract void backupRestore(java.io.InputStream[] in)
-
getWrappedEngine
public Engine getWrappedEngine()
Description copied from interface:Engineif this is wrapper return underlying engine, or null- Specified by:
getWrappedEnginein interfaceEngine
-
canSnapshot
public boolean canSnapshot()
- Specified by:
canSnapshotin interfaceEngine- Returns:
- true if engine can create read-only snapshots
-
-
DataMelt 3.0 © DataMelt by jWork.ORG