public class DBMaker<DBMakerT extends DBMaker<DBMakerT>> extends Object
Modifier and Type | Class and Description |
---|---|
protected static interface |
DBMaker.Keys |
Modifier and Type | Field and Description |
---|---|
protected Properties |
props |
protected String |
TRUE |
Modifier | Constructor and Description |
---|---|
protected |
DBMaker()
use static factory methods, or make subclass
|
protected |
DBMaker(File file) |
Modifier and Type | Method and Description |
---|---|
protected DBMakerT |
_newAppendFileDB(File file) |
DBMakerT |
_newFileDB(File file) |
DBMakerT |
_newHeapDB() |
DBMakerT |
_newMemoryDB() |
DBMakerT |
_newMemoryDirectDB() |
DBMakerT |
asyncWriteEnable()
Enables mode where all modifications are queued and written into disk on Background Writer Thread.
|
DBMakerT |
asyncWriteFlushDelay(int delay)
Set flush interval for write cache, by default is 0
When BTreeMap is constructed from ordered set, tree node size is increasing linearly with each
item added.
|
DBMakerT |
asyncWriteQueueSize(int queueSize)
Set size of async Write Queue.
|
DBMakerT |
cacheDisable()
Instance cache is enabled by default.
|
DBMakerT |
cacheHardRefEnable()
Enables unbounded hard reference cache.
|
DBMakerT |
cacheLRUEnable()
Enables Least Recently Used cache.
|
DBMakerT |
cacheSize(int cacheSize)
Set cache size.
|
DBMakerT |
cacheSoftRefEnable()
Enables unbounded cache which uses
SoftReference . |
DBMakerT |
cacheWeakRefEnable()
Enables unbounded cache which uses
WeakReference . |
DBMakerT |
checksumEnable()
Adds CRC32 checksum at end of each record to check data integrity.
|
DBMakerT |
closeOnJvmShutdown()
Adds JVM shutdown hook and closes DB just before JVM;
|
DBMakerT |
commitFileSyncDisable()
Disables file sync on commit.
|
DBMakerT |
compressionEnable()
Enables record compression.
|
DBMakerT |
deleteFilesAfterClose()
Try to delete files after DB is closed.
|
DBMakerT |
encryptionEnable(byte[] password)
Encrypt storage using XTEA algorithm.
|
DBMakerT |
encryptionEnable(String password)
Encrypt storage using XTEA algorithm.
|
protected void |
extendArgumentCheck() |
protected Engine |
extendAsyncWriteEngine(Engine engine) |
protected Engine |
extendCacheHardRef(Engine engine) |
protected Engine |
extendCacheHashTable(Engine engine) |
protected Engine |
extendCacheLRU(Engine engine) |
protected Engine |
extendCacheSoftRef(Engine engine) |
protected Engine |
extendCacheWeakRef(Engine engine) |
protected Engine |
extendHeapStore() |
protected Engine |
extendSnapshotEngine(Engine engine) |
protected Engine |
extendStoreAppend() |
protected Engine |
extendStoreDirect(Volume.Factory folFac) |
protected Volume.Factory |
extendStoreVolumeFactory() |
protected Engine |
extendStoreWAL(Volume.Factory folFac) |
protected Engine |
extendWrapCache(Engine engine) |
protected Engine |
extendWrapSnapshotEngine(Engine engine) |
protected Engine |
extendWrapStore(Engine engine) |
DBMakerT |
freeSpaceReclaimQ(int q)
Set free space reclaim Q.
|
protected static byte[] |
fromHexa(String s) |
protected DBMakerT |
getThis() |
protected static boolean |
JVMSupportsLargeMappedFiles()
Check if large files can be mapped into memory.
|
DB |
make()
constructs DB using current settings
|
Engine |
makeEngine()
constructs Engine using current settings
|
TxMaker |
makeTxMaker() |
DBMakerT |
mmapFileEnable()
Enables Memory Mapped Files, much faster storage option.
|
DBMakerT |
mmapFileEnableIfSupported()
Enable Memory Mapped Files only if current JVM supports it (is 64bit).
|
DBMakerT |
mmapFileEnablePartial()
Keeps small-frequently-used part of storage files memory mapped, but main area is accessed using Random Access File.
|
protected static DBMaker |
newAppendFileDB(File file)
Creates or open append-only database stored in file.
|
static <K,V> HTreeMap<K,V> |
newCache(double size)
Creates new cache with maximal size in GBs.
|
static <K,V> HTreeMap<K,V> |
newCacheDirect(double size)
Creates new off-heap cache with maximal size in GBs.
|
static DBMaker |
newFileDB(File file)
Creates or open database stored in file.
|
static DBMaker |
newHeapDB()
Creates new in-memory database which stores all data on heap without serialization.
|
static DBMaker |
newMemoryDB()
Creates new in-memory database.
|
static DBMaker |
newMemoryDirectDB()
Creates new in-memory database.
|
static DBMaker |
newTempFileDB()
Creates new database in temporary folder.
|
static <K,V> HTreeMap<K,V> |
newTempHashMap()
Create new HTreeMap backed by temporary file storage.
|
static <K> Set<K> |
newTempHashSet()
Create new HashSet backed by temporary file storage.
|
static <K,V> BTreeMap<K,V> |
newTempTreeMap()
Create new BTreeMap backed by temporary file storage.
|
static <K> NavigableSet<K> |
newTempTreeSet()
Create new TreeSet backed by temporary file storage.
|
protected boolean |
propsGetBool(String key) |
protected int |
propsGetInt(String key,
int defValue) |
protected long |
propsGetLong(String key,
long defValue) |
protected int |
propsGetRafMode() |
protected byte[] |
propsGetXteaEncKey() |
DBMakerT |
readOnly()
Open store in read-only mode.
|
DBMakerT |
sizeLimit(double maxSize)
Sets store size limit.
|
DBMakerT |
snapshotEnable()
MapDB supports snapshots.
|
DBMakerT |
strictDBGet()
DB Get methods such as
DB.getTreeMap(String) or DB.getAtomicLong(String) auto create
new record with default values, if record with given name does not exist. |
protected static String |
toHexa(byte[] bb) |
DBMakerT |
transactionDisable()
Transaction journal is enabled by default
You must call DB.commit() to save your changes.
|
protected final String TRUE
protected Properties props
protected DBMaker()
protected DBMaker(File file)
public static DBMaker newHeapDB()
public DBMakerT _newHeapDB()
public static DBMaker newMemoryDB()
public DBMakerT _newMemoryDB()
public static DBMaker newMemoryDirectDB()
public DBMakerT _newMemoryDirectDB()
protected static DBMaker newAppendFileDB(File file)
file
- public static <K,V> BTreeMap<K,V> newTempTreeMap()
Storage is created in temp folder and deleted on JVM shutdown
public static <K,V> HTreeMap<K,V> newTempHashMap()
Storage is created in temp folder and deleted on JVM shutdown
public static <K> NavigableSet<K> newTempTreeSet()
Storage is created in temp folder and deleted on JVM shutdown
public static <K> Set<K> newTempHashSet()
Storage is created in temp folder and deleted on JVM shutdown
public static DBMaker newTempFileDB()
public static <K,V> HTreeMap<K,V> newCacheDirect(double size)
ByteBuffer.allocateDirect(int)
size
- maximal size of off-heap store in gigabytes.public static <K,V> HTreeMap<K,V> newCache(double size)
ByteBuffer.allocate(int)
size
- maximal size of off-heap store in gigabytes.protected DBMakerT getThis()
public DBMakerT transactionDisable()
public DBMakerT cacheDisable()
public DBMakerT cacheHardRefEnable()
public DBMakerT cacheWeakRefEnable()
WeakReference
.
Items are removed from cache by Garbage Collectorpublic DBMakerT cacheSoftRefEnable()
SoftReference
.
Items are removed from cache by Garbage Collectorpublic DBMakerT cacheLRUEnable()
public DBMakerT mmapFileEnable()
public DBMakerT mmapFileEnablePartial()
public DBMakerT mmapFileEnableIfSupported()
public DBMakerT cacheSize(int cacheSize)
cacheSize
- new cache sizepublic DBMakerT snapshotEnable()
public DBMakerT asyncWriteEnable()
public DBMakerT asyncWriteFlushDelay(int delay)
delay
- flush write cache every N milisecondspublic DBMakerT asyncWriteQueueSize(int queueSize)
queueSize
- of queuepublic DBMakerT deleteFilesAfterClose()
public DBMakerT closeOnJvmShutdown()
public DBMakerT compressionEnable()
public DBMakerT encryptionEnable(String password)
password
- for encryptionpublic DBMakerT encryptionEnable(byte[] password)
password
- for encryptionpublic DBMakerT checksumEnable()
public DBMakerT strictDBGet()
DB.getTreeMap(String)
or DB.getAtomicLong(String)
auto create
new record with default values, if record with given name does not exist. This could be problem if you would like to enforce
stricter database schema. So this parameter disables record auto creation.
If this set, `DB.getXX()` will throw an exception if given name does not exist, instead of creating new record (or collection)public DBMakerT readOnly()
UnsupportedOperationException("Read-only")
public DBMakerT freeSpaceReclaimQ(int q)
public DBMakerT commitFileSyncDisable()
public DBMakerT sizeLimit(double maxSize)
maxSize
- maximal store size in GBpublic DB make()
public TxMaker makeTxMaker()
public Engine makeEngine()
protected int propsGetInt(String key, int defValue)
protected long propsGetLong(String key, long defValue)
protected boolean propsGetBool(String key)
protected byte[] propsGetXteaEncKey()
protected static boolean JVMSupportsLargeMappedFiles()
protected int propsGetRafMode()
protected void extendArgumentCheck()
protected Engine extendHeapStore()
protected Engine extendStoreAppend()
protected Engine extendStoreDirect(Volume.Factory folFac)
protected Engine extendStoreWAL(Volume.Factory folFac)
protected Volume.Factory extendStoreVolumeFactory()
protected static String toHexa(byte[] bb)
protected static byte[] fromHexa(String s)
Copyright © 2019. All rights reserved.