public final class DBMaker extends Object
A builder class to creare and open new database and individual collections.
It has several static factory methods.
Method names depends on type of storage it opens.
DBMaker
is typically used this way
DB db = DBMaker .memoryDB() //static method .transactionDisable() //configuration option .make() //opens db
Modifier and Type | Class and Description |
---|---|
protected static interface |
DBMaker.Keys |
static class |
DBMaker.Maker |
Modifier and Type | Field and Description |
---|---|
protected static Logger |
LOG |
protected static String |
TRUE |
Constructor and Description |
---|
DBMaker() |
Modifier and Type | Method and Description |
---|---|
static DBMaker.Maker |
appendFileDB(File file)
Creates or open append-only database stored in file.
|
static DBMaker.Maker |
archiveFileDB(File file) |
static Map<String,Object> |
CC()
Returns Compiler Config, static settings MapDB was compiled with
|
static DBMaker.Maker |
fileDB(File file)
Creates or open database stored in file.
|
static DB.HTreeMapMaker |
hashMapSegmented(DBMaker.Maker maker) |
static DB.HTreeMapMaker |
hashMapSegmentedMemory() |
static DB.HTreeMapMaker |
hashMapSegmentedMemoryDirect() |
static DBMaker.Maker |
heapDB()
Creates new in-memory database which stores all data on heap without serialization.
|
static DBMaker.Maker |
memoryDB()
Creates new in-memory database.
|
static DBMaker.Maker |
memoryDirectDB()
Creates new in-memory database.
|
static DBMaker.Maker |
memoryUnsafeDB()
Creates new in-memory database.
|
static DBMaker.Maker |
newAppendFileDB(File file)
Deprecated.
method renamed, prefix removed, use
appendFileDB(File) |
static <K,V> HTreeMap<K,V> |
newCache(double size)
Deprecated.
TODO this method is going to be replaced by something
|
static <K,V> HTreeMap<K,V> |
newCacheDirect(double size)
Deprecated.
TODO this method is going to be replaced by something
|
static DBMaker.Maker |
newFileDB(File file)
Deprecated.
method renamed, prefix removed, use
fileDB(File) |
static DBMaker.Maker |
newHeapDB()
Deprecated.
method renamed, prefix removed, use
heapDB() |
static DBMaker.Maker |
newMemoryDB()
Deprecated.
method renamed, prefix removed, use
memoryDB() |
static DBMaker.Maker |
newMemoryDirectDB()
Deprecated.
method renamed, prefix removed, use
memoryDirectDB() |
static DBMaker.Maker |
newMemoryUnsafeDB()
Deprecated.
method renamed, prefix removed, use
memoryUnsafeDB() |
static DBMaker.Maker |
newTempFileDB()
Deprecated.
method renamed, prefix removed, use
tempFileDB() |
static <K,V> HTreeMap<K,V> |
newTempHashMap()
Deprecated.
method renamed, prefix removed, use
tempHashMap() |
static <K> Set<K> |
newTempHashSet()
Deprecated.
method renamed, prefix removed, use
tempHashSet() |
static <K,V> BTreeMap<K,V> |
newTempTreeMap()
Deprecated.
method renamed, prefix removed, use
tempTreeMap() |
static <K> NavigableSet<K> |
newTempTreeSet()
Deprecated.
method renamed, prefix removed, use
tempTreeSet() |
static DBMaker.Maker |
tempFileDB()
Creates new database in temporary folder.
|
static <K,V> HTreeMap<K,V> |
tempHashMap()
Create new HTreeMap backed by temporary file storage.
|
static <K> Set<K> |
tempHashSet()
Create new HashSet backed by temporary file storage.
|
static <K,V> BTreeMap<K,V> |
tempTreeMap()
Create new BTreeMap backed by temporary file storage.
|
static <K> NavigableSet<K> |
tempTreeSet()
Create new TreeSet backed by temporary file storage.
|
protected static final Logger LOG
protected static final String TRUE
public static DBMaker.Maker heapDB()
public static DBMaker.Maker newHeapDB()
heapDB()
public static DBMaker.Maker memoryDB()
byte[]
,
so they are not affected by Garbage Collector.public static DBMaker.Maker newMemoryDB()
memoryDB()
public static DBMaker.Maker memoryDirectDB()
Creates new in-memory database. Changes are lost after JVM exits.
This will use DirectByteBuffer
outside of HEAP, so Garbage Collector is not affected
You should increase ammount of direct memory with
-XX:MaxDirectMemorySize=10G
JVM param
public static DBMaker.Maker newMemoryDirectDB()
memoryDirectDB()
public static DBMaker.Maker memoryUnsafeDB()
Creates new in-memory database. Changes are lost after JVM exits.
This will use sun.misc.Unsafe
. It uses direct-memory access and avoids boundary checking.
It is bit faster compared to DirectByteBuffer
, but can cause JVM crash in case of error.
If sun.misc.Unsafe
is not available for some reason, MapDB will log an warning and fallback into
DirectByteBuffer
based in-memory store without throwing an exception.
public static DBMaker.Maker newMemoryUnsafeDB()
memoryUnsafeDB()
public static DBMaker.Maker appendFileDB(File file)
file
- public static DBMaker.Maker archiveFileDB(File file)
public static DBMaker.Maker newAppendFileDB(File file)
appendFileDB(File)
public static <K,V> BTreeMap<K,V> tempTreeMap()
Create new BTreeMap backed by temporary file storage. This is quick way to create 'throw away' collection.
Storage is created in temp folder and deleted on JVM shutdown
public static <K,V> BTreeMap<K,V> newTempTreeMap()
tempTreeMap()
public static <K,V> HTreeMap<K,V> tempHashMap()
Create new HTreeMap backed by temporary file storage. This is quick way to create 'throw away' collection.
Storage is created in temp folder and deleted on JVM shutdown
public static <K,V> HTreeMap<K,V> newTempHashMap()
tempHashMap()
public static <K> NavigableSet<K> tempTreeSet()
Create new TreeSet backed by temporary file storage. This is quick way to create 'throw away' collection.
Storage is created in temp folder and deleted on JVM shutdown
public static <K> NavigableSet<K> newTempTreeSet()
tempTreeSet()
public static <K> Set<K> tempHashSet()
Create new HashSet backed by temporary file storage. This is quick way to create 'throw away' collection.
Storage is created in temp folder and deleted on JVM shutdown
public static <K> Set<K> newTempHashSet()
tempHashSet()
public static DBMaker.Maker tempFileDB()
public static DBMaker.Maker newTempFileDB()
tempFileDB()
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)
byte[]
, but does not affect GC since objects are serialized into binary form.
This method uses ByteBuffers backed by on-heap byte[]. See ByteBuffer.allocate(int)
size
- maximal size of off-heap store in gigabytes.public static DBMaker.Maker fileDB(File file)
public static DBMaker.Maker newFileDB(File file)
fileDB(File)
public static DB.HTreeMapMaker hashMapSegmented(DBMaker.Maker maker)
public static DB.HTreeMapMaker hashMapSegmentedMemory()
public static DB.HTreeMapMaker hashMapSegmentedMemoryDirect()
public static Map<String,Object> CC() throws IllegalAccessException
IllegalAccessException
Copyright © 2015. All Rights Reserved.