Renames NamedOrBlankNode to Subject

Preparatory work for RDF-star addition
pull/171/head
Tpt 4 years ago
parent bc27a298fa
commit 8004fc28c0
  1. 6
      lib/src/io/read.rs
  2. 175
      lib/src/model/dataset.rs
  3. 18
      lib/src/model/graph.rs
  4. 22
      lib/src/model/interning.rs
  5. 3
      lib/src/model/mod.rs
  6. 18
      lib/src/model/sophia.rs
  7. 132
      lib/src/model/triple.rs
  8. 5
      lib/src/sophia.rs
  9. 6
      lib/src/sparql/algebra.rs
  10. 6
      lib/src/sparql/dataset.rs
  11. 2
      lib/src/sparql/eval.rs
  12. 10
      lib/src/sparql/update.rs
  13. 38
      lib/src/storage/numeric_encoder.rs
  14. 40
      lib/src/store.rs
  15. 2
      lib/tests/store.rs
  16. 50
      python/src/model.rs
  17. 2
      python/src/sparql.rs
  18. 12
      python/src/store.rs
  19. 6
      server/src/main.rs
  20. 22
      spargebra/src/term.rs
  21. 9
      testsuite/src/manifest.rs
  22. 2
      testsuite/src/sparql_evaluator.rs
  23. 4
      wikibase/src/main.rs

@ -330,7 +330,7 @@ impl<'a> RioMapper {
}
}
fn named_or_blank_node(&mut self, node: rio::NamedOrBlankNode<'a>) -> NamedOrBlankNode {
fn subject(&mut self, node: rio::NamedOrBlankNode<'a>) -> Subject {
match node {
rio::NamedOrBlankNode::NamedNode(node) => self.named_node(node).into(),
rio::NamedOrBlankNode::BlankNode(node) => self.blank_node(node).into(),
@ -347,7 +347,7 @@ impl<'a> RioMapper {
fn triple(&mut self, triple: &rio::Triple<'a>) -> Triple {
Triple {
subject: self.named_or_blank_node(triple.subject),
subject: self.subject(triple.subject),
predicate: self.named_node(triple.predicate),
object: self.term(triple.object),
}
@ -363,7 +363,7 @@ impl<'a> RioMapper {
fn quad(&mut self, quad: &rio::Quad<'a>) -> Quad {
Quad {
subject: self.named_or_blank_node(quad.subject),
subject: self.subject(quad.subject),
predicate: self.named_node(quad.predicate),
object: self.term(quad.object),
graph_name: self.graph_name(quad.graph_name),

@ -27,7 +27,7 @@ use crate::io::{
DatasetFormat, DatasetParser, DatasetSerializer, GraphFormat, GraphParser, GraphSerializer,
};
use crate::model::interning::*;
use crate::model::NamedOrBlankNodeRef;
use crate::model::SubjectRef;
use crate::model::*;
use lasso::Rodeo;
use std::collections::hash_map::DefaultHasher;
@ -69,7 +69,7 @@ pub struct Dataset {
interner: Rodeo,
gspo: BTreeSet<(
InternedGraphName,
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
)>,
@ -77,16 +77,16 @@ pub struct Dataset {
InternedGraphName,
InternedNamedNode,
InternedTerm,
InternedNamedOrBlankNode,
InternedSubject,
)>,
gosp: BTreeSet<(
InternedGraphName,
InternedTerm,
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
)>,
spog: BTreeSet<(
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
@ -94,12 +94,12 @@ pub struct Dataset {
posg: BTreeSet<(
InternedNamedNode,
InternedTerm,
InternedNamedOrBlankNode,
InternedSubject,
InternedGraphName,
)>,
ospg: BTreeSet<(
InternedTerm,
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedGraphName,
)>,
@ -177,21 +177,21 @@ impl Dataset {
pub fn quads_for_subject<'a, 'b>(
&'a self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
) -> impl Iterator<Item = QuadRef<'a>> + 'a {
let subject = self
.encoded_named_or_blank_node(subject)
.unwrap_or_else(InternedNamedOrBlankNode::impossible);
.encoded_subject(subject)
.unwrap_or_else(InternedSubject::impossible);
self.interned_quads_for_subject(subject)
.map(move |q| self.decode_spog(q))
}
fn interned_quads_for_subject(
&self,
subject: InternedNamedOrBlankNode,
subject: InternedSubject,
) -> impl Iterator<
Item = (
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
@ -231,7 +231,7 @@ impl Dataset {
predicate: InternedNamedNode,
) -> impl Iterator<
Item = (
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
@ -242,13 +242,13 @@ impl Dataset {
&(
predicate,
InternedTerm::first(),
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
InternedGraphName::first(),
)
..&(
predicate.next(),
InternedTerm::first(),
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
InternedGraphName::first(),
),
)
@ -273,7 +273,7 @@ impl Dataset {
object: InternedTerm,
) -> impl Iterator<
Item = (
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
@ -283,13 +283,13 @@ impl Dataset {
.range(
&(
object,
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
InternedNamedNode::first(),
InternedGraphName::first(),
)
..&(
object.next(),
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
InternedNamedNode::first(),
InternedGraphName::first(),
),
@ -303,7 +303,7 @@ impl Dataset {
graph_name: InternedGraphName,
) -> impl Iterator<
Item = (
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
@ -313,13 +313,13 @@ impl Dataset {
.range(
&(
graph_name,
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
InternedNamedNode::first(),
InternedTerm::first(),
)
..&(
graph_name.next(),
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
InternedNamedNode::first(),
InternedTerm::first(),
),
@ -356,7 +356,7 @@ impl Dataset {
fn insert_encoded(
&mut self,
quad: (
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
@ -383,7 +383,7 @@ impl Dataset {
fn remove_encoded(
&mut self,
quad: (
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
@ -483,13 +483,13 @@ impl Dataset {
&mut self,
quad: QuadRef<'_>,
) -> (
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
) {
(
InternedNamedOrBlankNode::encoded_into(quad.subject, &mut self.interner),
InternedSubject::encoded_into(quad.subject, &mut self.interner),
InternedNamedNode::encoded_into(quad.predicate, &mut self.interner),
InternedTerm::encoded_into(quad.object, &mut self.interner),
InternedGraphName::encoded_into(quad.graph_name, &mut self.interner),
@ -500,13 +500,13 @@ impl Dataset {
&self,
quad: QuadRef<'_>,
) -> Option<(
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
)> {
Some((
self.encoded_named_or_blank_node(quad.subject)?,
self.encoded_subject(quad.subject)?,
self.encoded_named_node(quad.predicate)?,
self.encoded_term(quad.object)?,
self.encoded_graph_name(quad.graph_name)?,
@ -520,11 +520,11 @@ impl Dataset {
InternedNamedNode::encoded_from(node.into(), &self.interner)
}
pub(super) fn encoded_named_or_blank_node<'a>(
pub(super) fn encoded_subject<'a>(
&self,
node: impl Into<NamedOrBlankNodeRef<'a>>,
) -> Option<InternedNamedOrBlankNode> {
InternedNamedOrBlankNode::encoded_from(node.into(), &self.interner)
node: impl Into<SubjectRef<'a>>,
) -> Option<InternedSubject> {
InternedSubject::encoded_from(node.into(), &self.interner)
}
pub(super) fn encoded_term<'a>(&self, term: impl Into<TermRef<'a>>) -> Option<InternedTerm> {
@ -541,7 +541,7 @@ impl Dataset {
fn decode_spog(
&self,
quad: (
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
@ -597,7 +597,7 @@ impl Dataset {
fn blank_nodes(&self) -> HashSet<InternedBlankNode> {
let mut bnodes = HashSet::new();
for (g, s, _, o) in &self.gspo {
if let InternedNamedOrBlankNode::BlankNode(bnode) = s {
if let InternedSubject::BlankNode(bnode) = s {
bnodes.insert(*bnode);
}
if let InternedTerm::BlankNode(bnode) = o {
@ -625,7 +625,7 @@ impl Dataset {
let mut new_hashes = HashMap::new();
for (bnode, old_hash) in &hashes {
for (_, p, o, g) in
self.interned_quads_for_subject(InternedNamedOrBlankNode::BlankNode(*bnode))
self.interned_quads_for_subject(InternedSubject::BlankNode(*bnode))
{
to_hash.push((
self.hash_named_node(p),
@ -637,7 +637,7 @@ impl Dataset {
for (s, p, _, g) in self.interned_quads_for_object(InternedTerm::BlankNode(*bnode))
{
to_hash.push((
self.hash_named_or_blank_node(s, &hashes),
self.hash_subject(s, &hashes),
self.hash_named_node(p),
self.hash_graph_name(g, &hashes),
1,
@ -647,7 +647,7 @@ impl Dataset {
self.interned_quads_for_graph_name(InternedGraphName::BlankNode(*bnode))
{
to_hash.push((
self.hash_named_or_blank_node(s, &hashes),
self.hash_subject(s, &hashes),
self.hash_named_node(p),
self.hash_term(o, &hashes),
2,
@ -674,12 +674,12 @@ impl Dataset {
self.hash_tuple(node.decode_from(&self.interner))
}
fn hash_named_or_blank_node(
fn hash_subject(
&self,
node: InternedNamedOrBlankNode,
node: InternedSubject,
bnodes_hash: &HashMap<InternedBlankNode, u64>,
) -> u64 {
if let InternedNamedOrBlankNode::BlankNode(bnode) = node {
if let InternedSubject::BlankNode(bnode) = node {
*bnodes_hash.get(&bnode).unwrap()
} else {
self.hash_tuple(node.decode_from(&self.interner))
@ -717,7 +717,7 @@ impl Dataset {
hash: &HashMap<InternedBlankNode, u64>,
partition: &[(u64, Vec<InternedBlankNode>)],
) -> Vec<(
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
@ -755,7 +755,7 @@ impl Dataset {
&mut self,
hashes: &HashMap<InternedBlankNode, u64>,
) -> Vec<(
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
@ -765,8 +765,8 @@ impl Dataset {
.into_iter()
.map(|(s, p, o, g)| {
(
if let InternedNamedOrBlankNode::BlankNode(bnode) = s {
InternedNamedOrBlankNode::BlankNode(self.map_bnode(bnode, hashes))
if let InternedSubject::BlankNode(bnode) = s {
InternedSubject::BlankNode(self.map_bnode(bnode, hashes))
} else {
s
},
@ -894,13 +894,13 @@ impl<'a> GraphView<'a> {
let iter = self.dataset.gspo.range(
&(
self.graph_name,
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
InternedNamedNode::first(),
InternedTerm::first(),
)
..&(
self.graph_name.next(),
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
InternedNamedNode::first(),
InternedTerm::first(),
),
@ -913,16 +913,16 @@ impl<'a> GraphView<'a> {
pub fn triples_for_subject<'b>(
self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
) -> impl Iterator<Item = TripleRef<'a>> + 'a {
self.triples_for_interned_subject(self.dataset.encoded_named_or_blank_node(subject))
self.triples_for_interned_subject(self.dataset.encoded_subject(subject))
}
pub(super) fn triples_for_interned_subject(
self,
subject: Option<InternedNamedOrBlankNode>,
subject: Option<InternedSubject>,
) -> impl Iterator<Item = TripleRef<'a>> + 'a {
let subject = subject.unwrap_or_else(InternedNamedOrBlankNode::impossible);
let subject = subject.unwrap_or_else(InternedSubject::impossible);
self.dataset
.gspo
.range(
@ -944,21 +944,21 @@ impl<'a> GraphView<'a> {
pub fn objects_for_subject_predicate<'b>(
self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
predicate: impl Into<NamedNodeRef<'b>>,
) -> impl Iterator<Item = TermRef<'a>> + 'a {
self.objects_for_interned_subject_predicate(
self.dataset.encoded_named_or_blank_node(subject),
self.dataset.encoded_subject(subject),
self.dataset.encoded_named_node(predicate),
)
}
pub fn objects_for_interned_subject_predicate(
self,
subject: Option<InternedNamedOrBlankNode>,
subject: Option<InternedSubject>,
predicate: Option<InternedNamedNode>,
) -> impl Iterator<Item = TermRef<'a>> + 'a {
let subject = subject.unwrap_or_else(InternedNamedOrBlankNode::impossible);
let subject = subject.unwrap_or_else(InternedSubject::impossible);
let predicate = predicate.unwrap_or_else(InternedNamedNode::impossible);
self.dataset
.gspo
@ -976,7 +976,7 @@ impl<'a> GraphView<'a> {
pub fn object_for_subject_predicate<'b>(
self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
predicate: impl Into<NamedNodeRef<'b>>,
) -> Option<TermRef<'a>> {
self.objects_for_subject_predicate(subject, predicate)
@ -985,21 +985,21 @@ impl<'a> GraphView<'a> {
pub fn predicates_for_subject_object<'b>(
self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
object: impl Into<TermRef<'b>>,
) -> impl Iterator<Item = NamedNodeRef<'a>> + 'a {
self.predicates_for_interned_subject_object(
self.dataset.encoded_named_or_blank_node(subject),
self.dataset.encoded_subject(subject),
self.dataset.encoded_term(object),
)
}
pub(super) fn predicates_for_interned_subject_object(
self,
subject: Option<InternedNamedOrBlankNode>,
subject: Option<InternedSubject>,
object: Option<InternedTerm>,
) -> impl Iterator<Item = NamedNodeRef<'a>> + 'a {
let subject = subject.unwrap_or_else(InternedNamedOrBlankNode::impossible);
let subject = subject.unwrap_or_else(InternedSubject::impossible);
let object = object.unwrap_or_else(InternedTerm::impossible);
self.dataset
.gosp
@ -1034,13 +1034,13 @@ impl<'a> GraphView<'a> {
self.graph_name,
predicate,
InternedTerm::first(),
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
)
..&(
self.graph_name,
predicate.next(),
InternedTerm::first(),
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
),
)
.map(move |q| self.decode_gpos(*q))
@ -1050,7 +1050,7 @@ impl<'a> GraphView<'a> {
self,
predicate: impl Into<NamedNodeRef<'b>>,
object: impl Into<TermRef<'b>>,
) -> impl Iterator<Item = NamedOrBlankNodeRef<'a>> + 'a {
) -> impl Iterator<Item = SubjectRef<'a>> + 'a {
self.subjects_for_interned_predicate_object(
self.dataset.encoded_named_node(predicate),
self.dataset.encoded_term(object),
@ -1061,23 +1061,18 @@ impl<'a> GraphView<'a> {
self,
predicate: Option<InternedNamedNode>,
object: Option<InternedTerm>,
) -> impl Iterator<Item = NamedOrBlankNodeRef<'a>> + 'a {
) -> impl Iterator<Item = SubjectRef<'a>> + 'a {
let predicate = predicate.unwrap_or_else(InternedNamedNode::impossible);
let object = object.unwrap_or_else(InternedTerm::impossible);
self.dataset
.gpos
.range(
&(
self.graph_name,
predicate,
object,
InternedNamedOrBlankNode::first(),
)
&(self.graph_name, predicate, object, InternedSubject::first())
..&(
self.graph_name,
predicate,
object.next(),
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
),
)
.map(move |q| q.3.decode_from(&self.dataset.interner))
@ -1087,7 +1082,7 @@ impl<'a> GraphView<'a> {
self,
predicate: impl Into<NamedNodeRef<'b>>,
object: impl Into<TermRef<'b>>,
) -> Option<NamedOrBlankNodeRef<'a>> {
) -> Option<SubjectRef<'a>> {
self.subjects_for_predicate_object(predicate, object).next()
}
@ -1109,13 +1104,13 @@ impl<'a> GraphView<'a> {
&(
self.graph_name,
object,
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
InternedNamedNode::first(),
)
..&(
self.graph_name,
object.next(),
InternedNamedOrBlankNode::first(),
InternedSubject::first(),
InternedNamedNode::first(),
),
)
@ -1169,9 +1164,9 @@ impl<'a> GraphView<'a> {
fn encoded_triple(
&self,
triple: TripleRef<'_>,
) -> Option<(InternedNamedOrBlankNode, InternedNamedNode, InternedTerm)> {
) -> Option<(InternedSubject, InternedNamedNode, InternedTerm)> {
Some((
self.dataset.encoded_named_or_blank_node(triple.subject)?,
self.dataset.encoded_subject(triple.subject)?,
self.dataset.encoded_named_node(triple.predicate)?,
self.dataset.encoded_term(triple.object)?,
))
@ -1181,7 +1176,7 @@ impl<'a> GraphView<'a> {
self,
quad: (
InternedGraphName,
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
),
@ -1199,7 +1194,7 @@ impl<'a> GraphView<'a> {
InternedGraphName,
InternedNamedNode,
InternedTerm,
InternedNamedOrBlankNode,
InternedSubject,
),
) -> TripleRef<'a> {
self.decode_gspo((quad.0, quad.3, quad.1, quad.2))
@ -1210,7 +1205,7 @@ impl<'a> GraphView<'a> {
quad: (
InternedGraphName,
InternedTerm,
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
),
) -> TripleRef<'a> {
@ -1344,9 +1339,9 @@ impl<'a> GraphViewMut<'a> {
fn encode_triple(
&mut self,
triple: TripleRef<'_>,
) -> (InternedNamedOrBlankNode, InternedNamedNode, InternedTerm) {
) -> (InternedSubject, InternedNamedNode, InternedTerm) {
(
InternedNamedOrBlankNode::encoded_into(triple.subject, &mut self.dataset.interner),
InternedSubject::encoded_into(triple.subject, &mut self.dataset.interner),
InternedNamedNode::encoded_into(triple.predicate, &mut self.dataset.interner),
InternedTerm::encoded_into(triple.object, &mut self.dataset.interner),
)
@ -1359,26 +1354,26 @@ impl<'a> GraphViewMut<'a> {
pub fn triples_for_subject<'b>(
&'a self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
) -> impl Iterator<Item = TripleRef<'a>> + 'a {
self.read()
.triples_for_interned_subject(self.dataset.encoded_named_or_blank_node(subject))
.triples_for_interned_subject(self.dataset.encoded_subject(subject))
}
pub fn objects_for_subject_predicate<'b>(
&'a self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
predicate: impl Into<NamedNodeRef<'b>>,
) -> impl Iterator<Item = TermRef<'a>> + 'a {
self.read().objects_for_interned_subject_predicate(
self.dataset.encoded_named_or_blank_node(subject),
self.dataset.encoded_subject(subject),
self.dataset.encoded_named_node(predicate),
)
}
pub fn object_for_subject_predicate<'b>(
&'a self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
predicate: impl Into<NamedNodeRef<'b>>,
) -> Option<TermRef<'a>> {
self.read().object_for_subject_predicate(subject, predicate)
@ -1386,11 +1381,11 @@ impl<'a> GraphViewMut<'a> {
pub fn predicates_for_subject_object<'b>(
&'a self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
object: impl Into<TermRef<'b>>,
) -> impl Iterator<Item = NamedNodeRef<'a>> + 'a {
self.read().predicates_for_interned_subject_object(
self.dataset.encoded_named_or_blank_node(subject),
self.dataset.encoded_subject(subject),
self.dataset.encoded_term(object),
)
}
@ -1407,7 +1402,7 @@ impl<'a> GraphViewMut<'a> {
&'a self,
predicate: impl Into<NamedNodeRef<'b>>,
object: impl Into<TermRef<'b>>,
) -> impl Iterator<Item = NamedOrBlankNodeRef<'a>> + 'a {
) -> impl Iterator<Item = SubjectRef<'a>> + 'a {
self.read().subjects_for_interned_predicate_object(
self.dataset.encoded_named_node(predicate),
self.dataset.encoded_term(object),
@ -1418,7 +1413,7 @@ impl<'a> GraphViewMut<'a> {
&'a self,
predicate: impl Into<NamedNodeRef<'b>>,
object: impl Into<TermRef<'b>>,
) -> Option<NamedOrBlankNodeRef<'a>> {
) -> Option<SubjectRef<'a>> {
self.read().subject_for_predicate_object(predicate, object)
}
@ -1509,7 +1504,7 @@ pub struct Iter<'a> {
inner: std::collections::btree_set::Iter<
'a,
(
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
InternedGraphName,
@ -1532,7 +1527,7 @@ pub struct GraphViewIter<'a> {
'a,
(
InternedGraphName,
InternedNamedOrBlankNode,
InternedSubject,
InternedNamedNode,
InternedTerm,
),

@ -76,26 +76,26 @@ impl Graph {
pub fn triples_for_subject<'a, 'b>(
&'a self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
) -> impl Iterator<Item = TripleRef<'a>> + 'a {
self.graph()
.triples_for_interned_subject(self.dataset.encoded_named_or_blank_node(subject))
.triples_for_interned_subject(self.dataset.encoded_subject(subject))
}
pub fn objects_for_subject_predicate<'a, 'b>(
&'a self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
predicate: impl Into<NamedNodeRef<'b>>,
) -> impl Iterator<Item = TermRef<'a>> + 'a {
self.graph().objects_for_interned_subject_predicate(
self.dataset.encoded_named_or_blank_node(subject),
self.dataset.encoded_subject(subject),
self.dataset.encoded_named_node(predicate),
)
}
pub fn object_for_subject_predicate<'a, 'b>(
&'a self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
predicate: impl Into<NamedNodeRef<'b>>,
) -> Option<TermRef<'a>> {
self.graph()
@ -105,11 +105,11 @@ impl Graph {
pub fn predicates_for_subject_object<'a, 'b>(
&'a self,
subject: impl Into<NamedOrBlankNodeRef<'b>>,
subject: impl Into<SubjectRef<'b>>,
object: impl Into<TermRef<'b>>,
) -> impl Iterator<Item = NamedNodeRef<'a>> + 'a {
self.graph().predicates_for_interned_subject_object(
self.dataset.encoded_named_or_blank_node(subject),
self.dataset.encoded_subject(subject),
self.dataset.encoded_term(object),
)
}
@ -126,7 +126,7 @@ impl Graph {
&'a self,
predicate: impl Into<NamedNodeRef<'b>>,
object: impl Into<TermRef<'b>>,
) -> impl Iterator<Item = NamedOrBlankNodeRef<'a>> + 'a {
) -> impl Iterator<Item = SubjectRef<'a>> + 'a {
self.graph().subjects_for_interned_predicate_object(
self.dataset.encoded_named_node(predicate),
self.dataset.encoded_term(object),
@ -137,7 +137,7 @@ impl Graph {
&'a self,
predicate: impl Into<NamedNodeRef<'b>>,
object: impl Into<TermRef<'b>>,
) -> Option<NamedOrBlankNodeRef<'a>> {
) -> Option<SubjectRef<'a>> {
self.graph().subject_for_predicate_object(predicate, object)
}

@ -166,38 +166,38 @@ impl InternedLiteral {
}
#[derive(Eq, PartialEq, Ord, PartialOrd, Debug, Clone, Copy, Hash)]
pub enum InternedNamedOrBlankNode {
pub enum InternedSubject {
NamedNode(InternedNamedNode),
BlankNode(InternedBlankNode),
}
impl InternedNamedOrBlankNode {
pub fn encoded_into(node: NamedOrBlankNodeRef<'_>, interner: &mut Rodeo) -> Self {
impl InternedSubject {
pub fn encoded_into(node: SubjectRef<'_>, interner: &mut Rodeo) -> Self {
match node {
NamedOrBlankNodeRef::NamedNode(node) => {
SubjectRef::NamedNode(node) => {
Self::NamedNode(InternedNamedNode::encoded_into(node, interner))
}
NamedOrBlankNodeRef::BlankNode(node) => {
SubjectRef::BlankNode(node) => {
Self::BlankNode(InternedBlankNode::encoded_into(node, interner))
}
}
}
pub fn encoded_from(node: NamedOrBlankNodeRef<'_>, interner: &Rodeo) -> Option<Self> {
pub fn encoded_from(node: SubjectRef<'_>, interner: &Rodeo) -> Option<Self> {
Some(match node {
NamedOrBlankNodeRef::NamedNode(node) => {
SubjectRef::NamedNode(node) => {
Self::NamedNode(InternedNamedNode::encoded_from(node, interner)?)
}
NamedOrBlankNodeRef::BlankNode(node) => {
SubjectRef::BlankNode(node) => {
Self::BlankNode(InternedBlankNode::encoded_from(node, interner)?)
}
})
}
pub fn decode_from<'a>(&self, interner: &'a Rodeo) -> NamedOrBlankNodeRef<'a> {
pub fn decode_from<'a>(&self, interner: &'a Rodeo) -> SubjectRef<'a> {
match self {
Self::NamedNode(node) => NamedOrBlankNodeRef::NamedNode(node.decode_from(interner)),
Self::BlankNode(node) => NamedOrBlankNodeRef::BlankNode(node.decode_from(interner)),
Self::NamedNode(node) => SubjectRef::NamedNode(node.decode_from(interner)),
Self::BlankNode(node) => SubjectRef::BlankNode(node.decode_from(interner)),
}
}

@ -22,8 +22,7 @@ pub use self::literal::{Literal, LiteralRef};
pub use self::named_node::{NamedNode, NamedNodeRef};
pub use self::parser::TermParseError;
pub use self::triple::{
GraphName, GraphNameRef, NamedOrBlankNode, NamedOrBlankNodeRef, Quad, QuadRef, Term, TermRef,
Triple, TripleRef,
GraphName, GraphNameRef, Quad, QuadRef, Subject, SubjectRef, Term, TermRef, Triple, TripleRef,
};
pub use oxilangtag::LanguageTagParseError;
pub use oxiri::IriParseError;

@ -189,9 +189,9 @@ impl<'a> From<GraphNameRef<'a>> for Option<TermRef<'a>> {
}
}
impl TTerm for NamedOrBlankNode {
impl TTerm for Subject {
fn kind(&self) -> TermKind {
use NamedOrBlankNode::*;
use Subject::*;
match self {
NamedNode(_) => TermKind::Iri,
BlankNode(_) => TermKind::BlankNode,
@ -199,7 +199,7 @@ impl TTerm for NamedOrBlankNode {
}
fn value_raw(&self) -> RawValue<'_> {
use NamedOrBlankNode::*;
use Subject::*;
match self {
NamedNode(n) => n.value_raw(),
BlankNode(n) => n.value_raw(),
@ -207,7 +207,7 @@ impl TTerm for NamedOrBlankNode {
}
fn as_dyn(&self) -> &dyn TTerm {
use NamedOrBlankNode::*;
use Subject::*;
match self {
NamedNode(n) => n.as_dyn(),
BlankNode(n) => n.as_dyn(),
@ -215,7 +215,7 @@ impl TTerm for NamedOrBlankNode {
}
}
impl TryCopyTerm for NamedOrBlankNode {
impl TryCopyTerm for Subject {
type Error = SophiaToOxigraphConversionError;
fn try_copy<T>(other: &T) -> Result<Self, Self::Error>
@ -230,9 +230,9 @@ impl TryCopyTerm for NamedOrBlankNode {
}
}
impl<'a> TTerm for NamedOrBlankNodeRef<'a> {
impl<'a> TTerm for SubjectRef<'a> {
fn kind(&self) -> TermKind {
use NamedOrBlankNodeRef::*;
use SubjectRef::*;
match self {
NamedNode(_) => TermKind::Iri,
BlankNode(_) => TermKind::BlankNode,
@ -240,7 +240,7 @@ impl<'a> TTerm for NamedOrBlankNodeRef<'a> {
}
fn value_raw(&self) -> RawValue<'_> {
use NamedOrBlankNodeRef::*;
use SubjectRef::*;
match self {
NamedNode(n) => n.value_raw(),
BlankNode(n) => n.value_raw(),
@ -248,7 +248,7 @@ impl<'a> TTerm for NamedOrBlankNodeRef<'a> {
}
fn as_dyn(&self) -> &dyn TTerm {
use NamedOrBlankNodeRef::*;
use SubjectRef::*;
match self {
NamedNode(n) => n.as_dyn(),
BlankNode(n) => n.as_dyn(),

@ -7,12 +7,12 @@ use std::fmt;
/// The owned union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) and [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node).
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum NamedOrBlankNode {
pub enum Subject {
NamedNode(NamedNode),
BlankNode(BlankNode),
}
impl NamedOrBlankNode {
impl Subject {
#[inline]
pub fn is_named_node(&self) -> bool {
self.as_ref().is_named_node()
@ -24,43 +24,43 @@ impl NamedOrBlankNode {
}
#[inline]
pub fn as_ref(&self) -> NamedOrBlankNodeRef<'_> {
pub fn as_ref(&self) -> SubjectRef<'_> {
match self {
Self::NamedNode(node) => NamedOrBlankNodeRef::NamedNode(node.as_ref()),
Self::BlankNode(node) => NamedOrBlankNodeRef::BlankNode(node.as_ref()),
Self::NamedNode(node) => SubjectRef::NamedNode(node.as_ref()),
Self::BlankNode(node) => SubjectRef::BlankNode(node.as_ref()),
}
}
}
impl fmt::Display for NamedOrBlankNode {
impl fmt::Display for Subject {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.as_ref().fmt(f)
}
}
impl From<NamedNode> for NamedOrBlankNode {
impl From<NamedNode> for Subject {
#[inline]
fn from(node: NamedNode) -> Self {
Self::NamedNode(node)
}
}
impl From<NamedNodeRef<'_>> for NamedOrBlankNode {
impl From<NamedNodeRef<'_>> for Subject {
#[inline]
fn from(node: NamedNodeRef<'_>) -> Self {
node.into_owned().into()
}
}
impl From<BlankNode> for NamedOrBlankNode {
impl From<BlankNode> for Subject {
#[inline]
fn from(node: BlankNode) -> Self {
Self::BlankNode(node)
}
}
impl From<BlankNodeRef<'_>> for NamedOrBlankNode {
impl From<BlankNodeRef<'_>> for Subject {
#[inline]
fn from(node: BlankNodeRef<'_>) -> Self {
node.into_owned().into()
@ -69,12 +69,12 @@ impl From<BlankNodeRef<'_>> for NamedOrBlankNode {
/// The borrowed union of [IRIs](https://www.w3.org/TR/rdf11-concepts/#dfn-iri) and [blank nodes](https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node).
#[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)]
pub enum NamedOrBlankNodeRef<'a> {
pub enum SubjectRef<'a> {
NamedNode(NamedNodeRef<'a>),
BlankNode(BlankNodeRef<'a>),
}
impl<'a> NamedOrBlankNodeRef<'a> {
impl<'a> SubjectRef<'a> {
#[inline]
pub fn is_named_node(&self) -> bool {
match self {
@ -92,15 +92,15 @@ impl<'a> NamedOrBlankNodeRef<'a> {
}
#[inline]
pub fn into_owned(self) -> NamedOrBlankNode {
pub fn into_owned(self) -> Subject {
match self {
Self::NamedNode(node) => NamedOrBlankNode::NamedNode(node.into_owned()),
Self::BlankNode(node) => NamedOrBlankNode::BlankNode(node.into_owned()),
Self::NamedNode(node) => Subject::NamedNode(node.into_owned()),
Self::BlankNode(node) => Subject::BlankNode(node.into_owned()),
}
}
}
impl fmt::Display for NamedOrBlankNodeRef<'_> {
impl fmt::Display for SubjectRef<'_> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
@ -110,54 +110,54 @@ impl fmt::Display for NamedOrBlankNodeRef<'_> {
}
}
impl<'a> From<NamedNodeRef<'a>> for NamedOrBlankNodeRef<'a> {
impl<'a> From<NamedNodeRef<'a>> for SubjectRef<'a> {
#[inline]
fn from(node: NamedNodeRef<'a>) -> Self {
Self::NamedNode(node)
}
}
impl<'a> From<&'a NamedNode> for NamedOrBlankNodeRef<'a> {
impl<'a> From<&'a NamedNode> for SubjectRef<'a> {
#[inline]
fn from(node: &'a NamedNode) -> Self {
node.as_ref().into()
}
}
impl<'a> From<BlankNodeRef<'a>> for NamedOrBlankNodeRef<'a> {
impl<'a> From<BlankNodeRef<'a>> for SubjectRef<'a> {
#[inline]
fn from(node: BlankNodeRef<'a>) -> Self {
Self::BlankNode(node)
}
}
impl<'a> From<&'a BlankNode> for NamedOrBlankNodeRef<'a> {
impl<'a> From<&'a BlankNode> for SubjectRef<'a> {
#[inline]
fn from(node: &'a BlankNode) -> Self {
node.as_ref().into()
}
}
impl<'a> From<&'a NamedOrBlankNode> for NamedOrBlankNodeRef<'a> {
impl<'a> From<&'a Subject> for SubjectRef<'a> {
#[inline]
fn from(node: &'a NamedOrBlankNode) -> Self {
fn from(node: &'a Subject) -> Self {
node.as_ref()
}
}
impl<'a> From<NamedOrBlankNodeRef<'a>> for NamedOrBlankNode {
impl<'a> From<SubjectRef<'a>> for Subject {
#[inline]
fn from(node: NamedOrBlankNodeRef<'a>) -> Self {
fn from(node: SubjectRef<'a>) -> Self {
node.into_owned()
}
}
impl<'a> From<NamedOrBlankNodeRef<'a>> for rio::NamedOrBlankNode<'a> {
impl<'a> From<SubjectRef<'a>> for rio::NamedOrBlankNode<'a> {
#[inline]
fn from(node: NamedOrBlankNodeRef<'a>) -> Self {
fn from(node: SubjectRef<'a>) -> Self {
match node {
NamedOrBlankNodeRef::NamedNode(node) => rio::NamedNode::from(node).into(),
NamedOrBlankNodeRef::BlankNode(node) => rio::BlankNode::from(node).into(),
SubjectRef::NamedNode(node) => rio::NamedNode::from(node).into(),
SubjectRef::BlankNode(node) => rio::BlankNode::from(node).into(),
}
}
}
@ -246,19 +246,19 @@ impl From<LiteralRef<'_>> for Term {
}
}
impl From<NamedOrBlankNode> for Term {
impl From<Subject> for Term {
#[inline]
fn from(node: NamedOrBlankNode) -> Self {
fn from(node: Subject) -> Self {
match node {
NamedOrBlankNode::NamedNode(node) => node.into(),
NamedOrBlankNode::BlankNode(node) => node.into(),
Subject::NamedNode(node) => node.into(),
Subject::BlankNode(node) => node.into(),
}
}
}
impl From<NamedOrBlankNodeRef<'_>> for Term {
impl From<SubjectRef<'_>> for Term {
#[inline]
fn from(node: NamedOrBlankNodeRef<'_>) -> Self {
fn from(node: SubjectRef<'_>) -> Self {
node.into_owned().into()
}
}
@ -351,19 +351,19 @@ impl<'a> From<&'a Literal> for TermRef<'a> {
}
}
impl<'a> From<NamedOrBlankNodeRef<'a>> for TermRef<'a> {
impl<'a> From<SubjectRef<'a>> for TermRef<'a> {
#[inline]
fn from(node: NamedOrBlankNodeRef<'a>) -> Self {
fn from(node: SubjectRef<'a>) -> Self {
match node {
NamedOrBlankNodeRef::NamedNode(node) => node.into(),
NamedOrBlankNodeRef::BlankNode(node) => node.into(),
SubjectRef::NamedNode(node) => node.into(),
SubjectRef::BlankNode(node) => node.into(),
}
}
}
impl<'a> From<&'a NamedOrBlankNode> for TermRef<'a> {
impl<'a> From<&'a Subject> for TermRef<'a> {
#[inline]
fn from(node: &'a NamedOrBlankNode) -> Self {
fn from(node: &'a Subject) -> Self {
node.as_ref().into()
}
}
@ -397,7 +397,7 @@ impl<'a> From<TermRef<'a>> for rio::Term<'a> {
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct Triple {
/// The [subject](https://www.w3.org/TR/rdf11-concepts/#dfn-subject) of this triple
pub subject: NamedOrBlankNode,
pub subject: Subject,
/// The [predicate](https://www.w3.org/TR/rdf11-concepts/#dfn-predicate) of this triple
pub predicate: NamedNode,
@ -410,7 +410,7 @@ impl Triple {
/// Builds an RDF [triple](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple)
#[inline]
pub fn new(
subject: impl Into<NamedOrBlankNode>,
subject: impl Into<Subject>,
predicate: impl Into<NamedNode>,
object: impl Into<Term>,
) -> Self {
@ -453,7 +453,7 @@ impl fmt::Display for Triple {
#[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)]
pub struct TripleRef<'a> {
/// The [subject](https://www.w3.org/TR/rdf11-concepts/#dfn-subject) of this triple
pub subject: NamedOrBlankNodeRef<'a>,
pub subject: SubjectRef<'a>,
/// The [predicate](https://www.w3.org/TR/rdf11-concepts/#dfn-predicate) of this triple
pub predicate: NamedNodeRef<'a>,
@ -466,7 +466,7 @@ impl<'a> TripleRef<'a> {
/// Builds an RDF [triple](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple)
#[inline]
pub fn new(
subject: impl Into<NamedOrBlankNodeRef<'a>>,
subject: impl Into<SubjectRef<'a>>,
predicate: impl Into<NamedNodeRef<'a>>,
object: impl Into<TermRef<'a>>,
) -> Self {
@ -600,26 +600,26 @@ impl From<BlankNodeRef<'_>> for GraphName {
}
}
impl From<NamedOrBlankNode> for GraphName {
impl From<Subject> for GraphName {
#[inline]
fn from(node: NamedOrBlankNode) -> Self {
fn from(node: Subject) -> Self {
match node {
NamedOrBlankNode::NamedNode(node) => node.into(),
NamedOrBlankNode::BlankNode(node) => node.into(),
Subject::NamedNode(node) => node.into(),
Subject::BlankNode(node) => node.into(),
}
}
}
impl From<NamedOrBlankNodeRef<'_>> for GraphName {
impl From<SubjectRef<'_>> for GraphName {
#[inline]
fn from(node: NamedOrBlankNodeRef<'_>) -> Self {
fn from(node: SubjectRef<'_>) -> Self {
node.into_owned().into()
}
}
impl From<Option<NamedOrBlankNode>> for GraphName {
impl From<Option<Subject>> for GraphName {
#[inline]
fn from(name: Option<NamedOrBlankNode>) -> Self {
fn from(name: Option<Subject>) -> Self {
if let Some(node) = name {
node.into()
} else {
@ -628,7 +628,7 @@ impl From<Option<NamedOrBlankNode>> for GraphName {
}
}
impl From<GraphName> for Option<NamedOrBlankNode> {
impl From<GraphName> for Option<Subject> {
#[inline]
fn from(name: GraphName) -> Self {
match name {
@ -713,19 +713,19 @@ impl<'a> From<&'a BlankNode> for GraphNameRef<'a> {
}
}
impl<'a> From<NamedOrBlankNodeRef<'a>> for GraphNameRef<'a> {
impl<'a> From<SubjectRef<'a>> for GraphNameRef<'a> {
#[inline]
fn from(node: NamedOrBlankNodeRef<'a>) -> Self {
fn from(node: SubjectRef<'a>) -> Self {
match node {
NamedOrBlankNodeRef::NamedNode(node) => node.into(),
NamedOrBlankNodeRef::BlankNode(node) => node.into(),
SubjectRef::NamedNode(node) => node.into(),
SubjectRef::BlankNode(node) => node.into(),
}
}
}
impl<'a> From<&'a NamedOrBlankNode> for GraphNameRef<'a> {
impl<'a> From<&'a Subject> for GraphNameRef<'a> {
#[inline]
fn from(node: &'a NamedOrBlankNode) -> Self {
fn from(node: &'a Subject) -> Self {
node.as_ref().into()
}
}
@ -744,9 +744,9 @@ impl<'a> From<GraphNameRef<'a>> for GraphName {
}
}
impl<'a> From<Option<NamedOrBlankNodeRef<'a>>> for GraphNameRef<'a> {
impl<'a> From<Option<SubjectRef<'a>>> for GraphNameRef<'a> {
#[inline]
fn from(name: Option<NamedOrBlankNodeRef<'a>>) -> Self {
fn from(name: Option<SubjectRef<'a>>) -> Self {
if let Some(node) = name {
node.into()
} else {
@ -755,7 +755,7 @@ impl<'a> From<Option<NamedOrBlankNodeRef<'a>>> for GraphNameRef<'a> {
}
}
impl<'a> From<GraphNameRef<'a>> for Option<NamedOrBlankNodeRef<'a>> {
impl<'a> From<GraphNameRef<'a>> for Option<SubjectRef<'a>> {
#[inline]
fn from(name: GraphNameRef<'a>) -> Self {
match name {
@ -781,7 +781,7 @@ impl<'a> From<GraphNameRef<'a>> for Option<rio::NamedOrBlankNode<'a>> {
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct Quad {
/// The [subject](https://www.w3.org/TR/rdf11-concepts/#dfn-subject) of this triple
pub subject: NamedOrBlankNode,
pub subject: Subject,
/// The [predicate](https://www.w3.org/TR/rdf11-concepts/#dfn-predicate) of this triple
pub predicate: NamedNode,
@ -797,7 +797,7 @@ impl Quad {
/// Builds an RDF [triple](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple) in a [RDF dataset](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset)
#[inline]
pub fn new(
subject: impl Into<NamedOrBlankNode>,
subject: impl Into<Subject>,
predicate: impl Into<NamedNode>,
object: impl Into<Term>,
graph_name: impl Into<GraphName>,
@ -843,7 +843,7 @@ impl From<Quad> for Triple {
#[derive(Eq, PartialEq, Debug, Clone, Copy, Hash)]
pub struct QuadRef<'a> {
/// The [subject](https://www.w3.org/TR/rdf11-concepts/#dfn-subject) of this triple
pub subject: NamedOrBlankNodeRef<'a>,
pub subject: SubjectRef<'a>,
/// The [predicate](https://www.w3.org/TR/rdf11-concepts/#dfn-predicate) of this triple
pub predicate: NamedNodeRef<'a>,
@ -859,7 +859,7 @@ impl<'a> QuadRef<'a> {
/// Builds an RDF [triple](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple) in a [RDF dataset](https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset)
#[inline]
pub fn new(
subject: impl Into<NamedOrBlankNodeRef<'a>>,
subject: impl Into<SubjectRef<'a>>,
predicate: impl Into<NamedNodeRef<'a>>,
object: impl Into<TermRef<'a>>,
graph_name: impl Into<GraphNameRef<'a>>,

@ -1,8 +1,7 @@
//! This crate provides implementation of [Sophia](https://docs.rs/sophia/) traits for the `store` module.
use crate::model::{
BlankNodeRef, GraphNameRef, LiteralRef, NamedNodeRef, NamedOrBlankNodeRef, Quad, QuadRef, Term,
TermRef,
BlankNodeRef, GraphNameRef, LiteralRef, NamedNodeRef, Quad, QuadRef, SubjectRef, Term, TermRef,
};
use crate::sparql::{EvaluationError, QueryResults};
use crate::store::Store;
@ -449,7 +448,7 @@ fn io_err_map(err: EvaluationError) -> Error {
}
}
fn convert_subject<'a, T>(term: &'a T, buffer: &'a mut String) -> Option<NamedOrBlankNodeRef<'a>>
fn convert_subject<'a, T>(term: &'a T, buffer: &'a mut String) -> Option<SubjectRef<'a>>
where
T: TTerm + ?Sized + 'a,
{

@ -171,7 +171,7 @@ impl<'a> TryFrom<&'a String> for Update {
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct QueryDataset {
default: Option<Vec<GraphName>>,
named: Option<Vec<NamedOrBlankNode>>,
named: Option<Vec<Subject>>,
}
impl QueryDataset {
@ -255,7 +255,7 @@ impl QueryDataset {
}
/// Returns the list of the available named graphs for the query or `None` if all graphs are available
pub fn available_named_graphs(&self) -> Option<&[NamedOrBlankNode]> {
pub fn available_named_graphs(&self) -> Option<&[Subject]> {
self.named.as_deref()
}
@ -272,7 +272,7 @@ impl QueryDataset {
///
/// # Result::Ok::<_, Box<dyn std::error::Error>>(())
/// ```
pub fn set_available_named_graphs(&mut self, named_graphs: Vec<NamedOrBlankNode>) {
pub fn set_available_named_graphs(&mut self, named_graphs: Vec<Subject>) {
self.named = Some(named_graphs);
}
}

@ -1,8 +1,8 @@
use crate::sparql::algebra::QueryDataset;
use crate::sparql::EvaluationError;
use crate::storage::numeric_encoder::{
get_encoded_graph_name, get_encoded_named_or_blank_node, EncodedQuad, EncodedTerm,
StrContainer, StrHash, StrLookup,
get_encoded_graph_name, get_encoded_subject, EncodedQuad, EncodedTerm, StrContainer, StrHash,
StrLookup,
};
use crate::storage::Storage;
use std::cell::RefCell;
@ -28,7 +28,7 @@ impl DatasetView {
named: dataset.available_named_graphs().map(|graphs| {
graphs
.iter()
.map(|g| get_encoded_named_or_blank_node(g.as_ref()))
.map(|g| get_encoded_subject(g.as_ref()))
.collect::<Vec<_>>()
}),
};

@ -2668,7 +2668,7 @@ fn decode_triple<D: Decoder>(
object: &EncodedTerm,
) -> Result<Triple, EvaluationError> {
Ok(Triple::new(
decoder.decode_named_or_blank_node(subject)?,
decoder.decode_subject(subject)?,
decoder.decode_named_node(predicate)?,
decoder.decode_term(object)?,
))

@ -19,8 +19,8 @@ use oxiri::Iri;
use spargebra::algebra::{GraphPattern, GraphTarget};
use spargebra::term::{
BlankNode, GraphName, GraphNamePattern, GroundQuad, GroundQuadPattern, GroundTerm,
GroundTermPattern, Literal, NamedNode, NamedNodePattern, NamedOrBlankNode, Quad, QuadPattern,
Term, TermPattern, Variable,
GroundTermPattern, Literal, NamedNode, NamedNodePattern, Quad, QuadPattern, Subject, Term,
TermPattern, Variable,
};
use spargebra::GraphUpdateOperation;
use std::collections::HashMap;
@ -301,10 +301,8 @@ impl<'a> SimpleUpdateEvaluator<'a> {
) -> Result<Option<EncodedQuad>, EvaluationError> {
Ok(Some(EncodedQuad {
subject: match &quad.subject {
NamedOrBlankNode::NamedNode(subject) => {
self.encode_named_node_for_insertion(subject)?
}
NamedOrBlankNode::BlankNode(subject) => self
Subject::NamedNode(subject) => self.encode_named_node_for_insertion(subject)?,
Subject::BlankNode(subject) => self
.storage
.encode_blank_node(bnodes.entry(subject.clone()).or_default().as_ref())?,
},

@ -609,10 +609,10 @@ pub(crate) fn get_encoded_literal(literal: LiteralRef<'_>) -> EncodedTerm {
}
}
pub(crate) fn get_encoded_named_or_blank_node(term: NamedOrBlankNodeRef<'_>) -> EncodedTerm {
pub(crate) fn get_encoded_subject(term: SubjectRef<'_>) -> EncodedTerm {
match term {
NamedOrBlankNodeRef::NamedNode(named_node) => get_encoded_named_node(named_node),
NamedOrBlankNodeRef::BlankNode(blank_node) => get_encoded_blank_node(blank_node),
SubjectRef::NamedNode(named_node) => get_encoded_named_node(named_node),
SubjectRef::BlankNode(blank_node) => get_encoded_blank_node(blank_node),
}
}
@ -634,7 +634,7 @@ pub(crate) fn get_encoded_graph_name(name: GraphNameRef<'_>) -> EncodedTerm {
pub(crate) fn get_encoded_quad(quad: QuadRef<'_>) -> EncodedQuad {
EncodedQuad {
subject: get_encoded_named_or_blank_node(quad.subject),
subject: get_encoded_subject(quad.subject),
predicate: get_encoded_named_node(quad.predicate),
object: get_encoded_term(quad.object),
graph_name: get_encoded_graph_name(quad.graph_name),
@ -666,13 +666,10 @@ pub(crate) trait WriteEncoder: StrContainer {
self.encode_rio_literal(literal.into())
}
fn encode_named_or_blank_node(
&self,
term: NamedOrBlankNodeRef<'_>,
) -> Result<EncodedTerm, Self::Error> {
fn encode_subject(&self, term: SubjectRef<'_>) -> Result<EncodedTerm, Self::Error> {
match term {
NamedOrBlankNodeRef::NamedNode(named_node) => self.encode_named_node(named_node),
NamedOrBlankNodeRef::BlankNode(blank_node) => self.encode_blank_node(blank_node),
SubjectRef::NamedNode(named_node) => self.encode_named_node(named_node),
SubjectRef::BlankNode(blank_node) => self.encode_blank_node(blank_node),
}
}
@ -694,7 +691,7 @@ pub(crate) trait WriteEncoder: StrContainer {
fn encode_quad(&self, quad: QuadRef<'_>) -> Result<EncodedQuad, Self::Error> {
Ok(EncodedQuad {
subject: self.encode_named_or_blank_node(quad.subject)?,
subject: self.encode_subject(quad.subject)?,
predicate: self.encode_named_node(quad.predicate)?,
object: self.encode_term(quad.object)?,
graph_name: self.encode_graph_name(quad.graph_name)?,
@ -707,7 +704,7 @@ pub(crate) trait WriteEncoder: StrContainer {
graph_name: EncodedTerm,
) -> Result<EncodedQuad, Self::Error> {
Ok(EncodedQuad {
subject: self.encode_named_or_blank_node(triple.subject)?,
subject: self.encode_subject(triple.subject)?,
predicate: self.encode_named_node(triple.predicate)?,
object: self.encode_term(triple.object)?,
graph_name,
@ -838,7 +835,7 @@ pub(crate) trait WriteEncoder: StrContainer {
})
}
fn encode_rio_named_or_blank_node(
fn encode_rio_subject(
&self,
term: rio::NamedOrBlankNode<'_>,
bnodes_map: &mut HashMap<String, u128>,
@ -869,11 +866,11 @@ pub(crate) trait WriteEncoder: StrContainer {
bnodes_map: &mut HashMap<String, u128>,
) -> Result<EncodedQuad, Self::Error> {
Ok(EncodedQuad {
subject: self.encode_rio_named_or_blank_node(quad.subject, bnodes_map)?,
subject: self.encode_rio_subject(quad.subject, bnodes_map)?,
predicate: self.encode_rio_named_node(quad.predicate)?,
object: self.encode_rio_term(quad.object, bnodes_map)?,
graph_name: match quad.graph_name {
Some(graph_name) => self.encode_rio_named_or_blank_node(graph_name, bnodes_map)?,
Some(graph_name) => self.encode_rio_subject(graph_name, bnodes_map)?,
None => EncodedTerm::DefaultGraph,
},
})
@ -886,7 +883,7 @@ pub(crate) trait WriteEncoder: StrContainer {
bnodes_map: &mut HashMap<String, u128>,
) -> Result<EncodedQuad, Self::Error> {
Ok(EncodedQuad {
subject: self.encode_rio_named_or_blank_node(triple.subject, bnodes_map)?,
subject: self.encode_rio_subject(triple.subject, bnodes_map)?,
predicate: self.encode_rio_named_node(triple.predicate)?,
object: self.encode_rio_term(triple.object, bnodes_map)?,
graph_name,
@ -978,10 +975,7 @@ pub fn parse_day_time_duration_str(value: &str) -> Option<EncodedTerm> {
pub(crate) trait Decoder: StrLookup {
fn decode_term(&self, encoded: &EncodedTerm) -> Result<Term, DecoderError<Self::Error>>;
fn decode_named_or_blank_node(
&self,
encoded: &EncodedTerm,
) -> Result<NamedOrBlankNode, DecoderError<Self::Error>> {
fn decode_subject(&self, encoded: &EncodedTerm) -> Result<Subject, DecoderError<Self::Error>> {
match self.decode_term(encoded)? {
Term::NamedNode(named_node) => Ok(named_node.into()),
Term::BlankNode(blank_node) => Ok(blank_node.into()),
@ -1008,12 +1002,12 @@ pub(crate) trait Decoder: StrLookup {
fn decode_quad(&self, encoded: &EncodedQuad) -> Result<Quad, DecoderError<Self::Error>> {
Ok(Quad::new(
self.decode_named_or_blank_node(&encoded.subject)?,
self.decode_subject(&encoded.subject)?,
self.decode_named_node(&encoded.predicate)?,
self.decode_term(&encoded.object)?,
match &encoded.graph_name {
EncodedTerm::DefaultGraph => None,
graph_name => Some(self.decode_named_or_blank_node(graph_name)?),
graph_name => Some(self.decode_subject(graph_name)?),
},
))
}

@ -37,8 +37,8 @@ use crate::sparql::{
};
use crate::storage::io::{dump_dataset, dump_graph, load_dataset, load_graph};
use crate::storage::numeric_encoder::{
get_encoded_graph_name, get_encoded_named_node, get_encoded_named_or_blank_node,
get_encoded_quad, get_encoded_term, Decoder, WriteEncoder,
get_encoded_graph_name, get_encoded_named_node, get_encoded_quad, get_encoded_subject,
get_encoded_term, Decoder, WriteEncoder,
};
pub use crate::storage::ConflictableTransactionError;
pub use crate::storage::TransactionError;
@ -164,14 +164,14 @@ impl Store {
/// ```
pub fn quads_for_pattern(
&self,
subject: Option<NamedOrBlankNodeRef<'_>>,
subject: Option<SubjectRef<'_>>,
predicate: Option<NamedNodeRef<'_>>,
object: Option<TermRef<'_>>,
graph_name: Option<GraphNameRef<'_>>,
) -> QuadIter {
QuadIter {
iter: self.storage.quads_for_pattern(
subject.map(get_encoded_named_or_blank_node).as_ref(),
subject.map(get_encoded_subject).as_ref(),
predicate.map(get_encoded_named_node).as_ref(),
object.map(get_encoded_term).as_ref(),
graph_name.map(get_encoded_graph_name).as_ref(),
@ -441,13 +441,13 @@ impl Store {
/// Usage example:
/// ```
/// use oxigraph::store::Store;
/// use oxigraph::model::{NamedNode, QuadRef, NamedOrBlankNode};
/// use oxigraph::model::{NamedNode, QuadRef, Subject};
///
/// let ex = NamedNode::new("http://example.com")?;
/// let store = Store::new()?;
/// store.insert(QuadRef::new(&ex, &ex, &ex, &ex))?;
/// store.insert(QuadRef::new(&ex, &ex, &ex, None))?;
/// assert_eq!(vec![NamedOrBlankNode::from(ex)], store.named_graphs().collect::<Result<Vec<_>,_>>()?);
/// assert_eq!(vec![Subject::from(ex)], store.named_graphs().collect::<Result<Vec<_>,_>>()?);
/// # Result::<_,Box<dyn std::error::Error>>::Ok(())
/// ```
pub fn named_graphs(&self) -> GraphNameIter {
@ -472,9 +472,9 @@ impl Store {
/// ```
pub fn contains_named_graph<'a>(
&self,
graph_name: impl Into<NamedOrBlankNodeRef<'a>>,
graph_name: impl Into<SubjectRef<'a>>,
) -> Result<bool, io::Error> {
let graph_name = get_encoded_named_or_blank_node(graph_name.into());
let graph_name = get_encoded_subject(graph_name.into());
self.storage.contains_named_graph(&graph_name)
}
@ -495,9 +495,9 @@ impl Store {
/// ```
pub fn insert_named_graph<'a>(
&self,
graph_name: impl Into<NamedOrBlankNodeRef<'a>>,
graph_name: impl Into<SubjectRef<'a>>,
) -> Result<bool, io::Error> {
let graph_name = self.storage.encode_named_or_blank_node(graph_name.into())?;
let graph_name = self.storage.encode_subject(graph_name.into())?;
self.storage.insert_named_graph(&graph_name)
}
@ -549,9 +549,9 @@ impl Store {
/// ```
pub fn remove_named_graph<'a>(
&self,
graph_name: impl Into<NamedOrBlankNodeRef<'a>>,
graph_name: impl Into<SubjectRef<'a>>,
) -> Result<bool, io::Error> {
let graph_name = get_encoded_named_or_blank_node(graph_name.into());
let graph_name = get_encoded_subject(graph_name.into());
self.storage.remove_named_graph(&graph_name)
}
@ -714,9 +714,9 @@ impl Transaction<'_> {
/// Returns `true` if the graph was not already in the store.
pub fn insert_named_graph<'a>(
&self,
graph_name: impl Into<NamedOrBlankNodeRef<'a>>,
graph_name: impl Into<SubjectRef<'a>>,
) -> Result<bool, UnabortableTransactionError> {
let graph_name = self.storage.encode_named_or_blank_node(graph_name.into())?;
let graph_name = self.storage.encode_subject(graph_name.into())?;
self.storage.insert_named_graph(&graph_name)
}
}
@ -745,13 +745,13 @@ pub struct GraphNameIter {
}
impl Iterator for GraphNameIter {
type Item = Result<NamedOrBlankNode, io::Error>;
type Item = Result<Subject, io::Error>;
fn next(&mut self) -> Option<Result<NamedOrBlankNode, io::Error>> {
fn next(&mut self) -> Option<Result<Subject, io::Error>> {
Some(
self.iter.next()?.and_then(|graph_name| {
Ok(self.store.storage.decode_named_or_blank_node(&graph_name)?)
}),
self.iter
.next()?
.and_then(|graph_name| Ok(self.store.storage.decode_subject(&graph_name)?)),
)
}
@ -764,7 +764,7 @@ impl Iterator for GraphNameIter {
fn store() -> Result<(), io::Error> {
use crate::model::*;
let main_s = NamedOrBlankNode::from(BlankNode::default());
let main_s = Subject::from(BlankNode::default());
let main_p = NamedNode::new("http://example.com").unwrap();
let main_o = Term::from(Literal::from(1));
let main_g = GraphName::from(BlankNode::default());

@ -167,7 +167,7 @@ fn test_backward_compatibility() -> io::Result<()> {
}
assert!(store.contains_named_graph(graph_name)?);
assert_eq!(
vec![NamedOrBlankNode::from(graph_name)],
vec![Subject::from(graph_name)],
store.named_graphs().collect::<io::Result<Vec<_>>>()?
);
};

@ -39,7 +39,7 @@ impl From<PyNamedNode> for NamedNode {
}
}
impl From<PyNamedNode> for NamedOrBlankNode {
impl From<PyNamedNode> for Subject {
fn from(node: PyNamedNode) -> Self {
node.inner.into()
}
@ -138,7 +138,7 @@ impl From<PyBlankNode> for BlankNode {
}
}
impl From<PyBlankNode> for NamedOrBlankNode {
impl From<PyBlankNode> for Subject {
fn from(node: PyBlankNode) -> Self {
node.inner.into()
}
@ -405,34 +405,34 @@ impl PyObjectProtocol for PyDefaultGraph {
}
#[derive(FromPyObject)]
pub enum PyNamedOrBlankNode {
pub enum PySubject {
NamedNode(PyNamedNode),
BlankNode(PyBlankNode),
}
impl From<PyNamedOrBlankNode> for NamedOrBlankNode {
fn from(node: PyNamedOrBlankNode) -> Self {
impl From<PySubject> for Subject {
fn from(node: PySubject) -> Self {
match node {
PyNamedOrBlankNode::NamedNode(node) => node.into(),
PyNamedOrBlankNode::BlankNode(node) => node.into(),
PySubject::NamedNode(node) => node.into(),
PySubject::BlankNode(node) => node.into(),
}
}
}
impl From<NamedOrBlankNode> for PyNamedOrBlankNode {
fn from(node: NamedOrBlankNode) -> Self {
impl From<Subject> for PySubject {
fn from(node: Subject) -> Self {
match node {
NamedOrBlankNode::NamedNode(node) => PyNamedOrBlankNode::NamedNode(node.into()),
NamedOrBlankNode::BlankNode(node) => PyNamedOrBlankNode::BlankNode(node.into()),
Subject::NamedNode(node) => PySubject::NamedNode(node.into()),
Subject::BlankNode(node) => PySubject::BlankNode(node.into()),
}
}
}
impl IntoPy<PyObject> for PyNamedOrBlankNode {
impl IntoPy<PyObject> for PySubject {
fn into_py(self, py: Python<'_>) -> PyObject {
match self {
PyNamedOrBlankNode::NamedNode(node) => node.into_py(py),
PyNamedOrBlankNode::BlankNode(node) => node.into_py(py),
PySubject::NamedNode(node) => node.into_py(py),
PySubject::BlankNode(node) => node.into_py(py),
}
}
}
@ -519,7 +519,7 @@ impl<'a> From<&'a PyTriple> for TripleRef<'a> {
#[pymethods]
impl PyTriple {
#[new]
fn new(subject: PyNamedOrBlankNode, predicate: PyNamedNode, object: PyTerm) -> Self {
fn new(subject: PySubject, predicate: PyNamedNode, object: PyTerm) -> Self {
Triple::new(subject, predicate, object).into()
}
@ -529,7 +529,7 @@ impl PyTriple {
/// >>> Triple(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1')).subject
/// <NamedNode value=http://example.com>
#[getter]
fn subject(&self) -> PyNamedOrBlankNode {
fn subject(&self) -> PySubject {
self.inner.subject.clone().into()
}
@ -700,7 +700,7 @@ impl<'a> From<&'a PyQuad> for QuadRef<'a> {
impl PyQuad {
#[new]
fn new(
subject: PyNamedOrBlankNode,
subject: PySubject,
predicate: PyNamedNode,
object: PyTerm,
graph_name: Option<PyGraphName>,
@ -720,7 +720,7 @@ impl PyQuad {
/// >>> Quad(NamedNode('http://example.com'), NamedNode('http://example.com/p'), Literal('1'), NamedNode('http://example.com/g')).subject
/// <NamedNode value=http://example.com>
#[getter]
fn subject(&self) -> PyNamedOrBlankNode {
fn subject(&self) -> PySubject {
self.inner.subject.clone().into()
}
@ -804,7 +804,7 @@ impl PyMappingProtocol<'p> for PyQuad {
let gil = Python::acquire_gil();
let py = gil.python();
match input {
0 => Ok(PyNamedOrBlankNode::from(self.inner.subject.clone()).into_py(py)),
0 => Ok(PySubject::from(self.inner.subject.clone()).into_py(py)),
1 => Ok(PyNamedNode::from(self.inner.predicate.clone()).into_py(py)),
2 => Ok(PyTerm::from(self.inner.object.clone()).into_py(py)),
3 => Ok(PyGraphName::from(self.inner.graph_name.clone()).into_py(py)),
@ -929,21 +929,21 @@ impl<'a> TryFrom<&'a PyAny> for PyNamedNodeRef<'a> {
}
}
pub enum PyNamedOrBlankNodeRef<'a> {
pub enum PySubjectRef<'a> {
NamedNode(PyRef<'a, PyNamedNode>),
BlankNode(PyRef<'a, PyBlankNode>),
}
impl<'a> From<&'a PyNamedOrBlankNodeRef<'a>> for NamedOrBlankNodeRef<'a> {
fn from(value: &'a PyNamedOrBlankNodeRef<'a>) -> Self {
impl<'a> From<&'a PySubjectRef<'a>> for SubjectRef<'a> {
fn from(value: &'a PySubjectRef<'a>) -> Self {
match value {
PyNamedOrBlankNodeRef::NamedNode(value) => value.inner.as_ref().into(),
PyNamedOrBlankNodeRef::BlankNode(value) => value.inner.as_ref().into(),
PySubjectRef::NamedNode(value) => value.inner.as_ref().into(),
PySubjectRef::BlankNode(value) => value.inner.as_ref().into(),
}
}
}
impl<'a> TryFrom<&'a PyAny> for PyNamedOrBlankNodeRef<'a> {
impl<'a> TryFrom<&'a PyAny> for PySubjectRef<'a> {
type Error = PyErr;
fn try_from(value: &'a PyAny) -> PyResult<Self> {

@ -50,7 +50,7 @@ pub fn parse_query(
query.dataset_mut().set_available_named_graphs(
named_graphs
.iter()?
.map(|graph| Ok(graph?.extract::<PyNamedOrBlankNode>()?.into()))
.map(|graph| Ok(graph?.extract::<PySubject>()?.into()))
.collect::<PyResult<_>>()?,
)
}

@ -385,11 +385,11 @@ impl PyStore {
PyGraphNameRef::DefaultGraph => Ok(()),
PyGraphNameRef::NamedNode(graph_name) => self
.inner
.insert_named_graph(&PyNamedOrBlankNodeRef::NamedNode(graph_name))
.insert_named_graph(&PySubjectRef::NamedNode(graph_name))
.map(|_| ()),
PyGraphNameRef::BlankNode(graph_name) => self
.inner
.insert_named_graph(&PyNamedOrBlankNodeRef::BlankNode(graph_name))
.insert_named_graph(&PySubjectRef::BlankNode(graph_name))
.map(|_| ()),
}
.map_err(map_io_err)
@ -414,11 +414,11 @@ impl PyStore {
PyGraphNameRef::DefaultGraph => self.inner.clear_graph(GraphNameRef::DefaultGraph),
PyGraphNameRef::NamedNode(graph_name) => self
.inner
.remove_named_graph(&PyNamedOrBlankNodeRef::NamedNode(graph_name))
.remove_named_graph(&PySubjectRef::NamedNode(graph_name))
.map(|_| ()),
PyGraphNameRef::BlankNode(graph_name) => self
.inner
.remove_named_graph(&PyNamedOrBlankNodeRef::BlankNode(graph_name))
.remove_named_graph(&PySubjectRef::BlankNode(graph_name))
.map(|_| ()),
}
.map_err(map_io_err)?;
@ -487,7 +487,7 @@ impl PyIterProtocol for GraphNameIter {
slf.into()
}
fn __next__(mut slf: PyRefMut<Self>) -> PyResult<Option<PyNamedOrBlankNode>> {
fn __next__(mut slf: PyRefMut<Self>) -> PyResult<Option<PySubject>> {
slf.inner
.next()
.map(|q| Ok(q.map_err(map_io_err)?.into()))
@ -501,7 +501,7 @@ pub fn extract_quads_pattern<'a>(
object: &'a PyAny,
graph_name: Option<&'a PyAny>,
) -> PyResult<(
Option<PyNamedOrBlankNodeRef<'a>>,
Option<PySubjectRef<'a>>,
Option<PyNamedNodeRef<'a>>,
Option<PyTermRef<'a>>,
Option<PyGraphNameRef<'a>>,

@ -21,7 +21,7 @@ use http_types::{
StatusCode,
};
use oxigraph::io::{DatasetFormat, GraphFormat};
use oxigraph::model::{GraphName, GraphNameRef, NamedNode, NamedOrBlankNode};
use oxigraph::model::{GraphName, GraphNameRef, NamedNode, Subject};
use oxigraph::sparql::{Query, QueryResults, QueryResultsFormat, Update};
use oxigraph::store::Store;
use oxiri::Iri;
@ -407,7 +407,7 @@ fn evaluate_sparql_query(
let named_graph_uris = named_graph_uris
.into_iter()
.map(|e| Ok(NamedNode::new(e)?.into()))
.collect::<Result<Vec<NamedOrBlankNode>>>()
.collect::<Result<Vec<Subject>>>()
.map_err(bad_request)?;
if !default_graph_uris.is_empty() || !named_graph_uris.is_empty() {
@ -490,7 +490,7 @@ fn evaluate_sparql_update(
let named_graph_uris = named_graph_uris
.into_iter()
.map(|e| Ok(NamedNode::new(e)?.into()))
.collect::<Result<Vec<NamedOrBlankNode>>>()
.collect::<Result<Vec<Subject>>>()
.map_err(bad_request)?;
if !default_graph_uris.is_empty() || !named_graph_uris.is_empty() {
for using in update.using_datasets_mut() {

@ -123,29 +123,29 @@ impl fmt::Display for Literal {
///
/// The default string formatter is returning an N-Triples, Turtle and SPARQL compatible representation.
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub enum NamedOrBlankNode {
pub enum Subject {
NamedNode(NamedNode),
BlankNode(BlankNode),
}
impl fmt::Display for NamedOrBlankNode {
impl fmt::Display for Subject {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
NamedOrBlankNode::NamedNode(node) => node.fmt(f),
NamedOrBlankNode::BlankNode(node) => node.fmt(f),
Subject::NamedNode(node) => node.fmt(f),
Subject::BlankNode(node) => node.fmt(f),
}
}
}
impl From<NamedNode> for NamedOrBlankNode {
impl From<NamedNode> for Subject {
#[inline]
fn from(node: NamedNode) -> Self {
Self::NamedNode(node)
}
}
impl From<BlankNode> for NamedOrBlankNode {
impl From<BlankNode> for Subject {
#[inline]
fn from(node: BlankNode) -> Self {
Self::BlankNode(node)
@ -196,12 +196,12 @@ impl From<Literal> for Term {
}
}
impl From<NamedOrBlankNode> for Term {
impl From<Subject> for Term {
#[inline]
fn from(resource: NamedOrBlankNode) -> Self {
fn from(resource: Subject) -> Self {
match resource {
NamedOrBlankNode::NamedNode(node) => Self::NamedNode(node),
NamedOrBlankNode::BlankNode(node) => Self::BlankNode(node),
Subject::NamedNode(node) => Self::NamedNode(node),
Subject::BlankNode(node) => Self::BlankNode(node),
}
}
}
@ -285,7 +285,7 @@ impl From<NamedNode> for GraphName {
/// ```
#[derive(Eq, PartialEq, Debug, Clone, Hash)]
pub struct Quad {
pub subject: NamedOrBlankNode,
pub subject: Subject,
pub predicate: NamedNode,
pub object: Term,
pub graph_name: GraphName,

@ -161,7 +161,7 @@ impl Iterator for TestManifest {
TermRef::BlankNode(g) => Some(g.into()),
_ => None,
})
.filter_map(|g: NamedOrBlankNodeRef<'_>| {
.filter_map(|g: SubjectRef<'_>| {
if let (
Some(TermRef::NamedNode(endpoint)),
Some(TermRef::NamedNode(data)),
@ -246,8 +246,7 @@ impl Iterator for TestManifest {
None => {
match self.manifests_to_do.pop() {
Some(url) => {
let manifest =
NamedOrBlankNodeRef::from(NamedNodeRef::new(url.as_str()).unwrap());
let manifest = SubjectRef::from(NamedNodeRef::new(url.as_str()).unwrap());
if let Err(error) = load_to_graph(&url, &mut self.graph) {
return Some(Err(error));
}
@ -296,11 +295,11 @@ impl Iterator for TestManifest {
struct RdfListIterator<'a> {
graph: &'a Graph,
current_node: Option<NamedOrBlankNodeRef<'a>>,
current_node: Option<SubjectRef<'a>>,
}
impl<'a> RdfListIterator<'a> {
fn iter(graph: &'a Graph, root: NamedOrBlankNodeRef<'a>) -> RdfListIterator<'a> {
fn iter(graph: &'a Graph, root: SubjectRef<'a>) -> RdfListIterator<'a> {
RdfListIterator {
graph,
current_node: Some(root),

@ -104,7 +104,7 @@ fn evaluate_sparql_test(test: &Test) -> Result<()> {
}
}
for graph_name in query.dataset().available_named_graphs().unwrap_or(&[]) {
if let NamedOrBlankNode::NamedNode(graph_name) = graph_name {
if let Subject::NamedNode(graph_name) = graph_name {
load_to_store(graph_name.as_str(), &store, graph_name.as_ref())?;
} else {
return Err(anyhow!(

@ -21,7 +21,7 @@ use http_types::{
StatusCode,
};
use oxigraph::io::GraphFormat;
use oxigraph::model::{GraphName, NamedNode, NamedOrBlankNode};
use oxigraph::model::{GraphName, NamedNode, Subject};
use oxigraph::sparql::{Query, QueryResults, QueryResultsFormat};
use oxigraph::store::Store;
use std::str::FromStr;
@ -202,7 +202,7 @@ fn evaluate_sparql_query(
let named_graph_uris = named_graph_uris
.into_iter()
.map(|e| Ok(NamedNode::new(e)?.into()))
.collect::<Result<Vec<NamedOrBlankNode>>>()
.collect::<Result<Vec<Subject>>>()
.map_err(bad_request)?;
if !default_graph_uris.is_empty() || !named_graph_uris.is_empty() {

Loading…
Cancel
Save