Package com.ladybugdb
Class Database
java.lang.Object
com.ladybugdb.Database
- All Implemented Interfaces:
AutoCloseable
The Database class is the main class of LbugDB. It manages all database
components.
-
Constructor Summary
ConstructorsConstructorDescriptionDatabase()Creates a database object.Creates a database object.Database(String databasePath, long bufferPoolSize, boolean enableCompression, boolean readOnly, long maxDBSize, boolean autoCheckpoint, long checkpointThreshold, boolean throwOnWalReplayFailure, boolean enableChecksums) Creates a database object. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the database and release the underlying resources.
-
Constructor Details
-
Database
public Database()Creates a database object. The database will be created in memory with default settings. -
Database
Creates a database object.- Parameters:
databasePath- : Database path. If the database does not already exist, it will be created.
-
Database
public Database(String databasePath, long bufferPoolSize, boolean enableCompression, boolean readOnly, long maxDBSize, boolean autoCheckpoint, long checkpointThreshold, boolean throwOnWalReplayFailure, boolean enableChecksums) Creates a database object.- Parameters:
databasePath- : Database path. If the path is empty, or equal to `:memory:`, the database will be created in memory.bufferPoolSize- : Max size of the buffer pool in bytes.enableCompression- : Enable compression in storage.readOnly- : Open the database in READ_ONLY mode.maxDBSize- : The maximum size of the database in bytes. Note that this is introduced temporarily for now to get around with the default 8TB mmap address space limit some environment.autoCheckpoint- If true, the database will automatically checkpoint when the size of the WAL file exceeds the checkpoint threshold.checkpointThreshold- The threshold of the WAL file size in bytes. When the size of the WAL file exceeds this threshold, the database will checkpoint if autoCheckpoint is true.throwOnWalReplayFailure- If true, any WAL replaying failure when loading the database will throw an error. Otherwise, Lbug will silently ignore the failure and replay up to where the error occured.enableChecksums- If true, the database will use checksums to detect corruption in the WAL file.
-
-
Method Details
-
close
public void close()Close the database and release the underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.- Specified by:
closein interfaceAutoCloseable- Throws:
RuntimeException- If the database instance has been destroyed.
-