SPARQL: we do not need to ensure strings exist anymore

pull/173/head
Tpt 3 years ago
parent e59c4612b2
commit 7bb41e655e
  1. 6
      lib/src/sparql/update.rs
  2. 55
      lib/src/storage/mod.rs

@ -144,12 +144,6 @@ impl SimpleUpdateEvaluator {
Self::convert_ground_quad_pattern(quad, &variables, &tuple, &dataset)? Self::convert_ground_quad_pattern(quad, &variables, &tuple, &dataset)?
{ {
self.transaction.remove(quad.as_ref())?; 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 { for quad in insert {

@ -1201,59 +1201,4 @@ mod tests {
assert!(t3.remove(quad).is_err()); // Already locked assert!(t3.remove(quad).is_err()); // Already locked
Ok(()) 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(())
}
} }

Loading…
Cancel
Save