From 9af2717502cb9c087342d13ec8e32e89d97b0ef8 Mon Sep 17 00:00:00 2001 From: Tpt Date: Wed, 22 Nov 2023 16:28:07 +0100 Subject: [PATCH] Bulk loader: do not fail on empty files --- lib/src/storage/backend/rocksdb.rs | 3 +++ lib/tests/store.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/src/storage/backend/rocksdb.rs b/lib/src/storage/backend/rocksdb.rs index fc8f4da2..67766007 100644 --- a/lib/src/storage/backend/rocksdb.rs +++ b/lib/src/storage/backend/rocksdb.rs @@ -814,6 +814,9 @@ impl Db { &self, ssts_for_cf: &[(&ColumnFamily, PathBuf)], ) -> Result<(), StorageError> { + if ssts_for_cf.is_empty() { + return Ok(()); // Rocksdb does not support empty lists + } if let DbKind::ReadWrite(db) = &self.inner { let mut paths_by_cf = HashMap::<_, Vec<_>>::new(); for (cf, path) in ssts_for_cf { diff --git a/lib/tests/store.rs b/lib/tests/store.rs index 5f8a6809..32cb1516 100644 --- a/lib/tests/store.rs +++ b/lib/tests/store.rs @@ -12,6 +12,8 @@ use std::fs::{create_dir, remove_dir_all, File}; use std::io::Cursor; #[cfg(not(target_family = "wasm"))] use std::io::Write; +#[cfg(not(target_family = "wasm"))] +use std::iter::empty; #[cfg(target_os = "linux")] use std::iter::once; #[cfg(not(target_family = "wasm"))] @@ -159,6 +161,16 @@ fn test_bulk_load_graph_lenient() -> Result<(), Box> { Ok(()) } +#[test] +#[cfg(not(target_family = "wasm"))] +fn test_bulk_load_empty() -> Result<(), Box> { + let store = Store::new()?; + store.bulk_loader().load_quads(empty::())?; + assert!(store.is_empty()?); + store.validate()?; + Ok(()) +} + #[test] fn test_load_dataset() -> Result<(), Box> { let store = Store::new()?;