Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "An in-process property graph database management system built for
keywords = ["database", "graph", "ffi"]
readme = "lbug-src/README.md"
homepage = "https://ladybugdb.com/"
repository = "https://github.com/lbugdb/lbug"
repository = "https://github.com/LadybugDB/ladybug-rust"
license = "MIT"
categories = ["database"]

Expand Down
2 changes: 1 addition & 1 deletion include/lbug_rs.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ inline uint32_t logical_type_get_decimal_scale(const lbug::common::LogicalType&
std::unique_ptr<lbug::main::Database> new_database(std::string_view databasePath,
uint64_t bufferPoolSize, uint64_t maxNumThreads, bool enableCompression, bool readOnly,
uint64_t maxDBSize, bool autoCheckpoint, int64_t checkpointThreshold,
bool throwOnWalReplayFailure, bool enableChecksums);
bool throwOnWalReplayFailure, bool enableChecksums, bool enableMultiWrites);

void database_set_logging_level(lbug::main::Database& database, const std::string& level);

Expand Down
25 changes: 25 additions & 0 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub struct SystemConfig {
throw_on_wal_replay_failure: bool,
/// If true, the database will use checksums to detect corruption in the WAL file.
enable_checksums: bool,
/// If true, multiple concurrent write transactions are allowed.
/// Defaults to false
enable_multi_writes: bool,
}

#[cfg(test)]
Expand All @@ -58,6 +61,7 @@ pub(crate) const SYSTEM_CONFIG_FOR_TESTS: SystemConfig = SystemConfig {
checkpoint_threshold: -1_i64,
throw_on_wal_replay_failure: true,
enable_checksums: true,
enable_multi_writes: false,
};

impl Default for SystemConfig {
Expand All @@ -73,6 +77,7 @@ impl Default for SystemConfig {
checkpoint_threshold: -1_i64,
throw_on_wal_replay_failure: true,
enable_checksums: true,
enable_multi_writes: false,
}
}
}
Expand Down Expand Up @@ -114,6 +119,10 @@ impl SystemConfig {
self.enable_checksums = enable_checksums;
self
}
pub fn enable_multi_writes(mut self, enable_multi_writes: bool) -> Self {
self.enable_multi_writes = enable_multi_writes;
self
}
}

pub(crate) const IN_MEMORY_DB_NAME: &str = ":memory:";
Expand All @@ -138,6 +147,7 @@ impl Database {
config.checkpoint_threshold,
config.throw_on_wal_replay_failure,
config.enable_checksums,
config.enable_multi_writes,
)?),
})
}
Expand Down Expand Up @@ -343,4 +353,19 @@ mod tests {
assert!(results == HashSet::from(["Alice".to_string(), "Bob".to_string()]));
Ok(())
}

#[test]
fn test_database_enable_multi_writes() -> Result<()> {
let temp_dir = tempfile::tempdir()?;
let db = Database::new(
temp_dir.path().join("test"),
SYSTEM_CONFIG_FOR_TESTS.enable_multi_writes(true),
)?;
let conn1 = Connection::new(&db)?;
conn1.query("BEGIN TRANSACTION")?;
conn1.query("CREATE NODE TABLE t(a INT, b INT, PRIMARY KEY(a))")?;
let conn2 = Connection::new(&db)?;
conn2.query("BEGIN TRANSACTION")?;
Ok(())
}
}
1 change: 1 addition & 0 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ pub(crate) mod ffi {
checkpoint_threshold: i64,
throw_on_wal_replay_failure: bool,
enable_checksums: bool,
enableMultiWrites: bool,
) -> Result<UniquePtr<Database>>;

}
Expand Down
3 changes: 2 additions & 1 deletion src/lbug_rs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ std::unique_ptr<std::vector<lbug::common::LogicalType>> logical_type_get_struct_
std::unique_ptr<Database> new_database(std::string_view databasePath, uint64_t bufferPoolSize,
uint64_t maxNumThreads, bool enableCompression, bool readOnly, uint64_t maxDBSize,
bool autoCheckpoint, int64_t checkpointThreshold, bool throwOnWalReplayFailure,
bool enableChecksums) {
bool enableChecksums, bool enableMultiWrites) {
auto systemConfig = SystemConfig();
if (bufferPoolSize > 0) {
systemConfig.bufferPoolSize = bufferPoolSize;
Expand All @@ -87,6 +87,7 @@ std::unique_ptr<Database> new_database(std::string_view databasePath, uint64_t b
}
systemConfig.throwOnWalReplayFailure = throwOnWalReplayFailure;
systemConfig.enableChecksums = enableChecksums;
systemConfig.enableMultiWrites = enableMultiWrites;
return std::make_unique<Database>(databasePath, systemConfig);
}

Expand Down
Loading