Allows to use Speedb instead of RocksDB

speedb
Tpt 2 years ago
parent 6af6c9c0eb
commit ca91570f50
  1. 35
      .github/workflows/tests.yml
  2. 3
      .gitmodules
  3. 1
      lib/Cargo.toml
  4. 3
      oxrocksdb-sys/Cargo.toml
  5. 2
      oxrocksdb-sys/README.md
  6. 24
      oxrocksdb-sys/api/build_version.cc
  7. 4
      oxrocksdb-sys/api/c.cc
  8. 4
      oxrocksdb-sys/api/c.h
  9. 45
      oxrocksdb-sys/build.rs
  10. 1
      oxrocksdb-sys/speedb
  11. 2
      oxrocksdb-sys/trim_rocksdb.sh
  12. 3
      server/Cargo.toml
  13. 5
      server/src/main.rs

@ -128,7 +128,20 @@ jobs:
submodules: true submodules: true
- run: rustup update - run: rustup update
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: cargo test --all-features - run: cargo test
env:
RUST_BACKTRACE: 1
test_linux_speedb:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- run: cargo test --features speedb
working-directory: ./lib
env: env:
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
@ -155,7 +168,21 @@ jobs:
- run: rustup update - run: rustup update
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse - run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse
- run: cargo test --all-features - run: cargo test
env:
RUST_BACKTRACE: 1
test_windows_speedb:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- run: Remove-Item -LiteralPath "C:\msys64\" -Force -Recurse
- run: cargo test --features speedb
working-directory: ./lib
env: env:
RUST_BACKTRACE: 1 RUST_BACKTRACE: 1
@ -181,7 +208,7 @@ jobs:
submodules: true submodules: true
- run: rustup update - run: rustup update
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: cargo doc --all-features - run: cargo doc
working-directory: ./lib working-directory: ./lib
rustdoc_msrv: rustdoc_msrv:
@ -192,7 +219,7 @@ jobs:
submodules: true submodules: true
- run: rustup update && rustup override set 1.60.0 - run: rustup update && rustup override set 1.60.0
- uses: Swatinem/rust-cache@v2 - uses: Swatinem/rust-cache@v2
- run: cargo doc --all-features - run: cargo doc
working-directory: ./lib working-directory: ./lib
env: env:
RUSTDOCFLAGS: -D warnings RUSTDOCFLAGS: -D warnings

3
.gitmodules vendored

@ -13,3 +13,6 @@
[submodule "oxrocksdb-sys/lz4"] [submodule "oxrocksdb-sys/lz4"]
path = oxrocksdb-sys/lz4 path = oxrocksdb-sys/lz4
url = https://github.com/lz4/lz4.git url = https://github.com/lz4/lz4.git
[submodule "oxrocksdb-sys/speedb"]
path = oxrocksdb-sys/speedb
url = https://github.com/oxigraph/speedb.git

@ -20,6 +20,7 @@ all-features = true
[features] [features]
default = [] default = []
http_client = ["oxhttp", "oxhttp/rustls"] http_client = ["oxhttp", "oxhttp/rustls"]
speedb = ["oxrocksdb-sys/speedb"]
[dependencies] [dependencies]
rand = "0.8" rand = "0.8"

@ -13,6 +13,9 @@ rust-version = "1.60"
build = "build.rs" build = "build.rs"
links = "rocksdb" links = "rocksdb"
[features]
speedb = []
[dependencies] [dependencies]
libc = "0.2" libc = "0.2"

