Skip to content

Commit c90c1cc

Browse files
authored
Merge pull request #2 from DeciSym/update-0.7.3
Update 0.7.3
2 parents 976106b + 0c25a47 commit c90c1cc

23 files changed

Lines changed: 606 additions & 259 deletions

‎.github/workflows/lint_and_test.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
# - os: windows-latest
2626
runs-on: ${{ matrix.os }}
2727
steps:
28-
- uses: actions/checkout@v6
28+
- uses: actions/checkout@v7
2929
with:
3030
submodules: 'true'
3131
- name: Install Rust

‎CITATION.cff‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ authors:
99
email: konrad.hoeffner@uni-leipzig.de
1010
affiliation: Institute for Medical Informatics, Statistics and Epidemiology (IMISE), Leipzig, Germany
1111
orcid: https://orcid.org/0000-0001-7358-3217
12-
- given-names: Baccaert
13-
family-names: Tim
12+
- given-names: Tim
13+
family-names: Baccaert
1414
affiliation: Independent Researcher, Belgium
15-
- given-names: Hanson
16-
family-names: Greg
15+
- given-names: Greg
16+
family-names: Hanson
1717
affiliation: DeciSym
1818
repository-code: 'https://github.com/konradhoeffner/hdt'
1919
url: 'https://crates.io/crates/hdt'

‎Cargo.toml‎

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
[package]
22
name = "hdt"
3-
version = "0.5.0"
4-
repository = "https://github.com/konradhoeffner/hdt"
5-
authors = ["Tim Baccaert <tbaccaer@vub.be>", "Konrad Höffner"]
3+
version = "0.7.3"
4+
repository = "https://github.com/KonradHoeffner/hdt"
5+
authors = ["Tim Baccaert <tbaccaer@vub.be>", "Konrad Höffner", "Greg Hanson"]
66
license = "MIT"
77
description = "Library for the Header Dictionary Triples (HDT) RDF compression format."
88
keywords = ["rdf", "hdt", "compression", "file-format"]
99
categories = ["compression", "filesystem", "parsing", "web-programming"]
1010
readme = "README.md"
1111
edition = "2024"
1212
rust-version = "1.87"
13+
exclude = ["tests/resources/rdf-tests"]
1314

1415
[package.metadata."docs.rs"]
1516
all-features = true
1617

18+
1719
[dependencies]
1820
bytesize = "2"
1921
crc = "3"
20-
oxttl = "0.2"
2122
oxrdf = "0.3"
22-
sophia = { version = "0.9", optional = true }
23+
sophia = { version = "0.10", optional = true }
2324
thiserror = "2"
2425
log = "0.4"
2526
env_logger = { version = "0.11", default-features = false, features = ["auto-color"] }
@@ -34,20 +35,21 @@ color-eyre = { version = "0.6", optional = true }
3435
clap = { version = "4.5", optional = true, features = ["derive"] }
3536
fs-err = { version = "3.1.0", optional = true }
3637
bitset-core = { version = "0.1.1", optional = true }
37-
lasso = { version = "0.7.3", features = ["multi-threaded"], optional = true }
38-
qwt = "0.3.4"
39-
mem_dbg = "0.3.4"
38+
oxttl = { version = "0.2.3" }
39+
qwt = "0.4.0"
4040
memmap2 = "0.9"
4141
fs2 = { version = "0.4", optional = true }
4242
tempfile = { version = "3.27", optional = true }
43+
hashbrown = { version = "0.17", optional = true }
44+
ahash = { version = "0.8", optional = true }
4345

4446
[features]
4547
default = ["sophia", "cache"]
4648
sophia = ["dep:sophia", "dep:mownstr"]
4749
cli = ["sophia", "nt", "dep:eyre", "dep:color-eyre", "dep:clap","dep:fs-err"]
4850
cache = ["dep:serde", "dep:bincode", "dep:fs2", "dep:tempfile"]
4951
sparql = ["dep:spareval", "dep:spargebra"]
50-
nt = ["dep:lasso","dep:bitset-core"]
52+
nt = ["dep:hashbrown","dep:ahash","dep:bitset-core"]
5153

5254
[target.'cfg(target_arch = "wasm32")'.dependencies]
5355
wasm-bindgen = "0.2"
@@ -80,8 +82,12 @@ opt-level = 1
8082
pretty_assertions = "1"
8183
env_logger = { version = "0.11", default-features = false, features = ["auto-color"] }
8284
criterion = { version = "0.8", default-features = false, features = ["cargo_bench_support", "html_reports"] }
83-
gungraun = "0.17"
85+
gungraun = "0.19"
8486
color-eyre = "0.6"
8587
fs-err = "3.1.0"
8688
sparesults = "0.3"
8789
walkdir = "2.5.0"
90+
91+
[[example]]
92+
name = "write"
93+
required-features = ["sophia"]

‎README.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ Web Assembly allows purely client-side HDT in the browser.
8282
It is gated behind the wasm32-unknown-unknown target and not a feature but is still experimental.
8383
We don't release the compiled artifacts to NPM yet (please open an issue if you need this or something else) so for now you need to build them yourself.
8484
Open [test-wasm.html](tests/resources/test-wasm.html) to test it and see the source code for how to load and query HDT with Wasm.
85+
Due to CORS browser restrictions you may have to run a local server e.g. on port 8000 and then open <http://localhost:8000/tests/resources/test-wasm.html>.
8586

8687
```sh
8788
rustup target add wasm32-unknown-unknown
88-
cargo install wasm_pack
89+
cargo install wasm-pack
8990
RUSTFLAGS="-C target-feature=+simd128" wasm-pack build --target web --release
91+
python -m http.server 8000
9092
```
9193

