Moves sophia implementations into model and store packages

pull/51/head
Tpt 4 years ago
parent 0e3d37cb25
commit 44c216c348
  1. 12
      lib/src/lib.rs
  2. 2
      lib/src/model/mod.rs
  3. 6
      lib/src/model/sophia.rs
  4. 2
      lib/src/store/mod.rs
  5. 33
      lib/src/store/sophia.rs

@ -14,6 +14,8 @@
//!
//! Oxigraph also provides a set of utility functions for reading, writing and processing RDF files.
//!
//! The disabled by default `"sophia"` feature provides [`sophia_api`](https://docs.rs/sophia_api/) traits implemention on Oxigraph terms and stores.
//!
//! Usage example with the [`MemoryStore`](store/memory/struct.MemoryStore.html):
//!
//! ```
@ -118,13 +120,3 @@ pub use crate::store::memory::MemoryStore;
pub use crate::store::rocksdb::RocksDbStore;
#[cfg(feature = "sled")]
pub use crate::store::sled::SledStore;
#[cfg(feature = "sophia")]
/// Provides implementation of [Sophia] traits for Oxigraph types,
/// if the `sophia` feature is enabled.
///
/// [Sophia]: https://docs.rs/sophia/latest/sophia/
mod sophia {
mod model;
mod store;
}

@ -5,6 +5,8 @@
mod blank_node;
mod literal;
mod named_node;
#[cfg(feature = "sophia")]
mod sophia;
mod triple;
pub mod vocab;
pub(crate) mod xsd;

@ -393,16 +393,16 @@ impl<'a> From<TripleRef<'a>> for [TermRef<'a>; 3] {
}
}
/// Error raised when trying to conpy a [Sophia]
/// Error raised when trying to copy a [Sophia](https://docs.rs/sophia/)
/// term as an incompatible Oxigraph term
/// (e.g. a literal into `NamedNode`).
///
/// [Sophia]: https://docs.rs/sophia/latest/sophia/
#[derive(Clone, Copy, Debug)]
pub struct SophiaToOxigraphConversionError;
impl fmt::Display for SophiaToOxigraphConversionError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?}", self)
}
}
impl std::error::Error for SophiaToOxigraphConversionError {}

@ -9,6 +9,8 @@ pub mod rocksdb;
#[cfg(feature = "sled")]
pub mod sled;
pub(crate) mod small_string;
#[cfg(feature = "sophia")]
mod sophia;
pub use crate::store::memory::MemoryStore;
#[cfg(feature = "rocksdb")]

@ -22,23 +22,20 @@ type StreamedSophiaQuad<'a> = StreamedQuad<'a, ByValue<SophiaQuad>>;
/// + the query must be a SELECT query with a single selected variable
/// + it must not produce NULL results
macro_rules! sparql_to_hashset {
($store: ident, $err_map: ident, $sparql: expr) => {
//sparql_result_as_term_set($store, $sparql).map_err($err_map)
{
(|| -> Result<HashSet<Term>, EvaluationError> {
let q = $store.prepare_query($sparql, QueryOptions::default())?;
let r = q.exec()?;
if let QueryResults::Solutions(solutions) = r {
solutions
.map(|r| r.map(|v| v.get(0).unwrap().clone()))
.collect()
} else {
unreachable!()
}
})()
.map_err($err_map)
}
};
($store: ident, $err_map: ident, $sparql: expr) => {{
(|| -> Result<HashSet<Term>, EvaluationError> {
if let QueryResults::Solutions(solutions) =
$store.query($sparql, QueryOptions::default())?
{
solutions
.map(|r| r.map(|v| v.get(0).unwrap().clone()))
.collect()
} else {
unreachable!()
}
})()
.map_err($err_map)
}};
}
macro_rules! impl_dataset {
@ -418,7 +415,7 @@ macro_rules! impl_dataset {
};
}
mod mem {
mod memory {
use super::*;
impl_dataset!(
Loading…
Cancel
Save