Skip to content

Replace the Java rdf2json with a faithful Rust port#1306

Draft
jamesamcl wants to merge 3 commits into
devfrom
claude/rdf2json-rust-horned-owl-ls4nqd
Draft

Replace the Java rdf2json with a faithful Rust port#1306
jamesamcl wants to merge 3 commits into
devfrom
claude/rdf2json-rust-horned-owl-ls4nqd

Conversation

@jamesamcl

@jamesamcl jamesamcl commented Jun 26, 2026

Copy link
Copy Markdown
Member

What

Replaces the Java rdf2json dataload step (uk.ac.ebi.rdf2json.RDF2JSON) with a faithful Rust port, for performance — without changing the output contract the rest of the dataload pipeline depends on. This is a behaviour-preserving 1:1 replacement, the first of a planned series.

How it works

rdf2json (Rust) reads each ontology's RDF as triples via oxrdfio, builds the OLS node graph, runs the ~22 annotators (label / definition / synonym / direct+hierarchical parents / ancestors / hierarchy flags & metrics / shortForm / curie / relatedTo / isObsolete / reification / …), and streams the output JSON via serde_json one entity at a time, so memory stays bounded even on very large ontologies. --mergeOutputWith (the production incremental-reload safety net) is implemented via streaming struson. There is no horned-owl dependency.

Validation

  • 99/100 content-parity with the existing testcase fixtures. test_dataload.sh now compares normalized JSON content rather than byte-for-byte, because serde_json's whitespace differs from Gson's while the content is identical. The single difference, gitIssue502, differs only because it needs network access to fetch its source ontology.
  • --mergeOutputWith exercised for the fail→fallback, succeed→fresh, and unrelated→kept cases.
  • Downstream ols_create_manifest consumes the Rust output and produces a byte-identical manifest.
  • Full dockerised e2e (test_api.sh / apitester) runs in CI.

Behaviour change (intended)

The Java areSubgraphsIsomorphic bug duplicated annotated blank-node edges; the Rust port handles this correctly — annotated bnode edges merge into a single reified edge. The reification/reified-bnode fixtures are updated to the corrected output.

Commits

  1. Add the Rust port — crate, workspace/Docker/test wiring, reification fixture.
  2. Remove the Java rdf2json — delete source + maven module, switch nextflow to the Rust binary.

The dataload image still builds the remaining Java tools (merge_configs, reporting, extras).

Not in this PR (roadmap)

  • Remove Java/Maven from the dataload image: port merge_configs / reporting / extras/json2sssom to Rust.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V7yNmdd6CGnLqd85y3xoon


Generated by Claude Code

claude added 2 commits June 26, 2026 15:02
A performance-motivated, behaviour-preserving rewrite of uk.ac.ebi.rdf2json.RDF2JSON. It reads RDF triples via oxrdfio, builds the OLS node graph, runs the ~22 annotators, and streams the output JSON via serde_json (one entity at a time, so memory stays bounded on very large ontologies). It implements --mergeOutputWith (streamed via struson) to preserve the production incremental-reload safety net. There is no horned-owl dependency.

Output matches the existing testcase fixtures on 99/100 cases (only gitIssue502 differs, because it needs network access to fetch its source ontology). The dataload image builds the binary and the dev-testing / test_dataload.sh flows exercise it; JSON is compared by normalized content rather than byte-for-byte, since serde_json's formatting differs from Gson's while the content is identical.

This also corrects the reified-bnode handling the Java areSubgraphsIsomorphic bug got wrong: annotated blank-node edges now merge into a single reified edge instead of being duplicated. The reification testcase fixtures are updated to the corrected output.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V7yNmdd6CGnLqd85y3xoon
nextflow (ols_dataload.nf) now invokes the rdf2json Rust binary instead of the Java jar, dropping the JVM heap/entity-limit flags; the status-file grep is made whitespace-tolerant so it matches the pretty-printed status JSON.

The Java rdf2json maven module (dataload/pom.xml) and its source (dataload/rdf2json/) are removed; nothing else depended on them. dataload/README.md and dev-testing/dev-local.sh are repointed at the Rust binary.

The dataload image still builds the remaining Java tools (merge_configs, reporting, extras); removing Java/Maven from the image entirely is a follow-up.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V7yNmdd6CGnLqd85y3xoon
@jamesamcl
jamesamcl marked this pull request as draft June 26, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants