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