|
|
@ -7,7 +7,7 @@ use crate::io::{ |
|
|
|
use crate::model::*; |
|
|
|
use crate::model::*; |
|
|
|
use crate::sparql::*; |
|
|
|
use crate::sparql::*; |
|
|
|
use oxigraph::io::RdfParser; |
|
|
|
use oxigraph::io::RdfParser; |
|
|
|
use oxigraph::model::{GraphName, GraphNameRef}; |
|
|
|
use oxigraph::model::GraphNameRef; |
|
|
|
use oxigraph::sparql::Update; |
|
|
|
use oxigraph::sparql::Update; |
|
|
|
use oxigraph::store::{self, LoaderError, SerializerError, StorageError, Store}; |
|
|
|
use oxigraph::store::{self, LoaderError, SerializerError, StorageError, Store}; |
|
|
|
use pyo3::exceptions::{PyRuntimeError, PyValueError}; |
|
|
|
use pyo3::exceptions::{PyRuntimeError, PyValueError}; |
|
|
@ -161,7 +161,7 @@ impl PyStore { |
|
|
|
/// >>> store.extend([Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))])
|
|
|
|
/// >>> store.extend([Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g'))])
|
|
|
|
/// >>> list(store)
|
|
|
|
/// >>> list(store)
|
|
|
|
/// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
|
|
|
|
/// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
|
|
|
|
fn extend(&self, quads: &PyAny, py: Python<'_>) -> PyResult<()> { |
|
|
|
fn extend(&self, quads: &Bound<'_, PyAny>, py: Python<'_>) -> PyResult<()> { |
|
|
|
let quads = quads |
|
|
|
let quads = quads |
|
|
|
.iter()? |
|
|
|
.iter()? |
|
|
|
.map(|q| q?.extract()) |
|
|
|
.map(|q| q?.extract()) |
|
|
@ -187,7 +187,7 @@ impl PyStore { |
|
|
|
/// >>> list(store)
|
|
|
|
/// >>> list(store)
|
|
|
|
/// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
|
|
|
|
/// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
|
|
|
|
#[cfg(not(target_family = "wasm"))] |
|
|
|
#[cfg(not(target_family = "wasm"))] |
|
|
|
fn bulk_extend(&self, quads: &PyAny) -> PyResult<()> { |
|
|
|
fn bulk_extend(&self, quads: &Bound<'_, PyAny>) -> PyResult<()> { |
|
|
|
self.inner |
|
|
|
self.inner |
|
|
|
.bulk_loader() |
|
|
|
.bulk_loader() |
|
|
|
.load_ok_quads::<PyErr, PythonOrStorageError>( |
|
|
|
.load_ok_quads::<PyErr, PythonOrStorageError>( |
|
|
@ -234,24 +234,23 @@ impl PyStore { |
|
|
|
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')))
|
|
|
|
/// >>> store.add(Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')))
|
|
|
|
/// >>> list(store.quads_for_pattern(NamedNode('http://example.com'), None, None, None))
|
|
|
|
/// >>> list(store.quads_for_pattern(NamedNode('http://example.com'), None, None, None))
|
|
|
|
/// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
|
|
|
|
/// [<Quad subject=<NamedNode value=http://example.com> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
|
|
|
|
|
|
|
|
#[allow(clippy::needless_pass_by_value)] |
|
|
|
#[pyo3(signature = (subject, predicate, object, graph_name = None))] |
|
|
|
#[pyo3(signature = (subject, predicate, object, graph_name = None))] |
|
|
|
fn quads_for_pattern( |
|
|
|
fn quads_for_pattern( |
|
|
|
&self, |
|
|
|
&self, |
|
|
|
subject: &PyAny, |
|
|
|
subject: Option<PySubjectRef<'_>>, |
|
|
|
predicate: &PyAny, |
|
|
|
predicate: Option<PyNamedNodeRef<'_>>, |
|
|
|
object: &PyAny, |
|
|
|
object: Option<PyTermRef<'_>>, |
|
|
|
graph_name: Option<&PyAny>, |
|
|
|
graph_name: Option<PyGraphNameRef<'_>>, |
|
|
|
) -> PyResult<QuadIter> { |
|
|
|
) -> QuadIter { |
|
|
|
let (subject, predicate, object, graph_name) = |
|
|
|
QuadIter { |
|
|
|
extract_quads_pattern(subject, predicate, object, graph_name)?; |
|
|
|
|
|
|
|
Ok(QuadIter { |
|
|
|
|
|
|
|
inner: self.inner.quads_for_pattern( |
|
|
|
inner: self.inner.quads_for_pattern( |
|
|
|
subject.as_ref().map(Into::into), |
|
|
|
subject.as_ref().map(Into::into), |
|
|
|
predicate.as_ref().map(Into::into), |
|
|
|
predicate.as_ref().map(Into::into), |
|
|
|
object.as_ref().map(Into::into), |
|
|
|
object.as_ref().map(Into::into), |
|
|
|
graph_name.as_ref().map(Into::into), |
|
|
|
graph_name.as_ref().map(Into::into), |
|
|
|
), |
|
|
|
), |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Executes a `SPARQL 1.1 query <https://www.w3.org/TR/sparql11-query/>`_.
|
|
|
|
/// Executes a `SPARQL 1.1 query <https://www.w3.org/TR/sparql11-query/>`_.
|
|
|
@ -297,8 +296,8 @@ impl PyStore { |
|
|
|
query: &str, |
|
|
|
query: &str, |
|
|
|
base_iri: Option<&str>, |
|
|
|
base_iri: Option<&str>, |
|
|
|
use_default_graph_as_union: bool, |
|
|
|
use_default_graph_as_union: bool, |
|
|
|
default_graph: Option<&PyAny>, |
|
|
|
default_graph: Option<&Bound<'_, PyAny>>, |
|
|
|
named_graphs: Option<&PyAny>, |
|
|
|
named_graphs: Option<&Bound<'_, PyAny>>, |
|
|
|
py: Python<'_>, |
|
|
|
py: Python<'_>, |
|
|
|
) -> PyResult<PyObject> { |
|
|
|
) -> PyResult<PyObject> { |
|
|
|
let query = parse_query( |
|
|
|
let query = parse_query( |
|
|
@ -396,6 +395,7 @@ impl PyStore { |
|
|
|
/// >>> store.load(input='<foo> <p> "1" .', format=RdfFormat.TURTLE, base_iri="http://example.com/", to_graph=NamedNode("http://example.com/g"))
|
|
|
|
/// >>> store.load(input='<foo> <p> "1" .', format=RdfFormat.TURTLE, base_iri="http://example.com/", to_graph=NamedNode("http://example.com/g"))
|
|
|
|
/// >>> list(store)
|
|
|
|
/// >>> list(store)
|
|
|
|
/// [<Quad subject=<NamedNode value=http://example.com/foo> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
|
|
|
|
/// [<Quad subject=<NamedNode value=http://example.com/foo> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
|
|
|
|
|
|
|
|
#[allow(clippy::needless_pass_by_value)] |
|
|
|
#[pyo3(signature = (input = None, format = None, *, path = None, base_iri = None, to_graph = None))] |
|
|
|
#[pyo3(signature = (input = None, format = None, *, path = None, base_iri = None, to_graph = None))] |
|
|
|
fn load( |
|
|
|
fn load( |
|
|
|
&self, |
|
|
|
&self, |
|
|
@ -403,14 +403,10 @@ impl PyStore { |
|
|
|
format: Option<PyRdfFormatInput>, |
|
|
|
format: Option<PyRdfFormatInput>, |
|
|
|
path: Option<PathBuf>, |
|
|
|
path: Option<PathBuf>, |
|
|
|
base_iri: Option<&str>, |
|
|
|
base_iri: Option<&str>, |
|
|
|
to_graph: Option<&PyAny>, |
|
|
|
to_graph: Option<PyGraphNameRef<'_>>, |
|
|
|
py: Python<'_>, |
|
|
|
py: Python<'_>, |
|
|
|
) -> PyResult<()> { |
|
|
|
) -> PyResult<()> { |
|
|
|
let to_graph_name = if let Some(graph_name) = to_graph { |
|
|
|
let to_graph_name = to_graph.as_ref().map(GraphNameRef::from); |
|
|
|
Some(GraphName::from(&PyGraphNameRef::try_from(graph_name)?)) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
None |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
let input = PyReadable::from_args(&path, input, py)?; |
|
|
|
let input = PyReadable::from_args(&path, input, py)?; |
|
|
|
let format = lookup_rdf_format(format, path.as_deref())?; |
|
|
|
let format = lookup_rdf_format(format, path.as_deref())?; |
|
|
|
py.allow_threads(|| { |
|
|
|
py.allow_threads(|| { |
|
|
@ -468,6 +464,7 @@ impl PyStore { |
|
|
|
/// >>> store.bulk_load(input=b'<foo> <p> "1" .', format=RdfFormat.TURTLE, base_iri="http://example.com/", to_graph=NamedNode("http://example.com/g"))
|
|
|
|
/// >>> store.bulk_load(input=b'<foo> <p> "1" .', format=RdfFormat.TURTLE, base_iri="http://example.com/", to_graph=NamedNode("http://example.com/g"))
|
|
|
|
/// >>> list(store)
|
|
|
|
/// >>> list(store)
|
|
|
|
/// [<Quad subject=<NamedNode value=http://example.com/foo> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
|
|
|
|
/// [<Quad subject=<NamedNode value=http://example.com/foo> predicate=<NamedNode value=http://example.com/p> object=<Literal value=1 datatype=<NamedNode value=http://www.w3.org/2001/XMLSchema#string>> graph_name=<NamedNode value=http://example.com/g>>]
|
|
|
|
|
|
|
|
#[allow(clippy::needless_pass_by_value)] |
|
|
|
#[pyo3(signature = (input = None, format = None, *, path = None, base_iri = None, to_graph = None))] |
|
|
|
#[pyo3(signature = (input = None, format = None, *, path = None, base_iri = None, to_graph = None))] |
|
|
|
fn bulk_load( |
|
|
|
fn bulk_load( |
|
|
|
&self, |
|
|
|
&self, |
|
|
@ -475,14 +472,10 @@ impl PyStore { |
|
|
|
format: Option<PyRdfFormatInput>, |
|
|
|
format: Option<PyRdfFormatInput>, |
|
|
|
path: Option<PathBuf>, |
|
|
|
path: Option<PathBuf>, |
|
|
|
base_iri: Option<&str>, |
|
|
|
base_iri: Option<&str>, |
|
|
|
to_graph: Option<&PyAny>, |
|
|
|
to_graph: Option<PyGraphNameRef<'_>>, |
|
|
|
py: Python<'_>, |
|
|
|
py: Python<'_>, |
|
|
|
) -> PyResult<()> { |
|
|
|
) -> PyResult<()> { |
|
|
|
let to_graph_name = if let Some(graph_name) = to_graph { |
|
|
|
let to_graph_name = to_graph.as_ref().map(GraphNameRef::from); |
|
|
|
Some(GraphName::from(&PyGraphNameRef::try_from(graph_name)?)) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
None |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
let input = PyReadable::from_args(&path, input, py)?; |
|
|
|
let input = PyReadable::from_args(&path, input, py)?; |
|
|
|
let format = lookup_rdf_format(format, path.as_deref())?; |
|
|
|
let format = lookup_rdf_format(format, path.as_deref())?; |
|
|
|
py.allow_threads(|| { |
|
|
|
py.allow_threads(|| { |
|
|
@ -539,24 +532,21 @@ impl PyStore { |
|
|
|
/// >>> store.dump(output, RdfFormat.TURTLE, from_graph=NamedNode("http://example.com/g"))
|
|
|
|
/// >>> store.dump(output, RdfFormat.TURTLE, from_graph=NamedNode("http://example.com/g"))
|
|
|
|
/// >>> output.getvalue()
|
|
|
|
/// >>> output.getvalue()
|
|
|
|
/// b'<http://example.com> <http://example.com/p> "1" .\n'
|
|
|
|
/// b'<http://example.com> <http://example.com/p> "1" .\n'
|
|
|
|
|
|
|
|
#[allow(clippy::needless_pass_by_value)] |
|
|
|
#[pyo3(signature = (output = None, format = None, *, from_graph = None))] |
|
|
|
#[pyo3(signature = (output = None, format = None, *, from_graph = None))] |
|
|
|
fn dump<'a>( |
|
|
|
fn dump<'py>( |
|
|
|
&self, |
|
|
|
&self, |
|
|
|
output: Option<PyWritableOutput>, |
|
|
|
output: Option<PyWritableOutput>, |
|
|
|
format: Option<PyRdfFormatInput>, |
|
|
|
format: Option<PyRdfFormatInput>, |
|
|
|
from_graph: Option<&PyAny>, |
|
|
|
from_graph: Option<PyGraphNameRef<'_>>, |
|
|
|
py: Python<'a>, |
|
|
|
py: Python<'py>, |
|
|
|
) -> PyResult<Option<&'a PyBytes>> { |
|
|
|
) -> PyResult<Option<Bound<'py, PyBytes>>> { |
|
|
|
let from_graph_name = if let Some(graph_name) = from_graph { |
|
|
|
let from_graph_name = from_graph.as_ref().map(GraphNameRef::from); |
|
|
|
Some(GraphName::from(&PyGraphNameRef::try_from(graph_name)?)) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
None |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
PyWritable::do_write( |
|
|
|
PyWritable::do_write( |
|
|
|
|output, file_path| { |
|
|
|
|output, file_path| { |
|
|
|
py.allow_threads(|| { |
|
|
|
py.allow_threads(|| { |
|
|
|
let format = lookup_rdf_format(format, file_path.as_deref())?; |
|
|
|
let format = lookup_rdf_format(format, file_path.as_deref())?; |
|
|
|
if let Some(from_graph_name) = &from_graph_name { |
|
|
|
if let Some(from_graph_name) = from_graph_name { |
|
|
|
self.inner |
|
|
|
self.inner |
|
|
|
.dump_graph_to_write(from_graph_name, format, output) |
|
|
|
.dump_graph_to_write(from_graph_name, format, output) |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -597,14 +587,21 @@ impl PyStore { |
|
|
|
/// >>> store.add_graph(NamedNode('http://example.com/g'))
|
|
|
|
/// >>> store.add_graph(NamedNode('http://example.com/g'))
|
|
|
|
/// >>> store.contains_named_graph(NamedNode('http://example.com/g'))
|
|
|
|
/// >>> store.contains_named_graph(NamedNode('http://example.com/g'))
|
|
|
|
/// True
|
|
|
|
/// True
|
|
|
|
fn contains_named_graph(&self, graph_name: &PyAny) -> PyResult<bool> { |
|
|
|
#[allow(clippy::needless_pass_by_value)] |
|
|
|
let graph_name = GraphName::from(&PyGraphNameRef::try_from(graph_name)?); |
|
|
|
fn contains_named_graph( |
|
|
|
|
|
|
|
&self, |
|
|
|
|
|
|
|
graph_name: PyGraphNameRef<'_>, |
|
|
|
|
|
|
|
py: Python<'_>, |
|
|
|
|
|
|
|
) -> PyResult<bool> { |
|
|
|
|
|
|
|
let graph_name = GraphNameRef::from(&graph_name); |
|
|
|
|
|
|
|
py.allow_threads(|| { |
|
|
|
match graph_name { |
|
|
|
match graph_name { |
|
|
|
GraphName::DefaultGraph => Ok(true), |
|
|
|
GraphNameRef::DefaultGraph => Ok(true), |
|
|
|
GraphName::NamedNode(graph_name) => self.inner.contains_named_graph(&graph_name), |
|
|
|
GraphNameRef::NamedNode(graph_name) => self.inner.contains_named_graph(graph_name), |
|
|
|
GraphName::BlankNode(graph_name) => self.inner.contains_named_graph(&graph_name), |
|
|
|
GraphNameRef::BlankNode(graph_name) => self.inner.contains_named_graph(graph_name), |
|
|
|
} |
|
|
|
} |
|
|
|
.map_err(map_storage_error) |
|
|
|
.map_err(map_storage_error) |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Adds a named graph to the store.
|
|
|
|
/// Adds a named graph to the store.
|
|
|
@ -618,16 +615,17 @@ impl PyStore { |
|
|
|
/// >>> store.add_graph(NamedNode('http://example.com/g'))
|
|
|
|
/// >>> store.add_graph(NamedNode('http://example.com/g'))
|
|
|
|
/// >>> list(store.named_graphs())
|
|
|
|
/// >>> list(store.named_graphs())
|
|
|
|
/// [<NamedNode value=http://example.com/g>]
|
|
|
|
/// [<NamedNode value=http://example.com/g>]
|
|
|
|
fn add_graph(&self, graph_name: &PyAny, py: Python<'_>) -> PyResult<()> { |
|
|
|
#[allow(clippy::needless_pass_by_value)] |
|
|
|
let graph_name = GraphName::from(&PyGraphNameRef::try_from(graph_name)?); |
|
|
|
fn add_graph(&self, graph_name: PyGraphNameRef<'_>, py: Python<'_>) -> PyResult<()> { |
|
|
|
|
|
|
|
let graph_name = GraphNameRef::from(&graph_name); |
|
|
|
py.allow_threads(|| { |
|
|
|
py.allow_threads(|| { |
|
|
|
match graph_name { |
|
|
|
match graph_name { |
|
|
|
GraphName::DefaultGraph => Ok(()), |
|
|
|
GraphNameRef::DefaultGraph => Ok(()), |
|
|
|
GraphName::NamedNode(graph_name) => { |
|
|
|
GraphNameRef::NamedNode(graph_name) => { |
|
|
|
self.inner.insert_named_graph(&graph_name).map(|_| ()) |
|
|
|
self.inner.insert_named_graph(graph_name).map(|_| ()) |
|
|
|
} |
|
|
|
} |
|
|
|
GraphName::BlankNode(graph_name) => { |
|
|
|
GraphNameRef::BlankNode(graph_name) => { |
|
|
|
self.inner.insert_named_graph(&graph_name).map(|_| ()) |
|
|
|
self.inner.insert_named_graph(graph_name).map(|_| ()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.map_err(map_storage_error) |
|
|
|
.map_err(map_storage_error) |
|
|
@ -648,11 +646,12 @@ impl PyStore { |
|
|
|
/// []
|
|
|
|
/// []
|
|
|
|
/// >>> list(store.named_graphs())
|
|
|
|
/// >>> list(store.named_graphs())
|
|
|
|
/// [<NamedNode value=http://example.com/g>]
|
|
|
|
/// [<NamedNode value=http://example.com/g>]
|
|
|
|
fn clear_graph(&self, graph_name: &PyAny, py: Python<'_>) -> PyResult<()> { |
|
|
|
#[allow(clippy::needless_pass_by_value)] |
|
|
|
let graph_name = GraphName::from(&PyGraphNameRef::try_from(graph_name)?); |
|
|
|
fn clear_graph(&self, graph_name: PyGraphNameRef<'_>, py: Python<'_>) -> PyResult<()> { |
|
|
|
|
|
|
|
let graph_name = GraphNameRef::from(&graph_name); |
|
|
|
py.allow_threads(|| { |
|
|
|
py.allow_threads(|| { |
|
|
|
self.inner |
|
|
|
self.inner |
|
|
|
.clear_graph(&graph_name) |
|
|
|
.clear_graph(graph_name) |
|
|
|
.map_err(map_storage_error) |
|
|
|
.map_err(map_storage_error) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -671,16 +670,17 @@ impl PyStore { |
|
|
|
/// >>> store.remove_graph(NamedNode('http://example.com/g'))
|
|
|
|
/// >>> store.remove_graph(NamedNode('http://example.com/g'))
|
|
|
|
/// >>> list(store.named_graphs())
|
|
|
|
/// >>> list(store.named_graphs())
|
|
|
|
/// []
|
|
|
|
/// []
|
|
|
|
fn remove_graph(&self, graph_name: &PyAny, py: Python<'_>) -> PyResult<()> { |
|
|
|
#[allow(clippy::needless_pass_by_value)] |
|
|
|
let graph_name = GraphName::from(&PyGraphNameRef::try_from(graph_name)?); |
|
|
|
fn remove_graph(&self, graph_name: PyGraphNameRef<'_>, py: Python<'_>) -> PyResult<()> { |
|
|
|
|
|
|
|
let graph_name = GraphNameRef::from(&graph_name); |
|
|
|
py.allow_threads(|| { |
|
|
|
py.allow_threads(|| { |
|
|
|
match graph_name { |
|
|
|
match graph_name { |
|
|
|
GraphName::DefaultGraph => self.inner.clear_graph(GraphNameRef::DefaultGraph), |
|
|
|
GraphNameRef::DefaultGraph => self.inner.clear_graph(GraphNameRef::DefaultGraph), |
|
|
|
GraphName::NamedNode(graph_name) => { |
|
|
|
GraphNameRef::NamedNode(graph_name) => { |
|
|
|
self.inner.remove_named_graph(&graph_name).map(|_| ()) |
|
|
|
self.inner.remove_named_graph(graph_name).map(|_| ()) |
|
|
|
} |
|
|
|
} |
|
|
|
GraphName::BlankNode(graph_name) => { |
|
|
|
GraphNameRef::BlankNode(graph_name) => { |
|
|
|
self.inner.remove_named_graph(&graph_name).map(|_| ()) |
|
|
|
self.inner.remove_named_graph(graph_name).map(|_| ()) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.map_err(map_storage_error) |
|
|
|
.map_err(map_storage_error) |
|
|
@ -816,45 +816,6 @@ impl GraphNameIter { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
pub fn extract_quads_pattern<'a>( |
|
|
|
|
|
|
|
subject: &'a PyAny, |
|
|
|
|
|
|
|
predicate: &'a PyAny, |
|
|
|
|
|
|
|
object: &'a PyAny, |
|
|
|
|
|
|
|
graph_name: Option<&'a PyAny>, |
|
|
|
|
|
|
|
) -> PyResult<( |
|
|
|
|
|
|
|
Option<PySubjectRef<'a>>, |
|
|
|
|
|
|
|
Option<PyNamedNodeRef<'a>>, |
|
|
|
|
|
|
|
Option<PyTermRef<'a>>, |
|
|
|
|
|
|
|
Option<PyGraphNameRef<'a>>, |
|
|
|
|
|
|
|
)> { |
|
|
|
|
|
|
|
Ok(( |
|
|
|
|
|
|
|
if subject.is_none() { |
|
|
|
|
|
|
|
None |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Some(TryFrom::try_from(subject)?) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
if predicate.is_none() { |
|
|
|
|
|
|
|
None |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Some(TryFrom::try_from(predicate)?) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
if object.is_none() { |
|
|
|
|
|
|
|
None |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Some(TryFrom::try_from(object)?) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
if let Some(graph_name) = graph_name { |
|
|
|
|
|
|
|
if graph_name.is_none() { |
|
|
|
|
|
|
|
None |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Some(TryFrom::try_from(graph_name)?) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
None |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn map_storage_error(error: StorageError) -> PyErr { |
|
|
|
pub fn map_storage_error(error: StorageError) -> PyErr { |
|
|
|
match error { |
|
|
|
match error { |
|
|
|
StorageError::Io(error) => error.into(), |
|
|
|
StorageError::Io(error) => error.into(), |
|
|
|