From 7bb41e655e0ef1ad3f9527008eb805b5e8de0f75 Mon Sep 17 00:00:00 2001 From: Tpt Date: Sat, 27 Nov 2021 20:15:01 +0100 Subject: [PATCH] SPARQL: we do not need to ensure strings exist anymore --- lib/src/sparql/update.rs | 6 ----- lib/src/storage/mod.rs | 55 ---------------------------------------- 2 files changed, 61 deletions(-) diff --git a/lib/src/sparql/update.rs b/lib/src/sparql/update.rs index e4e31d89..8128e40a 100644 --- a/lib/src/sparql/update.rs +++ b/lib/src/sparql/update.rs @@ -144,12 +144,6 @@ impl SimpleUpdateEvaluator { Self::convert_ground_quad_pattern(quad, &variables, &tuple, &dataset)? { self.transaction.remove(quad.as_ref())?; - if !insert.is_empty() { - // Hack to make sure the triple terms are still available for an insert - dataset.encode_term(quad.subject.as_ref()); - dataset.encode_term(quad.predicate.as_ref()); - dataset.encode_term(quad.object.as_ref()); - } } } for quad in insert { diff --git a/lib/src/storage/mod.rs b/lib/src/storage/mod.rs index a11f321f..842a8f4a 100644 --- a/lib/src/storage/mod.rs +++ b/lib/src/storage/mod.rs @@ -1201,59 +1201,4 @@ mod tests { assert!(t3.remove(quad).is_err()); // Already locked Ok(()) } - - #[test] - fn test_strings_removal() -> 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 quad2 = QuadRef::new( - NamedNodeRef::new_unchecked("http://example.com/s"), - NamedNodeRef::new_unchecked("http://example.com/p"), - NamedNodeRef::new_unchecked("http://example.com/o2"), - NamedNodeRef::new_unchecked("http://example.com/g"), - ); - - let storage = Storage::new()?; - let reader = storage.reader(); - let mut writer = storage.transaction(); - writer.insert(quad)?; - writer.insert(quad2)?; - writer.remove(quad2)?; - writer.commit()?; - assert!(reader - .get_str(&StrHash::new("http://example.com/s"))? - .is_some()); - assert!(reader - .get_str(&StrHash::new("http://example.com/p"))? - .is_some()); - assert!(reader - .get_str(&StrHash::new("http://example.com/o2"))? - .is_none()); - let mut writer = storage.transaction(); - writer.clear_graph(NamedNodeRef::new_unchecked("http://example.com/g").into())?; - writer.commit()?; - assert!(reader - .get_str(&StrHash::new("http://example.com/s"))? - .is_none()); - assert!(reader - .get_str(&StrHash::new("http://example.com/p"))? - .is_none()); - assert!(reader - .get_str(&StrHash::new("http://example.com/o"))? - .is_none()); - assert!(reader - .get_str(&StrHash::new("http://example.com/g"))? - .is_some()); - let mut writer = storage.transaction(); - writer.remove_named_graph(NamedNodeRef::new_unchecked("http://example.com/g").into())?; - writer.commit()?; - assert!(reader - .get_str(&StrHash::new("http://example.com/g"))? - .is_none()); - Ok(()) - } }