Bulk loader: do not fail on empty files

pull/679/head
Tpt 1 year ago committed by Thomas Tanon
parent a259879ef1
commit 9af2717502
  1. 3
      lib/src/storage/backend/rocksdb.rs
  2. 12
      lib/tests/store.rs

@ -814,6 +814,9 @@ impl Db {
&self, &self,
ssts_for_cf: &[(&ColumnFamily, PathBuf)], ssts_for_cf: &[(&ColumnFamily, PathBuf)],
) -> Result<(), StorageError> { ) -> Result<(), StorageError> {
if ssts_for_cf.is_empty() {
return Ok(()); // Rocksdb does not support empty lists
}
if let DbKind::ReadWrite(db) = &self.inner { if let DbKind::ReadWrite(db) = &self.inner {
let mut paths_by_cf = HashMap::<_, Vec<_>>::new(); let mut paths_by_cf = HashMap::<_, Vec<_>>::new();
for (cf, path) in ssts_for_cf { for (cf, path) in ssts_for_cf {

@ -12,6 +12,8 @@ use std::fs::{create_dir, remove_dir_all, File};
use std::io::Cursor; use std::io::Cursor;
#[cfg(not(target_family = "wasm"))] #[cfg(not(target_family = "wasm"))]
use std::io::Write; use std::io::Write;
#[cfg(not(target_family = "wasm"))]
use std::iter::empty;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use std::iter::once; use std::iter::once;
#[cfg(not(target_family = "wasm"))] #[cfg(not(target_family = "wasm"))]
@ -159,6 +161,16 @@ fn test_bulk_load_graph_lenient() -> Result<(), Box<dyn Error>> {
Ok(()) Ok(())
} }
#[test]
#[cfg(not(target_family = "wasm"))]
fn test_bulk_load_empty() -> Result<(), Box<dyn Error>> {
let store = Store::new()?;
store.bulk_loader().load_quads(empty::<Quad>())?;
assert!(store.is_empty()?);
store.validate()?;
Ok(())
}
#[test] #[test]
fn test_load_dataset() -> Result<(), Box<dyn Error>> { fn test_load_dataset() -> Result<(), Box<dyn Error>> {
let store = Store::new()?; let store = Store::new()?;

Loading…
Cancel
Save