Expand description
HDT is a loading and triple pattern querying library for the Header Dictionary Triples compressed binary RDF format.
Currently this library only supports loading and querying existing HDT files as created by hdt-cpp. For reference implementations of HDT in C++ and Java, which support conversion and serialization from and into HDT with different format options, and acknowledgement of all the original authors, please look at the https://github.com/rdfhdt organisation.
§Example of loading and querying an HDT file
use hdt::Hdt;
// Load an hdt file
let file = std::fs::File::open("example.hdt").expect("error opening file");
let hdt = Hdt::new(std::io::BufReader::new(file)).expect("error loading HDT");
// query
let majors = hdt.triples_with_pattern(Some("http://dbpedia.org/resource/Leipzig"), Some("http://dbpedia.org/ontology/major"),None);
println!("{:?}", majors.collect::<Vec<_>>());
§Experimental Features
The cache feature is experimental and may change or be removed in future releases.
Creating and/or loading a HDT file leveraging a custom cache:
let hdt = hdt::Hdt::new_from_path(std::path::Path::new("tests/resources/snikmeta.hdt")).unwrap();
§Additional Optional Features
Using the sophia adapter:
use hdt::{Hdt,HdtGraph};
use hdt::sophia::api::graph::Graph;
use hdt::sophia::api::term::{IriRef, SimpleTerm, matcher::Any};
fn query(hdt: Hdt)
{
let graph = HdtGraph::new(hdt);
let s = SimpleTerm::Iri(IriRef::new_unchecked("http://dbpedia.org/resource/Leipzig".into()));
let p = SimpleTerm::Iri(IriRef::new_unchecked("http://dbpedia.org/ontology/major".into()));
let majors = graph.triples_matching(Some(s),Some(p),Any);
}
Re-exports§
Modules§
- containers
- Types for storing and reading data.
- hdt
- Types for representing triple sections.
- hdt_
graph - Adapter for the Sophia library.
- header
- Types for representing the header.
- triples
- Types for representing and querying triples.
Enums§
- IdKind
- Position in an RDF triple.