org.mapdb
Class Store

java.lang.Object
  extended by org.mapdb.Store
All Implemented Interfaces:
Engine
Direct Known Subclasses:
StoreDirect, StoreHeap

public abstract class Store
extends Object
implements Engine

Low level record store.


Field Summary
protected  boolean checksum
           
protected static int CHECKSUM_FLAG_MASK
           
protected static int CHUNK_SIZE
           
protected static int CHUNK_SIZE_MOD_MASK
           
protected  boolean compress
           
protected static int COMPRESS_FLAG_MASK
           
protected  boolean encrypt
           
protected static int ENCRYPT_FLAG_MASK
           
protected  EncryptionXTEA encryptionXTEA
           
protected  ReentrantReadWriteLock[] locks
           
protected static Logger LOG
           
protected  ThreadLocal<CompressLZF> LZF
           
protected  ReentrantReadWriteLock newRecidLock
           
protected  byte[] password
           
protected  Queue<DataOutput2> recycledDataOuts
           
protected  SerializerPojo serializerPojo
          default serializer used for persistence.
protected  Lock serializerPojoInitLock
           
protected  ReentrantLock structuralLock
           
 
Fields inherited from interface org.mapdb.Engine
CATALOG_RECID, CHECK_RECORD, CLASS_INFO_RECID, LAST_RESERVED_RECID
 
Constructor Summary
protected Store(boolean checksum, boolean compress, byte[] password, boolean disableLocks)
           
 
Method Summary
abstract  String calculateStatistics()
          get some statistics about store.
 boolean canSnapshot()
           
 void closeListenerRegister(Runnable closeListener)
           
 void closeListenerUnregister(Runnable closeListener)
           
protected
<A> A
deserialize(Serializer<A> serializer, int size, DataInput input)
           
protected  int expectedMasks()
           
static Store forDB(DB db)
          traverses EngineWrappers and returns underlying Store
static Store forEngine(Engine e)
          traverses EngineWrappers and returns underlying Store
abstract  long getCurrSize()
          returns current size occupied by physical store (does not include index).
abstract  Iterator<Long> getFreeRecids()
           
abstract  long getFreeSize()
          returns free size in physical store (does not include index).
abstract  long getMaxRecid()
           
abstract  ByteBuffer getRaw(long recid)
           
 SerializerPojo getSerializerPojo()
          Returns default serializer associated with this engine.
abstract  long getSizeLimit()
          returns maximal store size or `0` if there is no limit
protected  void lockAllWrite()
           
protected static int lockPos(long key)
           
protected  DataOutput2 newDataOut2()
           
 void printStatistics()
           
protected
<A> DataOutput2
serialize(A value, Serializer<A> serializer)
           
 Engine snapshot()
          Returns read-only snapshot of data in Engine.
protected  void unlockAllWrite()
           
abstract  void updateRaw(long recid, ByteBuffer data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.mapdb.Engine
canRollback, clearCache, close, commit, compact, compareAndSwap, delete, get, isClosed, isReadOnly, preallocate, preallocate, put, rollback, update
 

Field Detail

LOG

protected static final Logger LOG

checksum

protected final boolean checksum

compress

protected final boolean compress

encrypt

protected final boolean encrypt

password

protected final byte[] password

encryptionXTEA

protected final EncryptionXTEA encryptionXTEA

CHECKSUM_FLAG_MASK

protected static final int CHECKSUM_FLAG_MASK
See Also:
Constant Field Values

COMPRESS_FLAG_MASK

protected static final int COMPRESS_FLAG_MASK
See Also:
Constant Field Values

ENCRYPT_FLAG_MASK

protected static final int ENCRYPT_FLAG_MASK
See Also:
Constant Field Values

CHUNK_SIZE

protected static final int CHUNK_SIZE
See Also:
Constant Field Values

CHUNK_SIZE_MOD_MASK

protected static final int CHUNK_SIZE_MOD_MASK
See Also:
Constant Field Values

serializerPojo

protected SerializerPojo serializerPojo
default serializer used for persistence. Handles POJO and other stuff which requires write-able access to Engine


LZF

protected final ThreadLocal<CompressLZF> LZF

serializerPojoInitLock

protected Lock serializerPojoInitLock

structuralLock

protected final ReentrantLock structuralLock

newRecidLock

protected final ReentrantReadWriteLock newRecidLock

locks

protected final ReentrantReadWriteLock[] locks

recycledDataOuts

protected final Queue<DataOutput2> recycledDataOuts
Constructor Detail

Store

protected Store(boolean checksum,
                boolean compress,
                byte[] password,
                boolean disableLocks)
Method Detail

getMaxRecid

public abstract long getMaxRecid()

getRaw

public abstract ByteBuffer getRaw(long recid)

getFreeRecids

public abstract Iterator<Long> getFreeRecids()

updateRaw

public abstract void updateRaw(long recid,
                               ByteBuffer data)

getSizeLimit

public abstract long getSizeLimit()
returns maximal store size or `0` if there is no limit


getCurrSize

public abstract long getCurrSize()
returns current size occupied by physical store (does not include index). It means file allocated by physical file


getFreeSize

public abstract long getFreeSize()
returns free size in physical store (does not include index).


calculateStatistics

public abstract String calculateStatistics()
get some statistics about store. This may require traversing entire store, so it can take some time.


printStatistics

public void printStatistics()

getSerializerPojo

public SerializerPojo getSerializerPojo()
Description copied from interface: Engine
Returns default serializer associated with this engine. The default serializer will be moved from Engine into DB, so it is deprecated now and this method will be removed.

Specified by:
getSerializerPojo in interface Engine
Returns:
default serializer used in this DB, it handles POJO and other stuff.

lockAllWrite

protected void lockAllWrite()

unlockAllWrite

protected void unlockAllWrite()

serialize

protected <A> DataOutput2 serialize(A value,
                                    Serializer<A> serializer)

newDataOut2

protected DataOutput2 newDataOut2()

deserialize

protected <A> A deserialize(Serializer<A> serializer,
                            int size,
                            DataInput input)
                 throws IOException
Throws:
IOException

forDB

public static Store forDB(DB db)
traverses EngineWrappers and returns underlying Store


forEngine

public static Store forEngine(Engine e)
traverses EngineWrappers and returns underlying Store


expectedMasks

protected int expectedMasks()

lockPos

protected static int lockPos(long key)

canSnapshot

public boolean canSnapshot()
Specified by:
canSnapshot in interface Engine
Returns:
true if engine can create read-only snapshots

snapshot

public Engine snapshot()
                throws UnsupportedOperationException
Description copied from interface: Engine
Returns read-only snapshot of data in Engine.

Specified by:
snapshot in interface Engine
Throws:
UnsupportedOperationException - if snapshots are not supported/enabled
See Also:
EngineWrapper.canSnapshot()

closeListenerRegister

public void closeListenerRegister(Runnable closeListener)
Specified by:
closeListenerRegister in interface Engine

closeListenerUnregister

public void closeListenerUnregister(Runnable closeListener)
Specified by:
closeListenerUnregister in interface Engine


Copyright © 2014. All Rights Reserved.