Renames write_stt_files to insert_stt_files

pull/173/head
Tpt 3 years ago
parent a3e40556da
commit ed17e86853
  1. 2
      lib/src/storage/backend/rocksdb.rs
  2. 4
      lib/src/storage/mod.rs
  3. 39
      lib/tests/store.rs

@ -442,7 +442,7 @@ impl Db {
} }
} }
pub fn write_stt_files(&self, ssts_for_cf: Vec<(&ColumnFamily, PathBuf)>) -> Result<()> { pub fn insert_stt_files(&self, ssts_for_cf: Vec<(&ColumnFamily, PathBuf)>) -> Result<()> {
for (cf, path) in ssts_for_cf { for (cf, path) in ssts_for_cf {
unsafe { unsafe {
ffi_result!(rocksdb_transactiondb_ingest_external_file_cf( ffi_result!(rocksdb_transactiondb_ingest_external_file_cf(

@ -163,7 +163,7 @@ impl Storage {
stt_file.insert_empty(&k)?; stt_file.insert_empty(&k)?;
} }
this.db this.db
.write_stt_files(vec![(&this.graphs_cf, stt_file.finish()?)])?; .insert_stt_files(vec![(&this.graphs_cf, stt_file.finish()?)])?;
version = 1; version = 1;
this.update_version(version)?; this.update_version(version)?;
} }
@ -1166,7 +1166,7 @@ impl BulkLoader {
self.quads.clear(); self.quads.clear();
} }
self.storage.db.write_stt_files(to_load) self.storage.db.insert_stt_files(to_load)
} }
fn insert_term(&mut self, term: TermRef<'_>, encoded: &EncodedTerm) -> Result<()> { fn insert_term(&mut self, term: TermRef<'_>, encoded: &EncodedTerm) -> Result<()> {

@ -2,8 +2,7 @@ use oxigraph::io::{DatasetFormat, GraphFormat};
use oxigraph::model::vocab::{rdf, xsd}; use oxigraph::model::vocab::{rdf, xsd};
use oxigraph::model::*; use oxigraph::model::*;
use oxigraph::store::Store; use oxigraph::store::Store;
use std::io; use std::io::{Cursor, Result};
use std::io::Cursor;
use std::process::Command; use std::process::Command;
const DATA: &str = r#" const DATA: &str = r#"
@ -75,7 +74,7 @@ fn quads(graph_name: impl Into<GraphNameRef<'static>>) -> Vec<QuadRef<'static>>
} }
#[test] #[test]
fn test_load_graph() -> io::Result<()> { fn test_load_graph() -> Result<()> {
let store = Store::new()?; let store = Store::new()?;
store.load_graph( store.load_graph(
Cursor::new(DATA), Cursor::new(DATA),
@ -90,7 +89,7 @@ fn test_load_graph() -> io::Result<()> {
} }
#[test] #[test]
fn test_load_dataset() -> io::Result<()> { fn test_load_dataset() -> Result<()> {
let store = Store::new()?; let store = Store::new()?;
store.load_dataset(Cursor::new(DATA), DatasetFormat::TriG, None)?; store.load_dataset(Cursor::new(DATA), DatasetFormat::TriG, None)?;
for q in quads(GraphNameRef::DefaultGraph) { for q in quads(GraphNameRef::DefaultGraph) {
@ -100,7 +99,7 @@ fn test_load_dataset() -> io::Result<()> {
} }
#[test] #[test]
fn test_bulk_load_dataset() -> io::Result<()> { fn test_bulk_load_dataset() -> Result<()> {
let mut store = Store::new().unwrap(); let mut store = Store::new().unwrap();
store.bulk_load_dataset(Cursor::new(DATA), DatasetFormat::TriG, None)?; store.bulk_load_dataset(Cursor::new(DATA), DatasetFormat::TriG, None)?;
for q in quads(GraphNameRef::DefaultGraph) { for q in quads(GraphNameRef::DefaultGraph) {
@ -110,7 +109,7 @@ fn test_bulk_load_dataset() -> io::Result<()> {
} }
#[test] #[test]
fn test_dump_graph() -> io::Result<()> { fn test_dump_graph() -> Result<()> {
let store = Store::new()?; let store = Store::new()?;
for q in quads(GraphNameRef::DefaultGraph) { for q in quads(GraphNameRef::DefaultGraph) {
store.insert(q)?; store.insert(q)?;
@ -130,7 +129,7 @@ fn test_dump_graph() -> io::Result<()> {
} }
#[test] #[test]
fn test_dump_dataset() -> io::Result<()> { fn test_dump_dataset() -> Result<()> {
let store = Store::new()?; let store = Store::new()?;
for q in quads(GraphNameRef::DefaultGraph) { for q in quads(GraphNameRef::DefaultGraph) {
store.insert(q)?; store.insert(q)?;
@ -146,7 +145,7 @@ fn test_dump_dataset() -> io::Result<()> {
} }
#[test] #[test]
fn test_snapshot_isolation_iterator() -> io::Result<()> { fn test_snapshot_isolation_iterator() -> Result<()> {
let quad = QuadRef::new( let quad = QuadRef::new(
NamedNodeRef::new_unchecked("http://example.com/s"), NamedNodeRef::new_unchecked("http://example.com/s"),
NamedNodeRef::new_unchecked("http://example.com/p"), NamedNodeRef::new_unchecked("http://example.com/p"),
@ -157,16 +156,28 @@ fn test_snapshot_isolation_iterator() -> io::Result<()> {
store.insert(quad)?; store.insert(quad)?;
let iter = store.iter(); let iter = store.iter();
store.remove(quad)?; store.remove(quad)?;
assert_eq!( assert_eq!(iter.collect::<Result<Vec<_>>>()?, vec![quad.into_owned()]);
iter.collect::<io::Result<Vec<_>>>()?, Ok(())
vec![quad.into_owned()] }
#[test]
fn test_bulk_load_on_existing_delete_overrides_the_delete() -> Result<()> {
let quad = QuadRef::new(
NamedNodeRef::new_unchecked("http://example.com/s"),
NamedNodeRef::new_unchecked("http://example.com/p"),
NamedNodeRef::new_unchecked("http://example.com/o"),
NamedNodeRef::new_unchecked("http://example.com/g"),
); );
let mut store = Store::new()?;
store.remove(quad)?;
store.bulk_extend([quad.into_owned()])?;
assert_eq!(store.len()?, 1);
Ok(()) Ok(())
} }
#[test] #[test]
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
fn test_backward_compatibility() -> io::Result<()> { fn test_backward_compatibility() -> Result<()> {
// We run twice to check if data is properly saved and closed // We run twice to check if data is properly saved and closed
for _ in 0..2 { for _ in 0..2 {
let store = Store::open("tests/rocksdb_bc_data")?; let store = Store::open("tests/rocksdb_bc_data")?;
@ -181,14 +192,14 @@ fn test_backward_compatibility() -> io::Result<()> {
assert!(store.contains_named_graph(graph_name)?); assert!(store.contains_named_graph(graph_name)?);
assert_eq!( assert_eq!(
vec![NamedOrBlankNode::from(graph_name)], vec![NamedOrBlankNode::from(graph_name)],
store.named_graphs().collect::<io::Result<Vec<_>>>()? store.named_graphs().collect::<Result<Vec<_>>>()?
); );
} }
reset_dir("tests/rocksdb_bc_data")?; reset_dir("tests/rocksdb_bc_data")?;
Ok(()) Ok(())
} }
fn reset_dir(dir: &str) -> io::Result<()> { fn reset_dir(dir: &str) -> Result<()> {
assert!(Command::new("git") assert!(Command::new("git")
.args(&["clean", "-fX", dir]) .args(&["clean", "-fX", dir])
.status()? .status()?

Loading…
Cancel
Save