Crate hdt

source ·
Expand description

githubcrates-iodocs-rs


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<_>>());

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§

  • Types for storing and reading data.
  • Types for representing triple sections.
  • Adapter for the Sophia library.
  • Types for representing the header.
  • Types for representing and querying triples.

Enums§

  • Position in an RDF triple.