change C++ header file location

main
Ziyang Hu 2 years ago
parent 1e6211bc6e
commit 7f599b79c1

@ -2,7 +2,7 @@ fn main() {
cxx_build::bridge("src/lib.rs")
.file("src/cozorocks.cc")
.include("../rocksdb/include")
.include("include")
.include("src")
.flag_if_supported("-std=c++17")
.compile("cozo-rocks");
@ -12,5 +12,5 @@ fn main() {
println!("cargo:rustc-link-lib=bz2");
println!("cargo:rerun-if-changed=src/main.rs");
println!("cargo:rerun-if-changed=src/cozorocks.cc");
println!("cargo:rerun-if-changed=include/cozorocks.h");
println!("cargo:rerun-if-changed=src/cozorocks.h");
}

@ -59,7 +59,7 @@ mod ffi {
}
unsafe extern "C++" {
include!("cozo-rocks/include/cozorocks.h");
include!("cozorocks.h");
type StatusCode;
type StatusSubCode;
@ -195,7 +195,7 @@ impl DB {
),
default_read_options: ReadOptions::default(),
default_write_options: WriteOptions::default(),
options
options,
}
}
#[cfg(not(unix))]
@ -222,15 +222,15 @@ impl DB {
}
#[inline]
pub fn get(&self, key: impl AsRef<[u8]>, options: Option<&ReadOptions>) -> Result<PinnableSlice, Status> {
pub fn get(&self, key: impl AsRef<[u8]>, options: Option<&ReadOptions>) -> Result<Option<PinnableSlice>, Status> {
let mut status = Status::default();
let slice = self.bridge.get(
&options.unwrap_or(&self.default_read_options).bridge,
key.as_ref(), &mut status);
if status.code == StatusCode::kOk {
Ok(PinnableSlice { bridge: slice })
} else {
Err(status)
match status.code {
StatusCode::kOk => Ok(Some(PinnableSlice { bridge: slice })),
StatusCode::kNotFound => Ok(None),
_ => Err(status)
}
}
}

@ -94,16 +94,20 @@ mod tests {
builder.build_value(&Value::RefString("Another key"));
let key2 = builder.get();
let val = db.get(&key, None).unwrap();
// let val = val.as_bytes();
println!("before anything {}", val.is_none());
db.put(&key, "A motherfucking value!!! 👋👋👋", None).unwrap();
db.put(&key2, "Another motherfucking value!!! 👋👋👋", None).unwrap();
// db.put("Yes man", "A motherfucking value!!! 👋👋👋", None).unwrap();
let val = db.get(&key, None).unwrap();
let val = db.get(&key, None).unwrap().unwrap();
let val = val.as_bytes();
println!("{}", from_utf8(val).unwrap());
let val = db.get(&key2, None).unwrap();
let val = db.get(&key2, None).unwrap().unwrap();
let val = val.as_bytes();
println!("{}", from_utf8(val).unwrap());
let val = db.get(&key, None).unwrap();
let val = db.get(&key, None).unwrap().unwrap();
let val = val.as_bytes();
println!("{}", from_utf8(val).unwrap());
}

Loading…
Cancel
Save