@ -3,4 +3,6 @@ Oxigraph RocksDB bindings
[RocksDB](http://rocksdb.org/) bindings for [Oxigraph](https://oxigraph.org). [RocksDB](http://rocksdb.org/) bindings for [Oxigraph](https://oxigraph.org).
It is also possible to switch to [Speedb](https://www.speedb.dev/) by enabling the `"seedb"` Cargo feature.
Based on [librocksdb-sys](https://crates.io/crates/librocksdb-sys) under Apache v2 license. Based on [librocksdb-sys](https://crates.io/crates/librocksdb-sys) under Apache v2 license.

@ -4,6 +4,9 @@
#include "rocksdb/utilities/object_registry.h" #include "rocksdb/utilities/object_registry.h"
#include "rocksdb/version.h" #include "rocksdb/version.h"
#ifdef SPEEDB
#include "speedb/version.h"
#endif
namespace ROCKSDB_NAMESPACE { namespace ROCKSDB_NAMESPACE {
std::unordered_map<std::string, RegistrarFunc> ObjectRegistry::builtins_ = {}; std::unordered_map<std::string, RegistrarFunc> ObjectRegistry::builtins_ = {};
@ -24,9 +27,24 @@ std::string GetRocksVersionAsString(bool with_patch) {
} }
} }
#ifdef SPEEDB
std::string GetSpeedbVersionAsString(bool with_patch) {
std::string version =
std::to_string(SPEEDB_MAJOR) + "." + std::to_string(SPEEDB_MINOR);
if (with_patch) {
version += "." + std::to_string(SPEEDB_PATCH);
}
return version;
}
#endif
std::string GetRocksBuildInfoAsString(const std::string& program, std::string GetRocksBuildInfoAsString(const std::string& program,
bool verbose) { bool verbose) {
std::string info = program + " (RocksDB) " + GetRocksVersionAsString(true); std::string info = program;
#ifdef SPEEDB
info += " (Speedb " + GetSpeedbVersionAsString(true) + " )";
#endif
info += " (RocksDB " + GetRocksVersionAsString(true) + " )";
if (verbose) { if (verbose) {
for (const auto& it : GetRocksBuildProperties()) { for (const auto& it : GetRocksBuildProperties()) {
info.append("\n "); info.append("\n ");
@ -37,4 +55,8 @@ std::string GetRocksBuildInfoAsString(const std::string& program,
} }
return info; return info;
} }
#ifdef SPEEDB
std::string GetRocksDebugPropertiesAsString() { return ""; }
#endif
} // namespace ROCKSDB_NAMESPACE } // namespace ROCKSDB_NAMESPACE

@ -1,4 +1,8 @@
#ifdef SPEEDB
#include "../speedb/db/c.cc"
#else
#include "../rocksdb/db/c.cc" #include "../rocksdb/db/c.cc"
#endif
#include "c.h" #include "c.h"

@ -1,6 +1,10 @@
#pragma once #pragma once
#ifdef SPEEDB
#include "../speedb/include/rocksdb/c.h"
#else
#include "../rocksdb/include/rocksdb/c.h" #include "../rocksdb/include/rocksdb/c.h"
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

@ -32,29 +32,42 @@ fn bindgen_rocksdb() {
fn build_rocksdb() { fn build_rocksdb() {
let target = var("TARGET").unwrap(); let target = var("TARGET").unwrap();
let speedb = cfg!(feature = "speedb");
let mut config = cc::Build::new(); let mut config = cc::Build::new();
config config
.cpp(true) .cpp(true)
.include("rocksdb/include/") .include(if speedb {
.include("rocksdb/") "speedb/include/"
} else {
"rocksdb/include/"
})
.include(if speedb { "speedb/" } else { "rocksdb/" })
.file("api/c.cc") .file("api/c.cc")
.file("api/build_version.cc") .file("api/build_version.cc")
.define("NDEBUG", Some("1")) .define("NDEBUG", Some("1"))
.define("LZ4", Some("1")) .define("LZ4", Some("1"))
.include("lz4/lib/"); .include("lz4/lib/");
let mut lib_sources = include_str!("rocksdb/src.mk") let mut lib_sources = if speedb {
.split_once("LIB_SOURCES =") include_str!("speedb/src.mk")
.unwrap() } else {
.1 include_str!("rocksdb/src.mk")
.split_once("ifeq") }
.unwrap() .split_once("LIB_SOURCES =")
.0 .unwrap()
.split('\\') .1
.map(str::trim) .split_once("ifeq")
.filter(|p| !p.is_empty()) .unwrap()
.collect::<Vec<_>>(); .0
.split('\\')
.map(str::trim)
.filter(|p| !p.is_empty())
.collect::<Vec<_>>();
if speedb {
config.define("SPEEDB", None);
}
if target.contains("x86_64") { if target.contains("x86_64") {
// This is needed to enable hardware CRC32C. Technically, SSE 4.2 is // This is needed to enable hardware CRC32C. Technically, SSE 4.2 is
@ -177,7 +190,11 @@ fn build_rocksdb() {
if file == "db/c.cc" || file == "util/build_version.cc" { if file == "db/c.cc" || file == "util/build_version.cc" {
continue; continue;
} }
config.file(&format!("rocksdb/{file}")); config.file(&if speedb {
format!("speedb/{file}")
} else {
format!("rocksdb/{file}")
});
} }
config.compile("rocksdb"); config.compile("rocksdb");
} }

@ -0,0 +1 @@
Subproject commit 288398bf74c5c8d708a2f1823cf5db38975dabc8

@ -2,3 +2,5 @@
cd "$(dirname "$0")"/rocksdb || return cd "$(dirname "$0")"/rocksdb || return
rm -rf java .circleci .github build_tools coverage db_stress_tool docs examples fuzz java microbench ./**/*_test.cc rm -rf java .circleci .github build_tools coverage db_stress_tool docs examples fuzz java microbench ./**/*_test.cc
cd "$(dirname "$0")"/speedb || return
rm -rf java .circleci .github build_tools coverage db_stress_tool docs examples fuzz java microbench ./**/*_test.cc

@ -12,6 +12,9 @@ Oxigraph SPARQL HTTP server
edition = "2021" edition = "2021"
rust-version = "1.60" rust-version = "1.60"
[features]
speedb = ["oxigraph/speedb"]
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"
oxhttp = { version = "0.1", features = ["rayon"] } oxhttp = { version = "0.1", features = ["rayon"] }

@ -1604,6 +1604,11 @@ mod tests {
escargot::CargoBuild::new() escargot::CargoBuild::new()
.bin(env!("CARGO_PKG_NAME")) .bin(env!("CARGO_PKG_NAME"))
.manifest_path(format!("{}/Cargo.toml", env!("CARGO_MANIFEST_DIR"))) .manifest_path(format!("{}/Cargo.toml", env!("CARGO_MANIFEST_DIR")))
.features(if cfg!(feature = "speedb") {
"speedb"
} else {
""
})
.run()? .run()?
.command(), .command(),
)) ))

Loading…
Cancel
Save