Skip to content

Commit 30b8491

Browse files
committed
feat: expose enable_multi_writes in Python bindings + mvcc-bank pytest suite
1 parent 96e2b3b commit 30b8491

5 files changed

Lines changed: 348 additions & 5 deletions

File tree

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,9 @@ exclude = ["src_cpp*"]
132132

133133
[build-system]
134134
requires = ["setuptools", "wheel"]
135-
build-backend = "setuptools.build_meta"
135+
build-backend = "setuptools.build_meta"
136+
137+
[tool.pytest.ini_options]
138+
markers = [
139+
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
140+
]

src_cpp/include/py_database.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PyDatabase {
1919
explicit PyDatabase(const std::string& databasePath, uint64_t bufferPoolSize,
2020
uint64_t maxNumThreads, bool compression, bool readOnly, uint64_t maxDBSize,
2121
bool autoCheckpoint, int64_t checkpointThreshold, bool throwOnWalReplayFailure = true,
22-
bool enableChecksums = true);
22+
bool enableChecksums = true, bool enableMultiWrites = false);
2323

2424
~PyDatabase();
2525

src_cpp/py_database.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ using namespace lbug::common;
1212
void PyDatabase::initialize(py::handle& m) {
1313
py::class_<PyDatabase>(m, "Database")
1414
.def(py::init<const std::string&, uint64_t, uint64_t, bool, bool, uint64_t, bool, int64_t,
15-
bool, bool>(),
15+
bool, bool, bool>(),
1616
py::arg("database_path"), py::arg("buffer_pool_size") = 0,
1717
py::arg("max_num_threads") = 0, py::arg("compression") = true,
1818
py::arg("read_only") = false, py::arg("max_db_size") = (uint64_t)1 << 43,
1919
py::arg("auto_checkpoint") = true, py::arg("checkpoint_threshold") = -1,
20-
py::arg("throw_on_wal_replay_failure") = true, py::arg("enable_checksums") = true)
20+
py::arg("throw_on_wal_replay_failure") = true, py::arg("enable_checksums") = true,
21+
py::arg("enable_multi_writes") = false)
2122
.def("scan_node_table_as_int64", &PyDatabase::scanNodeTable<std::int64_t>,
2223
py::arg("table_name"), py::arg("prop_name"), py::arg("indices"), py::arg("np_array"),
2324
py::arg("num_threads"))
@@ -49,14 +50,15 @@ uint64_t PyDatabase::getStorageVersion() {
4950
PyDatabase::PyDatabase(const std::string& databasePath, uint64_t bufferPoolSize,
5051
uint64_t maxNumThreads, bool compression, bool readOnly, uint64_t maxDBSize,
5152
bool autoCheckpoint, int64_t checkpointThreshold, bool throwOnWalReplayFailure,
52-
bool enableChecksums) {
53+
bool enableChecksums, bool enableMultiWrites) {
5354
auto systemConfig = SystemConfig(bufferPoolSize, maxNumThreads, compression, readOnly,
5455
maxDBSize, autoCheckpoint);
5556
if (checkpointThreshold >= 0) {
5657
systemConfig.checkpointThreshold = static_cast<uint64_t>(checkpointThreshold);
5758
}
5859
systemConfig.throwOnWalReplayFailure = throwOnWalReplayFailure;
5960
systemConfig.enableChecksums = enableChecksums;
61+
systemConfig.enableMultiWrites = enableMultiWrites;
6062
database = std::make_unique<Database>(databasePath, systemConfig);
6163
lbug::extension::ExtensionUtils::addTableFunc<lbug::PandasScanFunction>(*database);
6264
storageDriver = std::make_unique<StorageDriver>(database.get());

src_py/database.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(
3939
checkpoint_threshold: int = -1,
4040
throw_on_wal_replay_failure: bool = True,
4141
enable_checksums: bool = True,
42+
enable_multi_writes: bool = False,
4243
):
4344
"""
4445
Parameters
@@ -94,6 +95,9 @@ def __init__(
9495
If true, the database will use checksums to detect corruption in the
9596
WAL file.
9697
98+
enable_multi_writes: bool
99+
If true, multiple concurrent write transactions are allowed. Default to False.
100+
97101
"""
98102
if database_path is None:
99103
database_path = ":memory:"
@@ -110,6 +114,7 @@ def __init__(
110114
self.checkpoint_threshold = checkpoint_threshold
111115
self.throw_on_wal_replay_failure = throw_on_wal_replay_failure
112116
self.enable_checksums = enable_checksums
117+
self.enable_multi_writes = enable_multi_writes
113118
self.is_closed = False
114119

115120
self._database: Any = None # (type: _lbug.Database from pybind11)
@@ -176,6 +181,7 @@ def init_database(self) -> None:
176181
self.checkpoint_threshold,
177182
self.throw_on_wal_replay_failure,
178183
self.enable_checksums,
184+
self.enable_multi_writes,
179185
)
180186

181187
def get_torch_geometric_remote_backend(

0 commit comments

Comments
 (0)