diff --git a/Cargo.toml b/Cargo.toml index a26b221..0264f1e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "hdt" -version = "0.2.1" +version = "0.2.2" repository = "https://github.com/konradhoeffner/hdt" authors = ["Tim Baccaert ", "Konrad Höffner"] license = "MIT" @@ -18,11 +18,11 @@ crc = "3" iref = "3" langtag = "0.4" ntriple = "0.1" -sophia = { version = "0.8.0", optional = true } +sophia = { version = "0.9", optional = true } sucds = "0.8" thiserror = "2" log = "0.4" -mownstr = "0.2" +mownstr = "0.3" lazy_static = "1" eyre = "0.6" diff --git a/src/hdt_graph.rs b/src/hdt_graph.rs index 3bb5b1e..064ecb1 100644 --- a/src/hdt_graph.rs +++ b/src/hdt_graph.rs @@ -4,7 +4,7 @@ use crate::four_sect_dict::IdKind; use crate::hdt::Hdt; use crate::triples::{Id, ObjectIter, PredicateIter, PredicateObjectIter, SubjectIter, TripleId}; use log::debug; -use sophia::api::graph::{GTripleSource, Graph}; +use sophia::api::graph::Graph; use sophia::api::term::{matcher::TermMatcher, BnodeId, IriRef, LanguageTag, Term}; use std::convert::Infallible; use std::io::{self, Error, ErrorKind}; @@ -134,11 +134,11 @@ impl Graph for HdtGraph { /// println!("{:?}", graph.triples().next().expect("no triple in the graph")); /// } /// ``` - fn triples(&self) -> GTripleSource { + fn triples(&self) -> impl Iterator, Self::Error>> { debug!("Iterating through ALL triples in the HDT Graph. This can be inefficient for large graphs."); - Box::new(self.hdt.triples().map(move |(s, p, o)| { + self.hdt.triples().map(move |(s, p, o)| { Ok([auto_term(&s).unwrap(), HdtTerm::Iri(IriRef::new_unchecked(p)), auto_term(&o).unwrap()]) - })) + }) } /// Only supports constant and "any" matchers. @@ -156,7 +156,8 @@ impl Graph for HdtGraph { /// let persons = dbpedia.triples_matching(Any, Some(birth_place), Some(leipzig)); /// } /// ``` - fn triples_matching<'s, S, P, O>(&'s self, sm: S, pm: P, om: O) -> GTripleSource<'s, Self> + #[allow(refining_impl_trait)] + fn triples_matching<'s, S, P, O>(&'s self, sm: S, pm: P, om: O) -> Box, Self::Error>> + 's> where S: TermMatcher + 's, P: TermMatcher + 's, diff --git a/src/hdt_graph/term.rs b/src/hdt_graph/term.rs index 37bdedd..e611e15 100644 --- a/src/hdt_graph/term.rs +++ b/src/hdt_graph/term.rs @@ -65,14 +65,14 @@ impl Term for HdtTerm { fn iri(&self) -> Option> { match self { - HdtTerm::Iri(iri) => Some(iri.as_ref().map_unchecked(MownStr::from_str)), + HdtTerm::Iri(iri) => Some(iri.as_ref().map_unchecked(MownStr::from_ref)), _ => None, } } fn bnode_id(&self) -> Option> { match self { - HdtTerm::BlankNode(bnid) => Some(bnid.as_ref().map_unchecked(MownStr::from_str)), + HdtTerm::BlankNode(bnid) => Some(bnid.as_ref().map_unchecked(MownStr::from_ref)), _ => None, } } @@ -86,7 +86,7 @@ impl Term for HdtTerm { fn datatype(&self) -> Option> { match self { - HdtTerm::LiteralDatatype(_, datatype) => Some(datatype.as_ref().map_unchecked(MownStr::from_str)), + HdtTerm::LiteralDatatype(_, datatype) => Some(datatype.as_ref().map_unchecked(MownStr::from_ref)), HdtTerm::LiteralLanguage(..) => rdf::langString.iri(), _ => None, } @@ -94,7 +94,7 @@ impl Term for HdtTerm { fn language_tag(&self) -> Option> { match self { - HdtTerm::LiteralLanguage(_, tag) => Some(tag.as_ref().map_unchecked(MownStr::from_str)), + HdtTerm::LiteralLanguage(_, tag) => Some(tag.as_ref().map_unchecked(MownStr::from_ref)), _ => None, } }