|
|
@ -8,10 +8,11 @@ use crate::sparql::http::Client; |
|
|
|
use crate::sparql::plan::EncodedTuple; |
|
|
|
use crate::sparql::plan::EncodedTuple; |
|
|
|
use crate::sparql::plan_builder::PlanBuilder; |
|
|
|
use crate::sparql::plan_builder::PlanBuilder; |
|
|
|
use crate::sparql::{EvaluationError, UpdateOptions}; |
|
|
|
use crate::sparql::{EvaluationError, UpdateOptions}; |
|
|
|
|
|
|
|
use crate::store::load_graph; |
|
|
|
use crate::store::numeric_encoder::{ |
|
|
|
use crate::store::numeric_encoder::{ |
|
|
|
EncodedQuad, EncodedTerm, ReadEncoder, StrContainer, StrLookup, WriteEncoder, |
|
|
|
EncodedQuad, EncodedTerm, ReadEncoder, StrLookup, WriteEncoder, |
|
|
|
}; |
|
|
|
}; |
|
|
|
use crate::store::{load_graph, ReadableEncodedStore, StoreOrParseError, WritableEncodedStore}; |
|
|
|
use crate::store::storage::Storage; |
|
|
|
use http::header::{ACCEPT, CONTENT_TYPE, USER_AGENT}; |
|
|
|
use http::header::{ACCEPT, CONTENT_TYPE, USER_AGENT}; |
|
|
|
use http::{Method, Request, StatusCode}; |
|
|
|
use http::{Method, Request, StatusCode}; |
|
|
|
use oxiri::Iri; |
|
|
|
use oxiri::Iri; |
|
|
@ -25,31 +26,21 @@ use std::collections::HashMap; |
|
|
|
use std::io; |
|
|
|
use std::io; |
|
|
|
use std::rc::Rc; |
|
|
|
use std::rc::Rc; |
|
|
|
|
|
|
|
|
|
|
|
pub(crate) struct SimpleUpdateEvaluator<'a, R, W> { |
|
|
|
pub(crate) struct SimpleUpdateEvaluator<'a> { |
|
|
|
read: R, |
|
|
|
storage: &'a Storage, |
|
|
|
write: &'a mut W, |
|
|
|
|
|
|
|
base_iri: Option<Rc<Iri<String>>>, |
|
|
|
base_iri: Option<Rc<Iri<String>>>, |
|
|
|
options: UpdateOptions, |
|
|
|
options: UpdateOptions, |
|
|
|
client: Client, |
|
|
|
client: Client, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
impl< |
|
|
|
impl<'a> SimpleUpdateEvaluator<'a> { |
|
|
|
'a, |
|
|
|
|
|
|
|
R: ReadableEncodedStore + Clone + 'static, |
|
|
|
|
|
|
|
W: StrContainer + WritableEncodedStore + 'a, |
|
|
|
|
|
|
|
> SimpleUpdateEvaluator<'a, R, W> |
|
|
|
|
|
|
|
where |
|
|
|
|
|
|
|
io::Error: From<StoreOrParseError<W::Error>>, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
pub fn new( |
|
|
|
pub fn new( |
|
|
|
read: R, |
|
|
|
storage: &'a Storage, |
|
|
|
write: &'a mut W, |
|
|
|
|
|
|
|
base_iri: Option<Rc<Iri<String>>>, |
|
|
|
base_iri: Option<Rc<Iri<String>>>, |
|
|
|
options: UpdateOptions, |
|
|
|
options: UpdateOptions, |
|
|
|
) -> Self { |
|
|
|
) -> Self { |
|
|
|
Self { |
|
|
|
Self { |
|
|
|
read, |
|
|
|
storage, |
|
|
|
write, |
|
|
|
|
|
|
|
base_iri, |
|
|
|
base_iri, |
|
|
|
options, |
|
|
|
options, |
|
|
|
client: Client::new(), |
|
|
|
client: Client::new(), |
|
|
@ -102,7 +93,7 @@ where |
|
|
|
let mut bnodes = HashMap::new(); |
|
|
|
let mut bnodes = HashMap::new(); |
|
|
|
for quad in data { |
|
|
|
for quad in data { |
|
|
|
if let Some(quad) = self.encode_quad_for_insertion(quad, &mut bnodes)? { |
|
|
|
if let Some(quad) = self.encode_quad_for_insertion(quad, &mut bnodes)? { |
|
|
|
self.write.insert_encoded(&quad).map_err(to_eval_error)?; |
|
|
|
self.storage.insert(&quad)?; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
@ -111,7 +102,7 @@ where |
|
|
|
fn eval_delete_data(&mut self, data: &[Quad]) -> Result<(), EvaluationError> { |
|
|
|
fn eval_delete_data(&mut self, data: &[Quad]) -> Result<(), EvaluationError> { |
|
|
|
for quad in data { |
|
|
|
for quad in data { |
|
|
|
if let Some(quad) = self.encode_quad_for_deletion(quad)? { |
|
|
|
if let Some(quad) = self.encode_quad_for_deletion(quad)? { |
|
|
|
self.write.remove_encoded(&quad).map_err(to_eval_error)?; |
|
|
|
self.storage.remove(&quad)?; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
@ -124,9 +115,9 @@ where |
|
|
|
using: &QueryDataset, |
|
|
|
using: &QueryDataset, |
|
|
|
algebra: &GraphPattern, |
|
|
|
algebra: &GraphPattern, |
|
|
|
) -> Result<(), EvaluationError> { |
|
|
|
) -> Result<(), EvaluationError> { |
|
|
|
let dataset = Rc::new(DatasetView::new(self.read.clone(), using)?); |
|
|
|
let dataset = Rc::new(DatasetView::new(self.storage.clone(), using)?); |
|
|
|
let (plan, variables) = PlanBuilder::build(dataset.as_ref(), algebra)?; |
|
|
|
let (plan, variables) = PlanBuilder::build(dataset.as_ref(), algebra)?; |
|
|
|
let evaluator = SimpleEvaluator::<DatasetView<R>>::new( |
|
|
|
let evaluator = SimpleEvaluator::new( |
|
|
|
dataset.clone(), |
|
|
|
dataset.clone(), |
|
|
|
self.base_iri.clone(), |
|
|
|
self.base_iri.clone(), |
|
|
|
self.options.query_options.service_handler.clone(), |
|
|
|
self.options.query_options.service_handler.clone(), |
|
|
@ -138,22 +129,16 @@ where |
|
|
|
.into_iter() |
|
|
|
.into_iter() |
|
|
|
.map(|t| { |
|
|
|
.map(|t| { |
|
|
|
Ok(if let Some(t) = t { |
|
|
|
Ok(if let Some(t) = t { |
|
|
|
t.on_each_id(|id| { |
|
|
|
let r: Result<_, EvaluationError> = t.on_each_id(|id| { |
|
|
|
self.write |
|
|
|
self.storage.insert_str( |
|
|
|
.insert_str( |
|
|
|
id, |
|
|
|
&dataset |
|
|
|
&dataset.get_str(id)?.ok_or_else(|| { |
|
|
|
.get_str(id) |
|
|
|
EvaluationError::msg("String not stored in the string store") |
|
|
|
.map_err(to_eval_error)? |
|
|
|
})?, |
|
|
|
.ok_or_else(|| { |
|
|
|
)?; |
|
|
|
EvaluationError::msg( |
|
|
|
Ok(()) |
|
|
|
"String not stored in the string store", |
|
|
|
}); |
|
|
|
) |
|
|
|
r?; |
|
|
|
}) |
|
|
|
|
|
|
|
.map_err(to_eval_error)?, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.map(|_| ()) |
|
|
|
|
|
|
|
.map_err(to_eval_error) |
|
|
|
|
|
|
|
})?; |
|
|
|
|
|
|
|
Some(t) |
|
|
|
Some(t) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
None |
|
|
|
None |
|
|
@ -165,14 +150,14 @@ where |
|
|
|
if let Some(quad) = |
|
|
|
if let Some(quad) = |
|
|
|
self.encode_quad_pattern_for_deletion(quad, &variables, &tuple)? |
|
|
|
self.encode_quad_pattern_for_deletion(quad, &variables, &tuple)? |
|
|
|
{ |
|
|
|
{ |
|
|
|
self.write.remove_encoded(&quad).map_err(to_eval_error)?; |
|
|
|
self.storage.remove(&quad)?; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for quad in insert { |
|
|
|
for quad in insert { |
|
|
|
if let Some(quad) = |
|
|
|
if let Some(quad) = |
|
|
|
self.encode_quad_pattern_for_insertion(quad, &variables, &tuple, &mut bnodes)? |
|
|
|
self.encode_quad_pattern_for_insertion(quad, &variables, &tuple, &mut bnodes)? |
|
|
|
{ |
|
|
|
{ |
|
|
|
self.write.insert_encoded(&quad).map_err(to_eval_error)?; |
|
|
|
self.storage.insert(&quad)?; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
bnodes.clear(); |
|
|
|
bnodes.clear(); |
|
|
@ -223,7 +208,7 @@ where |
|
|
|
GraphNameRef::DefaultGraph |
|
|
|
GraphNameRef::DefaultGraph |
|
|
|
}; |
|
|
|
}; |
|
|
|
load_graph( |
|
|
|
load_graph( |
|
|
|
self.write, |
|
|
|
self.storage, |
|
|
|
response.into_body(), |
|
|
|
response.into_body(), |
|
|
|
format, |
|
|
|
format, |
|
|
|
to_graph_name, |
|
|
|
to_graph_name, |
|
|
@ -235,11 +220,7 @@ where |
|
|
|
|
|
|
|
|
|
|
|
fn eval_create(&mut self, graph: &NamedNode, silent: bool) -> Result<(), EvaluationError> { |
|
|
|
fn eval_create(&mut self, graph: &NamedNode, silent: bool) -> Result<(), EvaluationError> { |
|
|
|
let encoded_graph_name = self.encode_named_node_for_insertion(graph)?; |
|
|
|
let encoded_graph_name = self.encode_named_node_for_insertion(graph)?; |
|
|
|
if self |
|
|
|
if self.storage.contains_named_graph(encoded_graph_name)? { |
|
|
|
.read |
|
|
|
|
|
|
|
.contains_encoded_named_graph(encoded_graph_name) |
|
|
|
|
|
|
|
.map_err(to_eval_error)? |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if silent { |
|
|
|
if silent { |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -249,9 +230,8 @@ where |
|
|
|
))) |
|
|
|
))) |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
self.write |
|
|
|
self.storage.insert_named_graph(encoded_graph_name)?; |
|
|
|
.insert_encoded_named_graph(encoded_graph_name) |
|
|
|
Ok(()) |
|
|
|
.map_err(to_eval_error) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -259,15 +239,8 @@ where |
|
|
|
match graph { |
|
|
|
match graph { |
|
|
|
GraphTarget::NamedNode(graph_name) => { |
|
|
|
GraphTarget::NamedNode(graph_name) => { |
|
|
|
if let Some(graph_name) = self.encode_named_node_for_deletion(graph_name)? { |
|
|
|
if let Some(graph_name) = self.encode_named_node_for_deletion(graph_name)? { |
|
|
|
if self |
|
|
|
if self.storage.contains_named_graph(graph_name)? { |
|
|
|
.read |
|
|
|
return Ok(self.storage.clear_graph(graph_name)?); |
|
|
|
.contains_encoded_named_graph(graph_name) |
|
|
|
|
|
|
|
.map_err(to_eval_error)? |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return self |
|
|
|
|
|
|
|
.write |
|
|
|
|
|
|
|
.clear_encoded_graph(graph_name) |
|
|
|
|
|
|
|
.map_err(to_eval_error); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if silent { |
|
|
|
if silent { |
|
|
@ -279,29 +252,20 @@ where |
|
|
|
))) |
|
|
|
))) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
GraphTarget::DefaultGraph => self |
|
|
|
GraphTarget::DefaultGraph => Ok(self.storage.clear_graph(EncodedTerm::DefaultGraph)?), |
|
|
|
.write |
|
|
|
|
|
|
|
.clear_encoded_graph(EncodedTerm::DefaultGraph) |
|
|
|
|
|
|
|
.map_err(to_eval_error), |
|
|
|
|
|
|
|
GraphTarget::NamedGraphs => { |
|
|
|
GraphTarget::NamedGraphs => { |
|
|
|
// TODO: optimize?
|
|
|
|
// TODO: optimize?
|
|
|
|
for graph in self.read.encoded_named_graphs() { |
|
|
|
for graph in self.storage.named_graphs() { |
|
|
|
self.write |
|
|
|
self.storage.clear_graph(graph?)?; |
|
|
|
.clear_encoded_graph(graph.map_err(to_eval_error)?) |
|
|
|
|
|
|
|
.map_err(to_eval_error)?; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
GraphTarget::AllGraphs => { |
|
|
|
GraphTarget::AllGraphs => { |
|
|
|
// TODO: optimize?
|
|
|
|
// TODO: optimize?
|
|
|
|
for graph in self.read.encoded_named_graphs() { |
|
|
|
for graph in self.storage.named_graphs() { |
|
|
|
self.write |
|
|
|
self.storage.clear_graph(graph?)?; |
|
|
|
.clear_encoded_graph(graph.map_err(to_eval_error)?) |
|
|
|
|
|
|
|
.map_err(to_eval_error)?; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
self.write |
|
|
|
Ok(self.storage.clear_graph(EncodedTerm::DefaultGraph)?) |
|
|
|
.clear_encoded_graph(EncodedTerm::DefaultGraph) |
|
|
|
|
|
|
|
.map_err(to_eval_error) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -310,15 +274,9 @@ where |
|
|
|
match graph { |
|
|
|
match graph { |
|
|
|
GraphTarget::NamedNode(graph_name) => { |
|
|
|
GraphTarget::NamedNode(graph_name) => { |
|
|
|
if let Some(graph_name) = self.encode_named_node_for_deletion(graph_name)? { |
|
|
|
if let Some(graph_name) = self.encode_named_node_for_deletion(graph_name)? { |
|
|
|
if self |
|
|
|
if self.storage.contains_named_graph(graph_name)? { |
|
|
|
.read |
|
|
|
self.storage.remove_named_graph(graph_name)?; |
|
|
|
.contains_encoded_named_graph(graph_name) |
|
|
|
return Ok(()); |
|
|
|
.map_err(to_eval_error)? |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return self |
|
|
|
|
|
|
|
.write |
|
|
|
|
|
|
|
.remove_encoded_named_graph(graph_name) |
|
|
|
|
|
|
|
.map_err(to_eval_error); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if silent { |
|
|
|
if silent { |
|
|
@ -330,20 +288,15 @@ where |
|
|
|
))) |
|
|
|
))) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
GraphTarget::DefaultGraph => self |
|
|
|
GraphTarget::DefaultGraph => Ok(self.storage.clear_graph(EncodedTerm::DefaultGraph)?), |
|
|
|
.write |
|
|
|
|
|
|
|
.clear_encoded_graph(EncodedTerm::DefaultGraph) |
|
|
|
|
|
|
|
.map_err(to_eval_error), |
|
|
|
|
|
|
|
GraphTarget::NamedGraphs => { |
|
|
|
GraphTarget::NamedGraphs => { |
|
|
|
// TODO: optimize?
|
|
|
|
// TODO: optimize?
|
|
|
|
for graph in self.read.encoded_named_graphs() { |
|
|
|
for graph in self.storage.named_graphs() { |
|
|
|
self.write |
|
|
|
self.storage.remove_named_graph(graph?)?; |
|
|
|
.remove_encoded_named_graph(graph.map_err(to_eval_error)?) |
|
|
|
|
|
|
|
.map_err(to_eval_error)?; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Ok(()) |
|
|
|
Ok(()) |
|
|
|
} |
|
|
|
} |
|
|
|
GraphTarget::AllGraphs => self.write.clear().map_err(to_eval_error), |
|
|
|
GraphTarget::AllGraphs => Ok(self.storage.clear()?), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -358,20 +311,17 @@ where |
|
|
|
self.encode_named_node_for_insertion(subject)? |
|
|
|
self.encode_named_node_for_insertion(subject)? |
|
|
|
} |
|
|
|
} |
|
|
|
NamedOrBlankNode::BlankNode(subject) => self |
|
|
|
NamedOrBlankNode::BlankNode(subject) => self |
|
|
|
.write |
|
|
|
.storage |
|
|
|
.encode_blank_node(bnodes.entry(subject.clone()).or_default().as_ref()) |
|
|
|
.encode_blank_node(bnodes.entry(subject.clone()).or_default().as_ref())?, |
|
|
|
.map_err(to_eval_error)?, |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
predicate: self |
|
|
|
predicate: self |
|
|
|
.write |
|
|
|
.storage |
|
|
|
.encode_named_node(NamedNodeRef::new_unchecked(&quad.predicate.iri)) |
|
|
|
.encode_named_node(NamedNodeRef::new_unchecked(&quad.predicate.iri))?, |
|
|
|
.map_err(to_eval_error)?, |
|
|
|
|
|
|
|
object: match &quad.object { |
|
|
|
object: match &quad.object { |
|
|
|
Term::NamedNode(object) => self.encode_named_node_for_insertion(object)?, |
|
|
|
Term::NamedNode(object) => self.encode_named_node_for_insertion(object)?, |
|
|
|
Term::BlankNode(object) => self |
|
|
|
Term::BlankNode(object) => self |
|
|
|
.write |
|
|
|
.storage |
|
|
|
.encode_blank_node(bnodes.entry(object.clone()).or_default().as_ref()) |
|
|
|
.encode_blank_node(bnodes.entry(object.clone()).or_default().as_ref())?, |
|
|
|
.map_err(to_eval_error)?, |
|
|
|
|
|
|
|
Term::Literal(object) => self.encode_literal_for_insertion(object)?, |
|
|
|
Term::Literal(object) => self.encode_literal_for_insertion(object)?, |
|
|
|
}, |
|
|
|
}, |
|
|
|
graph_name: match &quad.graph_name { |
|
|
|
graph_name: match &quad.graph_name { |
|
|
@ -446,9 +396,8 @@ where |
|
|
|
TermOrVariable::Term(term) => Some(match term { |
|
|
|
TermOrVariable::Term(term) => Some(match term { |
|
|
|
Term::NamedNode(term) => self.encode_named_node_for_insertion(term)?, |
|
|
|
Term::NamedNode(term) => self.encode_named_node_for_insertion(term)?, |
|
|
|
Term::BlankNode(bnode) => self |
|
|
|
Term::BlankNode(bnode) => self |
|
|
|
.write |
|
|
|
.storage |
|
|
|
.encode_blank_node(bnodes.entry(bnode.clone()).or_default().as_ref()) |
|
|
|
.encode_blank_node(bnodes.entry(bnode.clone()).or_default().as_ref())?, |
|
|
|
.map_err(to_eval_error)?, |
|
|
|
|
|
|
|
Term::Literal(term) => self.encode_literal_for_insertion(term)?, |
|
|
|
Term::Literal(term) => self.encode_literal_for_insertion(term)?, |
|
|
|
}), |
|
|
|
}), |
|
|
|
TermOrVariable::Variable(v) => { |
|
|
|
TermOrVariable::Variable(v) => { |
|
|
@ -501,26 +450,24 @@ where |
|
|
|
&mut self, |
|
|
|
&mut self, |
|
|
|
term: &NamedNode, |
|
|
|
term: &NamedNode, |
|
|
|
) -> Result<EncodedTerm, EvaluationError> { |
|
|
|
) -> Result<EncodedTerm, EvaluationError> { |
|
|
|
self.write |
|
|
|
Ok(self |
|
|
|
.encode_named_node(NamedNodeRef::new_unchecked(&term.iri)) |
|
|
|
.storage |
|
|
|
.map_err(to_eval_error) |
|
|
|
.encode_named_node(NamedNodeRef::new_unchecked(&term.iri))?) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn encode_literal_for_insertion( |
|
|
|
fn encode_literal_for_insertion( |
|
|
|
&mut self, |
|
|
|
&mut self, |
|
|
|
term: &Literal, |
|
|
|
term: &Literal, |
|
|
|
) -> Result<EncodedTerm, EvaluationError> { |
|
|
|
) -> Result<EncodedTerm, EvaluationError> { |
|
|
|
self.write |
|
|
|
Ok(self.storage.encode_literal(match term { |
|
|
|
.encode_literal(match term { |
|
|
|
Literal::Simple { value } => LiteralRef::new_simple_literal(value), |
|
|
|
Literal::Simple { value } => LiteralRef::new_simple_literal(value), |
|
|
|
Literal::LanguageTaggedString { value, language } => { |
|
|
|
Literal::LanguageTaggedString { value, language } => { |
|
|
|
LiteralRef::new_language_tagged_literal_unchecked(value, language) |
|
|
|
LiteralRef::new_language_tagged_literal_unchecked(value, language) |
|
|
|
} |
|
|
|
} |
|
|
|
Literal::Typed { value, datatype } => { |
|
|
|
Literal::Typed { value, datatype } => { |
|
|
|
LiteralRef::new_typed_literal(value, NamedNodeRef::new_unchecked(&datatype.iri)) |
|
|
|
LiteralRef::new_typed_literal(value, NamedNodeRef::new_unchecked(&datatype.iri)) |
|
|
|
} |
|
|
|
} |
|
|
|
})?) |
|
|
|
}) |
|
|
|
|
|
|
|
.map_err(to_eval_error) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn encode_quad_for_deletion( |
|
|
|
fn encode_quad_for_deletion( |
|
|
@ -675,29 +622,23 @@ where |
|
|
|
&self, |
|
|
|
&self, |
|
|
|
term: &NamedNode, |
|
|
|
term: &NamedNode, |
|
|
|
) -> Result<Option<EncodedTerm>, EvaluationError> { |
|
|
|
) -> Result<Option<EncodedTerm>, EvaluationError> { |
|
|
|
self.read |
|
|
|
Ok(self |
|
|
|
.get_encoded_named_node(NamedNodeRef::new_unchecked(&term.iri)) |
|
|
|
.storage |
|
|
|
.map_err(to_eval_error) |
|
|
|
.get_encoded_named_node(NamedNodeRef::new_unchecked(&term.iri))?) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn encode_literal_for_deletion( |
|
|
|
fn encode_literal_for_deletion( |
|
|
|
&self, |
|
|
|
&self, |
|
|
|
term: &Literal, |
|
|
|
term: &Literal, |
|
|
|
) -> Result<Option<EncodedTerm>, EvaluationError> { |
|
|
|
) -> Result<Option<EncodedTerm>, EvaluationError> { |
|
|
|
self.read |
|
|
|
Ok(self.storage.get_encoded_literal(match term { |
|
|
|
.get_encoded_literal(match term { |
|
|
|
Literal::Simple { value } => LiteralRef::new_simple_literal(value), |
|
|
|
Literal::Simple { value } => LiteralRef::new_simple_literal(value), |
|
|
|
Literal::LanguageTaggedString { value, language } => { |
|
|
|
Literal::LanguageTaggedString { value, language } => { |
|
|
|
LiteralRef::new_language_tagged_literal_unchecked(value, language) |
|
|
|
LiteralRef::new_language_tagged_literal_unchecked(value, language) |
|
|
|
} |
|
|
|
} |
|
|
|
Literal::Typed { value, datatype } => { |
|
|
|
Literal::Typed { value, datatype } => { |
|
|
|
LiteralRef::new_typed_literal(value, NamedNodeRef::new_unchecked(&datatype.iri)) |
|
|
|
LiteralRef::new_typed_literal(value, NamedNodeRef::new_unchecked(&datatype.iri)) |
|
|
|
} |
|
|
|
} |
|
|
|
})?) |
|
|
|
}) |
|
|
|
|
|
|
|
.map_err(to_eval_error) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn to_eval_error(e: impl Into<EvaluationError>) -> EvaluationError { |
|
|
|
|
|
|
|
e.into() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|