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
- run: rustup update
- 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:
RUST_BACKTRACE: 1
@ -155,7 +168,21 @@ jobs:
- run: rustup update
- uses: Swatinem/rust-cache@v2
- 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:
RUST_BACKTRACE: 1
@ -181,7 +208,7 @@ jobs:
submodules: true
- run: rustup update
- uses: Swatinem/rust-cache@v2
- run: cargo doc --all-features
- run: cargo doc
working-directory: ./lib
rustdoc_msrv:
@ -192,7 +219,7 @@ jobs:
submodules: true
- run: rustup update && rustup override set 1.60.0
- uses: Swatinem/rust-cache@v2
- run: cargo doc --all-features
- run: cargo doc
working-directory: ./lib
env:
RUSTDOCFLAGS: -D warnings

3
.gitmodules vendored

@ -13,3 +13,6 @@
[submodule "oxrocksdb-sys/lz4"]
path = oxrocksdb-sys/lz4
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]
default = []
http_client = ["oxhttp", "oxhttp/rustls"]
speedb = ["oxrocksdb-sys/speedb"]
[dependencies]
rand = "0.8"

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

@ -3,4 +3,6 @@ Oxigraph RocksDB bindings
[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.

@ -4,6 +4,9 @@
#include "rocksdb/utilities/object_registry.h"
#include "rocksdb/version.h"
#ifdef SPEEDB
#include "speedb/version.h"
#endif
namespace ROCKSDB_NAMESPACE {
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,
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) {
for (const auto& it : GetRocksBuildProperties()) {
info.append("\n ");
@ -37,4 +55,8 @@ std::string GetRocksBuildInfoAsString(const std::string& program,
}
return info;
}
#ifdef SPEEDB
std::string GetRocksDebugPropertiesAsString() { return ""; }
#endif
} // namespace ROCKSDB_NAMESPACE

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

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

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

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

@ -2,3 +2,5 @@
cd "$(dirname "$0")"/rocksdb || return
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"
rust-version = "1.60"
[features]
speedb = ["oxigraph/speedb"]
[dependencies]
anyhow = "1"
oxhttp = { version = "0.1", features = ["rayon"] }

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

Loading…
Cancel
Save