9294
## API Documentation
@@ -130,7 +132,7 @@ cargo bench --bench gungraun
130132
```
131133

132134
* requires [persondata\_en\_10k.hdt](https://github.com/KonradHoeffner/hdt/releases/download/benchmarkdata/persondata_en_10k.hdt.bz2) placed in `tests/resources`
133-
* requires [Valgrind](https://valgrind.org/) to be installed
135+
* requires [Valgrind](https://valgrind.org/) and [gungraun-runner](https://gungraun.github.io/gungraun/latest/html/installation/gungraun.html) to be installed
134136
* may require a conservative target CPU like `RUSTFLAGS="-C target-cpu=skylake" cargo bench --bench gungraun`
135137

136138
## Comparative benchmark suite

‎benches/criterion.rs‎

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use color_eyre::Result;
22
use color_eyre::eyre::WrapErr;
3-
use criterion::{Criterion, criterion_group, criterion_main};
4-
use fs_err::File;
5-
use hdt::triples::*;
3+
use criterion::{Criterion, criterion_group};
4+
use fs_err::{File, exists};
5+
use hdt::triples::{ObjectIter, PredicateIter, PredicateObjectIter, SubjectIter};
66
use hdt::{Hdt, IdKind};
77
use sophia::api::graph::Graph;
88
use sophia::api::term::matcher::Any;
@@ -12,10 +12,10 @@ const VINCENT: &str = "http://dbpedia.org/resource/Vincent_Descombes_Sevoie";
1212
const TYPE: &str = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
1313
const PERSON: &str = "http://dbpedia.org/ontology/Person";
1414
const H: &str = "tests/resources/persondata_en.hdt";
15+
#[cfg(feature = "nt")]
1516
const N: &str = "tests/resources/persondata_en.nt";
1617

1718
fn load() -> Result<Hdt> {
18-
color_eyre::install().unwrap();
1919
let f = File::open(H).wrap_err(format!("Error opening {H}, did you download it? See README.md."))?;
2020
//let file = File::open("tests/resources/lscomplete2015.hdt").expect("error opening file");
2121
//let file = File::open("tests/resources/snikmeta.hdt").expect("error opening file");
@@ -44,47 +44,47 @@ fn query(c: &mut Criterion) {
4444
let mut group = c.benchmark_group("S??");
4545
//let mut group = c.benchmark_group("query");
4646
group.bench_function("1.1 (vincent, ?, ?) triple IDs", |b| {
47-
b.iter(|| SubjectIter::with_pattern(triples, [vincent_id, 0, 0]).count())
47+
b.iter(|| SubjectIter::with_pattern(triples, [vincent_id, 0, 0]).count());
4848
});
4949
group.bench_function("1.2 (vincent, ?, ?) str triples", |b| b.iter(|| twp(Some(VINCENT), None, None).count()));
5050
group.bench_function("1.3 (vincent, ?, ?) Sophia triples", |b| {
51-
b.iter(|| hdt.triples_matching(Some(&vincent_term), Any, Any).count())
51+
b.iter(|| hdt.triples_matching(Some(&vincent_term), Any, Any).count());
5252
});
5353
group.finish();
5454

5555
let mut group = c.benchmark_group(format!("?P? {} triples", PredicateIter::new(triples, type_id).count()));
5656
group.sample_size(10);
5757
group.bench_function("2.1 (?, type, ?) triple IDs", |b| {
58-
b.iter(|| PredicateIter::new(triples, type_id).count())
58+
b.iter(|| PredicateIter::new(triples, type_id).count());
5959
});
6060
group.bench_function("2.2 (?, type, ?) str triples", |b| b.iter(|| twp(None, Some(TYPE), None).count()));
6161
group.bench_function("2.3 (?, type, ?) Sophia triples", |b| {
62-
b.iter(|| hdt.triples_matching(Any, Some(&type_term), Any).count())
62+
b.iter(|| hdt.triples_matching(Any, Some(&type_term), Any).count());
6363
});
6464
group.finish();
6565
let mut group = c.benchmark_group(format!("??O {} triples", ObjectIter::new(triples, person_id).count()));
6666
group.bench_function("3.1 (?, ?, person) triple IDs", |b| {
67-
b.iter(|| ObjectIter::new(triples, person_id).count())
67+
b.iter(|| ObjectIter::new(triples, person_id).count());
6868
});
6969
group.bench_function("3.2 (?, ?, person) str triples", |b| b.iter(|| twp(None, None, Some(PERSON)).count()));
7070
group.bench_function("3.3 (?, ?, person) Sophia triples", |b| {
71-
b.iter(|| hdt.triples_matching(Any, Any, Some(&person_term)).count())
71+
b.iter(|| hdt.triples_matching(Any, Any, Some(&person_term)).count());
7272
});
7373
group.finish();
7474
let mut group = c
7575
.benchmark_group(format!("?PO {} triples", PredicateObjectIter::new(triples, type_id, person_id).count()));
7676
group.sample_size(10);
7777
group.bench_function("4.1 (?, type, person) triple IDs", |b| {
78-
b.iter(|| PredicateObjectIter::new(triples, type_id, person_id).count())
78+
b.iter(|| PredicateObjectIter::new(triples, type_id, person_id).count());
7979
});
8080
group.bench_function("4.2 (?, type, person) str subjects", |b| {
81-
b.iter(|| hdt.subjects_with_po(TYPE, PERSON).count())
81+
b.iter(|| hdt.subjects_with_po(TYPE, PERSON).count());
8282
});
8383
group.bench_function("4.3 (?, type, person) str triples", |b| {
84-
b.iter(|| twp(None, Some(TYPE), Some(PERSON)).count())
84+
b.iter(|| twp(None, Some(TYPE), Some(PERSON)).count());
8585
});
8686
group.bench_function("4.4 (?, type, person) Sophia triples", |b| {
87-
b.iter(|| hdt.triples_matching(Any, Some(&type_term), Some(&person_term)).count())
87+
b.iter(|| hdt.triples_matching(Any, Some(&type_term), Some(&person_term)).count());
8888
});
8989
group.finish();
9090
}
@@ -99,8 +99,29 @@ fn read_nt_benchmarks(c: &mut Criterion) {
9999
group.finish();
100100
}
101101

102+
fn read_hdt_benchmarks(c: &mut Criterion) {
103+
use std::path::Path;
104+
let path = Path::new(H);
105+
assert!(exists(path).unwrap(), "{H} does not exist, please create it. See README.md.");
106+
let mut group = c.benchmark_group("read_hdt");
107+
group.sample_size(10);
108+
109+
group.bench_function("read_hdt_uncached", |b| b.iter(load));
110+
#[cfg(feature = "cache")]
111+
{
112+
let c = format!("{H}.{}", hdt::triples::CACHE_EXT);
113+
assert!(exists(Path::new(&c)).unwrap(), "cache file {c} does not exist");
114+
group.bench_function("read_hdt_cached", |b| b.iter(|| Hdt::read_from_path(path)));
115+
}
116+
group.finish();
117+
}
118+
102119
#[cfg(feature = "nt")]
103-
criterion_group!(criterion, query, read_nt_benchmarks);
120+
criterion_group!(criterion, query, read_nt_benchmarks, read_hdt_benchmarks);
104121
#[cfg(not(feature = "nt"))]
105-
criterion_group!(criterion, query);
106-
criterion_main!(criterion);
122+
criterion_group!(criterion, query, read_hdt_benchmarks);
123+
124+
fn main() {
125+
color_eyre::install().unwrap();
126+
criterion();
127+
}

‎codemeta.json‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,25 @@
1010
},
1111
{
1212
"affiliation": {
13-
"name": "Institut für Medizinische Informatik, Statistik und Epidemiologie (IMISE), Leipzig University",
13+
"name": "Institute for Medical Informatics, Statistics and Epidemiology (IMISE), Leipzig, Germany",
1414
"@type": "Organization"
1515
},
1616
"familyName": "Höffner",
1717
"givenName": "Konrad",
1818
"@id": "https://github.com/KonradHoeffner",
1919
"@type": "Person"
20+
},
21+
{
22+
"familyName": "Hanson",
23+
"givenName": "Greg",
24+
"@id": "https://github.com/GregHanson",
25+
"@type": "Person"
2026
}
2127
],
2228
"codeRepository": "https://github.com/KonradHoeffner/hdt",
2329
"dateCreated": "2022-09-26",
2430
"datePublished": "2022-11-17",
25-
"description": "Library for the Header Dictionary Triples (HDT) compression file format for RDF data. All features other than \"sophia\" are experimental and are neither guaranteed to work in all combinations nor adher to semver: they may change or be removed in future versions including minor or patch releases.\n \n A Rust library for the [Header Dictionary Triples](https://www.rdfhdt.org/) compressed RDF format, including: \n* loading the HDT default format as created by [hdt-cpp](https://github.com/rdfhdt/hdt-cpp)\n* converting N-Triples to HDT\n* efficient querying by triple patterns\n* serializing into other formats like RDF Turtle and N-Triples using the [Sophia](https://crates.io/crates/sophia) adapter\n* running SPARQL queries (with the experimental \"sparql\" feature but HDT is not optimized for that) \n* load other HDT variants\n* swap data to disk\n* modify the RDF graph in memory \nIf you need any of the those features, consider using a SPARQL endpoint instead.\nFor acknowledgement of all the original authors, please look at the reference implementations in C++ and Java by the [https://github.com/rdfhdt](https://github.com/rdfhdt) organisation.\n \n The performance of a query depends on the size of the graph, the type of triple pattern and the size of the result set.\nWhen using large HDT files, make sure to enable the release profile, such as through `cargo build --release`, as this can be much faster than using the dev profile.\n \n If you want to optimize the code, you can use a profiler.\nThe provided test data is very small in order to keep the size of the crate down; locally modifying the tests to use a large HDT file returns more meaningful results.\n \n",
31+
"description": "Rust library for the Header Dictionary Triples (HDT) compression file format for RDF data.",
2632
"identifier": "10.5281/zenodo.7871065",
2733
"keywords": [
2834
{
@@ -61,7 +67,7 @@
6167
],
6268
"datePublished": "2023",
6369
"identifier": "10.21105/joss.05114",
64-
"name": "https://orcid.org/0000-0000-0000-0000",
70+
"name": "hdt-rs: A Rust library for the Header Dictionary Triples binary RDF compression format",
6571
"url": "https://doi.org/10.21105/joss.05114",
6672
"@type": "ScholarlyArticle"
6773
}

‎examples/write.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![cfg(feature = "sophia")]
21
use hdt::Hdt;
32
use sophia::api::prelude::{Stringifier, TripleSerializer};
43
use sophia::turtle::serializer::turtle::{TurtleConfig, TurtleSerializer};

0 commit comments

Comments
 (0)