#rdf #compression #file-format #hdt

nightly hdt

Library for the Header Dictionary Triples (HDT) RDF compression format

10 releases

Uses new Rust 2021

new 0.0.12 Jan 23, 2023
0.0.11 Jan 5, 2023
0.0.8 Dec 22, 2022
0.0.5 Nov 30, 2022
0.0.0 Oct 13, 2022

#90 in Compression

Download history 12/week @ 2022-10-07 10/week @ 2022-10-14 3/week @ 2022-10-21 54/week @ 2022-11-11 60/week @ 2022-11-18 63/week @ 2022-11-25 21/week @ 2022-12-02 34/week @ 2022-12-09 46/week @ 2022-12-16 21/week @ 2022-12-23 71/week @ 2022-12-30 49/week @ 2023-01-06 26/week @ 2023-01-13 61/week @ 2023-01-20

208 downloads per month
Used in rickview

MIT license

115KB
2K SLoC

HDT

Latest Version Documentation Benchmarks

A Rust library for the Header Dictionary Triples compressed RDF format, including:

  • loading the HDT default format as created by hdt-cpp
  • efficient querying by triple patterns
  • serializing into other formats like RDF Turtle and N-Triples using the Sophia adapter

However it cannot:

  • load other RDF formats
  • load other HDT variants

For this functionality and acknowledgement of all the original authors, please look at the reference implementations in C++ and Java by the https://github.com/rdfhdt organisation.

It also cannot:

  • swap data to disk
  • modify the RDF graph in memory
  • run SPARQL queries

If you need any of the those features, consider using a SPARQL endpoint instead.

Examples

[dependencies]
hdt = "0.0.12"
use hdt::Hdt;

let file = std::fs::File::open("example.hdt").expect("error opening file");
let hdt = Hdt::Rc<str>::new(std::io::BufReader::new(file)).expect("error loading HDT");
// query
let majors = hdt.triples_with_sp("http://dbpedia.org/resource/Leipzig", "http://dbpedia.org/ontology/major");
println!("{:?}", majors.collect::<Vec<_>>());

You can also use the Sophia adapter to load HDT files and reduce memory consumption of an existing application based on Sophia:

use hdt::{Hdt,HdtGraph};
use sophia::term::BoxTerm;
use sophia::graph::Graph;

let file = std::fs::File::open("dbpedia.hdt").expect("error opening file");
let hdt = Hdt::<std::rc::Rc<str>>::new(std::io::BufReader::new(file)).expect("error loading HDT");
let graph = HdtGraph::new(hdt);
let s = BoxTerm::new_iri_unchecked("http://dbpedia.org/resource/Leipzig");
let p = BoxTerm::new_iri_unchecked("http://dbpedia.org/ontology/major");
let majors = graph.triples_with_sp(&s,&p);

If you don't want to pull in the Sophia dependency, you can exclude the adapter:

[dependencies]
hdt = { version = "0.0.12", default-features = false }

Dependencies

~4.5MB
~104K SLoC