Package com.gengoai.collection.disk
Class MapDBHandle
- java.lang.Object
-
- com.gengoai.collection.disk.MapDBHandle
-
- All Implemented Interfaces:
Serializable
,AutoCloseable
public final class MapDBHandle extends Object implements Serializable, AutoCloseable
Wraps and manages a MapDB DB store.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description MapDBHandle(@NonNull Resource resource, boolean compressed)
Instantiates a new MapDBHandle.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
void
commit()
Commits changes made to the databasevoid
delete()
Deletes the database files.org.mapdb.Atomic.Boolean
getBoolean(String name)
Gets the global boolean value with the given nameorg.mapdb.Atomic.Integer
getInteger(String name)
Gets global integer value with the given name.org.mapdb.Atomic.Long
getLong(String name)
Gets the global long value with the given name.protected org.mapdb.DB
getStore()
Gets the database store objectorg.mapdb.Atomic.String
getString(String name)
Gets the gloabl string value for the given name.<E> org.mapdb.Atomic.Var<E>
getVar(String name)
Gets the global value of the given variable name.boolean
isClosed()
Is closed.
-
-
-
Constructor Detail
-
MapDBHandle
public MapDBHandle(@NonNull @NonNull Resource resource, boolean compressed)
Instantiates a new MapDBHandle.- Parameters:
resource
- the file containing the MapDBcompressed
- True if compression is used
-
-
Method Detail
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
commit
public void commit()
Commits changes made to the database
-
delete
public void delete()
Deletes the database files.
-
getBoolean
public org.mapdb.Atomic.Boolean getBoolean(String name)
Gets the global boolean value with the given name- Parameters:
name
- the name- Returns:
- the boolean
-
getInteger
public org.mapdb.Atomic.Integer getInteger(String name)
Gets global integer value with the given name.- Parameters:
name
- the name- Returns:
- the integer
-
getLong
public org.mapdb.Atomic.Long getLong(String name)
Gets the global long value with the given name.- Parameters:
name
- the name- Returns:
- the long
-
getStore
protected org.mapdb.DB getStore()
Gets the database store object- Returns:
- the store
-
getString
public org.mapdb.Atomic.String getString(String name)
Gets the gloabl string value for the given name.- Parameters:
name
- the name- Returns:
- the string
-
getVar
public <E> org.mapdb.Atomic.Var<E> getVar(String name)
Gets the global value of the given variable name.- Type Parameters:
E
- the type parameter- Parameters:
name
- the name- Returns:
- the var
-
isClosed
public boolean isClosed()
Is closed.- Returns:
- True if closed, False if not
-
-