public class DB extends Object
Modifier and Type | Class and Description |
---|---|
class |
DB.BTreeMapMaker |
class |
DB.BTreeSetMaker |
class |
DB.HTreeMapMaker |
class |
DB.HTreeSetMaker |
protected static class |
DB.IdentityWrapper |
Modifier and Type | Field and Description |
---|---|
protected SortedMap<String,Object> |
catalog
view over named records
|
protected Engine |
engine
Engine which provides persistence for this DB
|
protected Map<String,WeakReference<?>> |
namesInstanciated
already loaded named collections.
|
protected Map<DB.IdentityWrapper,String> |
namesLookup |
protected boolean |
strictDBGet |
Constructor and Description |
---|
DB(Engine engine)
Construct new DB.
|
DB(Engine engine,
boolean strictDBGet,
boolean disableLocks) |
Modifier and Type | Method and Description |
---|---|
<A> A |
catGet(String name) |
<A> A |
catGet(String name,
A init) |
<A> A |
catPut(String name,
A value) |
<A> A |
catPut(String name,
A value,
A retValueIfNull) |
void |
checkNameNotExists(String name)
Checks that object with given name does not exist yet.
|
void |
checkNotClosed() |
void |
checkShouldCreate(String name) |
void |
checkType(String type,
String expected) |
void |
close()
Closes database.
|
void |
commit()
Commit changes made on collections loaded by this DB
|
void |
compact()
Perform storage maintenance.
|
Atomic.Boolean |
createAtomicBoolean(String name,
boolean initValue) |
Atomic.Integer |
createAtomicInteger(String name,
int initValue) |
Atomic.Long |
createAtomicLong(String name,
long initValue) |
Atomic.String |
createAtomicString(String name,
String initValue) |
<E> Atomic.Var<E> |
createAtomicVar(String name,
E initValue,
Serializer<E> serializer) |
<E> BlockingQueue<E> |
createCircularQueue(String name,
Serializer<E> serializer,
long size) |
protected <K,V> HTreeMap<K,V> |
createHashMap(DB.HTreeMapMaker m)
Creates new HashMap with more specific arguments
|
DB.HTreeMapMaker |
createHashMap(String name)
Returns new builder for HashMap with given name
|
protected <K> Set<K> |
createHashSet(DB.HTreeSetMaker m) |
DB.HTreeSetMaker |
createHashSet(String name)
Creates new HashSet
|
<E> BlockingQueue<E> |
createQueue(String name,
Serializer<E> serializer,
boolean useLocks) |
<E> BlockingQueue<E> |
createStack(String name,
Serializer<E> serializer,
boolean useLocks) |
protected <K,V> BTreeMap<K,V> |
createTreeMap(DB.BTreeMapMaker m) |
DB.BTreeMapMaker |
createTreeMap(String name)
Returns new builder for TreeMap with given name
|
<K> NavigableSet<K> |
createTreeSet(DB.BTreeSetMaker m) |
DB.BTreeSetMaker |
createTreeSet(String name)
Creates new TreeSet.
|
void |
delete(String name)
delete record/collection with given name
|
boolean |
exists(String name) |
protected <K> BTreeKeySerializer<K> |
fillNulls(BTreeKeySerializer<K> keySerializer)
Replace nulls in tuple serializers with default (Comparable) values
|
<E> E |
get(String name)
return record with given name or null if name does not exist
|
Map<String,Object> |
getAll()
return map of all named collections/records
|
Atomic.Boolean |
getAtomicBoolean(String name) |
Atomic.Integer |
getAtomicInteger(String name) |
Atomic.Long |
getAtomicLong(String name) |
Atomic.String |
getAtomicString(String name) |
<E> Atomic.Var<E> |
getAtomicVar(String name) |
SortedMap<String,Object> |
getCatalog()
Get Name Catalog.
|
<E> BlockingQueue<E> |
getCircularQueue(String name) |
Serializer |
getDefaultSerializer() |
Engine |
getEngine() |
Object |
getFromWeakCollection(String name)
All collections are weakly referenced to prevent two instances of the same collection in memory.
|
<K,V> HTreeMap<K,V> |
getHashMap(String name)
Opens existing or creates new Hash Tree Map.
|
<K,V> HTreeMap<K,V> |
getHashMap(String name,
Fun.Function1<V,K> valueCreator)
Opens existing or creates new Hash Tree Map.
|
<K> Set<K> |
getHashSet(String name)
Opens existing or creates new Hash Tree Set.
|
String |
getNameForObject(Object obj)
returns name for this object, if it has name and was instanciated by this DB
|
<E> BlockingQueue<E> |
getQueue(String name) |
<E> BlockingQueue<E> |
getStack(String name) |
<K,V> BTreeMap<K,V> |
getTreeMap(String name)
Opens existing or creates new B-linked-tree Map.
|
<K> NavigableSet<K> |
getTreeSet(String name)
Opens existing or creates new B-linked-tree Set.
|
boolean |
isClosed() |
<V> V |
namedPut(String name,
Object ret) |
protected void |
reinit() |
void |
rename(String oldName,
String newName)
rename named record into newName
|
void |
rollback()
Rollback changes made on collections loaded by this DB
|
DB |
snapshot()
Make readonly snapshot view of DB and all of its collection
Collections loaded by this instance are not affected (are still mutable).
|
protected final boolean strictDBGet
protected Engine engine
protected Map<String,WeakReference<?>> namesInstanciated
protected Map<DB.IdentityWrapper,String> namesLookup
public DB(Engine engine)
Engine
which does the real work.engine
- public DB(Engine engine, boolean strictDBGet, boolean disableLocks)
protected void reinit()
public <A> A catGet(String name, A init)
public <A> A catGet(String name)
public <A> A catPut(String name, A value)
public <A> A catPut(String name, A value, A retValueIfNull)
public String getNameForObject(Object obj)
public <K,V> HTreeMap<K,V> getHashMap(String name)
name
- of the mappublic <K,V> HTreeMap<K,V> getHashMap(String name, Fun.Function1<V,K> valueCreator)
name
- of mapvalueCreator
- if value is not found, new is created and placed into map.public DB.HTreeMapMaker createHashMap(String name)
name
- of map to createIllegalArgumentException
- if name is already usedprotected <K,V> HTreeMap<K,V> createHashMap(DB.HTreeMapMaker m)
IllegalArgumentException
- if name is already usedpublic <K> Set<K> getHashSet(String name)
name
- of the Setpublic DB.HTreeSetMaker createHashSet(String name)
name
- of set to createprotected <K> Set<K> createHashSet(DB.HTreeSetMaker m)
public <K,V> BTreeMap<K,V> getTreeMap(String name)
name
- of mappublic DB.BTreeMapMaker createTreeMap(String name)
name
- of map to createIllegalArgumentException
- if name is already usedprotected <K,V> BTreeMap<K,V> createTreeMap(DB.BTreeMapMaker m)
protected <K> BTreeKeySerializer<K> fillNulls(BTreeKeySerializer<K> keySerializer)
keySerializer
- with nullspublic SortedMap<String,Object> getCatalog()
public <K> NavigableSet<K> getTreeSet(String name)
name
- of setpublic DB.BTreeSetMaker createTreeSet(String name)
name
- of set to createIllegalArgumentException
- if name is already usedpublic <K> NavigableSet<K> createTreeSet(DB.BTreeSetMaker m)
public <E> BlockingQueue<E> getQueue(String name)
public <E> BlockingQueue<E> createQueue(String name, Serializer<E> serializer, boolean useLocks)
public <E> BlockingQueue<E> getStack(String name)
public <E> BlockingQueue<E> createStack(String name, Serializer<E> serializer, boolean useLocks)
public <E> BlockingQueue<E> getCircularQueue(String name)
public <E> BlockingQueue<E> createCircularQueue(String name, Serializer<E> serializer, long size)
public Atomic.Long createAtomicLong(String name, long initValue)
public Atomic.Long getAtomicLong(String name)
public Atomic.Integer createAtomicInteger(String name, int initValue)
public Atomic.Integer getAtomicInteger(String name)
public Atomic.Boolean createAtomicBoolean(String name, boolean initValue)
public Atomic.Boolean getAtomicBoolean(String name)
public void checkShouldCreate(String name)
public Atomic.String createAtomicString(String name, String initValue)
public Atomic.String getAtomicString(String name)
public <E> Atomic.Var<E> createAtomicVar(String name, E initValue, Serializer<E> serializer)
public <E> Atomic.Var<E> getAtomicVar(String name)
public <E> E get(String name)
public boolean exists(String name)
public void delete(String name)
public void rename(String oldName, String newName)
oldName
- current name of record/collectionnewName
- new name of record/collectionNoSuchElementException
- if oldName does not existpublic void checkNameNotExists(String name)
name
- to checkIllegalArgumentException
- if name is already usedpublic void close()
public Object getFromWeakCollection(String name)
public void checkNotClosed()
public boolean isClosed()
public void commit()
Engine.commit()
public void rollback()
Engine.rollback()
public void compact()
public DB snapshot()
public Serializer getDefaultSerializer()
public Engine getEngine()
Copyright © 2017. All rights reserved.