@@ -27,16 +27,9 @@ use crate::io::formats::PROGRESS_NOTIFY_INCREMENT;
27
27
use super :: {
28
28
error:: RdfFormatError ,
29
29
value_format:: { RdfValueFormat , RdfValueFormats } ,
30
- RdfVariant ,
30
+ RdfVariant , DEFAULT_GRAPH_IRI ,
31
31
} ;
32
32
33
- /// IRI to be used for the default graph used by Nemo when loading RDF data with
34
- /// named graphs (quads).
35
- ///
36
- /// SPARQL 1.1 has failed to provide any standard identifier for this purpose.
37
- /// If future SPARQL or RDF versions are adding this, we could align accordingly.
38
- const DEFAULT_GRAPH : & str = "tag:nemo:defaultgraph" ;
39
-
40
33
/// A [TableProvider] for RDF 1.1 files containing triples.
41
34
pub ( super ) struct RdfReader {
42
35
/// Buffer from which content is read
@@ -157,7 +150,7 @@ impl RdfReader {
157
150
value : Option < GraphName < ' _ > > ,
158
151
) -> Result < AnyDataValue , RdfFormatError > {
159
152
match value {
160
- None => Ok ( AnyDataValue :: new_iri ( DEFAULT_GRAPH . to_string ( ) ) ) ,
153
+ None => Ok ( AnyDataValue :: new_iri ( DEFAULT_GRAPH_IRI . to_string ( ) ) ) ,
161
154
Some ( GraphName :: NamedNode ( nn) ) => Ok ( Self :: datavalue_from_named_node ( nn) ) ,
162
155
Some ( GraphName :: BlankNode ( bn) ) => {
163
156
Ok ( Self :: datavalue_from_blank_node ( bnode_map, tuple_writer, bn) )
@@ -368,7 +361,7 @@ impl ByteSized for RdfReader {
368
361
369
362
#[ cfg( test) ]
370
363
mod test {
371
- use super :: { RdfReader , DEFAULT_GRAPH } ;
364
+ use super :: { RdfReader , DEFAULT_GRAPH_IRI } ;
372
365
use std:: cell:: RefCell ;
373
366
374
367
use nemo_physical:: {
@@ -454,7 +447,7 @@ mod test {
454
447
let dict = RefCell :: new ( Dict :: default ( ) ) ;
455
448
let mut tuple_writer = TupleWriter :: new ( & dict, 3 ) ;
456
449
let mut null_map = NullMap :: default ( ) ;
457
- let graph_dv = AnyDataValue :: new_iri ( DEFAULT_GRAPH . to_string ( ) ) ;
450
+ let graph_dv = AnyDataValue :: new_iri ( DEFAULT_GRAPH_IRI . to_string ( ) ) ;
458
451
459
452
// check that we use our own default graph IRI
460
453
assert_eq ! (
@@ -463,115 +456,10 @@ mod test {
463
456
) ;
464
457
// check that our default graph is a valid IRI in the first place
465
458
assert_eq ! (
466
- Iri :: parse( DEFAULT_GRAPH . to_string( ) ) . unwrap( ) . to_string( ) ,
467
- DEFAULT_GRAPH . to_string( )
459
+ Iri :: parse( DEFAULT_GRAPH_IRI . to_string( ) )
460
+ . unwrap( )
461
+ . to_string( ) ,
462
+ DEFAULT_GRAPH_IRI . to_string( )
468
463
) ;
469
464
}
470
-
471
- // #[test]
472
- // fn example_1() {
473
- // macro_rules! parse_example_with_rdf_parser {
474
- // ($data:tt, $make_parser:expr) => {
475
- // let $data = r#"<http://one.example/subject1> <http://one.example/predicate1> <http://one.example/object1> . # comments here
476
- // # or on a line by themselves
477
- // _:subject1 <http://an.example/predicate1> "object1" .
478
- // _:subject2 <http://an.example/predicate2> "object2" .
479
- // "#.as_bytes();
480
-
481
- // let dict = RefCell::new(Dict::default());
482
- // let mut builders = vec![
483
- // PhysicalBuilderProxyEnum::String(PhysicalStringColumnBuilderProxy::new(&dict)),
484
- // PhysicalBuilderProxyEnum::String(PhysicalStringColumnBuilderProxy::new(&dict)),
485
- // PhysicalBuilderProxyEnum::String(PhysicalStringColumnBuilderProxy::new(&dict)),
486
- // ];
487
- // let reader = RDFReader::new(ResourceProviders::empty(), String::new(), None, vec![PrimitiveType::Any, PrimitiveType::Any, PrimitiveType::Any]);
488
-
489
- // let result = reader.read_triples_with_parser(&mut builders, $make_parser);
490
- // assert!(result.is_ok());
491
-
492
- // let columns = builders
493
- // .into_iter()
494
- // .map(|builder| match builder {
495
- // PhysicalBuilderProxyEnum::String(b) => b.finalize(),
496
- // _ => unreachable!("only string columns here"),
497
- // })
498
- // .collect::<Vec<_>>();
499
-
500
- // log::debug!("columns: {columns:?}");
501
- // let triples = (0..=2)
502
- // .map(|idx| {
503
- // columns
504
- // .iter()
505
- // .map(|column| {
506
- // column
507
- // .get(idx)
508
- // .and_then(|value| value.try_into().ok())
509
- // .and_then(|u64: u64| usize::try_from(u64).ok())
510
- // .and_then(|usize| dict.borrow_mut().get(usize))
511
- // .unwrap()
512
- // })
513
- // .map(PhysicalString::from)
514
- // .collect::<Vec<_>>()
515
- // })
516
- // .collect::<Vec<_>>();
517
- // log::debug!("triple: {triples:?}");
518
- // for (value, expected) in PrimitiveType::Any.serialize_output(DataValueIteratorT::String(Box::new(triples[0].iter().cloned()))).zip(vec!["http://one.example/subject1", "http://one.example/predicate1", "http://one.example/object1"]) {
519
- // assert_eq!(value, expected);
520
- // }
521
- // for (value, expected) in PrimitiveType::Any.serialize_output(DataValueIteratorT::String(Box::new(triples[1].iter().cloned()))).zip(vec!["_:subject1", "http://an.example/predicate1", r#""object1""#]) {
522
- // assert_eq!(value, expected);
523
- // }
524
- // for (value, expected) in PrimitiveType::Any.serialize_output(DataValueIteratorT::String(Box::new(triples[2].iter().cloned()))).zip(vec!["_:subject2", "http://an.example/predicate2", r#""object2""#]) {
525
- // assert_eq!(value, expected);
526
- // }
527
- // };
528
- // }
529
-
530
- // parse_example_with_rdf_parser!(reader, || NTriplesParser::new(reader));
531
- // parse_example_with_rdf_parser!(reader, || TurtleParser::new(reader, None));
532
- // }
533
-
534
- // #[test]
535
- // fn rollback() {
536
- // let data = r#"<http://example.org/> <http://example.org/> <http://example.org/> .
537
- // malformed <http://example.org/> <http://example.org/>
538
- // <http://example.org/> malformed <http://example.org/> .
539
- // <http://example.org/> <http://example.org/> malformed .
540
- // <http://example.org/> <http://example.org/> "123"^^<http://www.w3.org/2001/XMLSchema#integer> .
541
- // <http://example.org/> <http://example.org/> "123.45"^^<http://www.w3.org/2001/XMLSchema#integer> .
542
- // <http://example.org/> <http://example.org/> "123.45"^^<http://www.w3.org/2001/XMLSchema#decimal> .
543
- // <http://example.org/> <http://example.org/> "123.45a"^^<http://www.w3.org/2001/XMLSchema#decimal> .
544
- // <https://example.org/> <https://example.org/> <https://example.org/> .
545
- // "#
546
- // .as_bytes();
547
-
548
- // let dict = RefCell::new(Dict::default());
549
- // let mut builders = vec![
550
- // PhysicalBuilderProxyEnum::String(PhysicalStringColumnBuilderProxy::new(&dict)),
551
- // PhysicalBuilderProxyEnum::String(PhysicalStringColumnBuilderProxy::new(&dict)),
552
- // PhysicalBuilderProxyEnum::String(PhysicalStringColumnBuilderProxy::new(&dict)),
553
- // ];
554
- // let reader = RDFReader::new(
555
- // ResourceProviders::empty(),
556
- // String::new(),
557
- // None,
558
- // vec![PrimitiveType::Any, PrimitiveType::Any, PrimitiveType::Any],
559
- // );
560
-
561
- // let result = reader.read_triples_with_parser(&mut builders, || NTriplesParser::new(data));
562
- // assert!(result.is_ok());
563
-
564
- // let columns = builders
565
- // .into_iter()
566
- // .map(|builder| match builder {
567
- // PhysicalBuilderProxyEnum::String(b) => b.finalize(),
568
- // _ => unreachable!("only string columns here"),
569
- // })
570
- // .collect::<Vec<_>>();
571
-
572
- // assert_eq!(columns.len(), 3);
573
- // assert_eq!(columns[0].len(), 4);
574
- // assert_eq!(columns[1].len(), 4);
575
- // assert_eq!(columns[2].len(), 4);
576
- // }
577
465
}
0 commit comments