pchampin / sophia_rs

Sophia: a Rust toolkit for RDF and Linked Data
Other
214 stars 23 forks source link

Change `Term::batch_join` into something more usable #50

Closed pchampin closed 4 years ago

pchampin commented 4 years ago

Currently, there are two ways to resolve (possibly relative) terms agains a base IRI:

The rationale for this design is that joining requires the structure of the base IRI to be parsed, and we do not store that structure in IRI Terms (to save space -- not all IRIs in a graph are expected to be used as base IRIs). batch_join allows to perform the parsing only once, and resolve multiple terms in a row.

A possibly better design would be to have a dedicated type, storing the parsed structure of an IRI, and providing methods to resove terms (and why not, whold triples, quads, or even graphs and datasets?). Term::batch_join would then be replaced by a Term::to_base method, returning such an object. This would allow for this kind of pattern:

let base = some_iri_term.to_base();
let abs_triples = some_triple_source.map_triples(|t| base.join_triple(&t));
MattesWhite commented 4 years ago

Isn't this issue solved due to the Resolve-trait?

pchampin commented 4 years ago

Absolutely! :tada: