Repository navigation
The ldh plugin's dataset skill builds a CSV of millions of rows in chunks, keeps mappings to standard SPARQL 1.1, and runs arq from Jena 6.3 - #575
Open
namedgraph wants to merge 2 commits into
Conversation
…unks, keeps mappings to standard SPARQL 1.1, and runs arq from Jena 6.3 Converting a 4.8M-row, 1.9 GB CSV with the skill's csv2rdf + arq CONSTRUCT path met what it did not cover: arq holds input and result in memory, so the CSV must be chunked; csv2rdf rows carry no row number; BIND(NOW()) gives a document a dct:created per chunk; a mapping sees one row at a time, so values that differ between rows of one key multiply; an OPTIONAL lookup on an unbound key fans out over the whole alignment table; and splitting a list without apf:strSplit needs a VALUES index. The ground rule on standard SPARQL 1.1 now covers mappings too and names the regex features XPath lacks. The Jena pitfall says 6.3 writes quad CONSTRUCT results again, that JENA_HOME must be set explicitly, and that --results=NQ streams where the default pretty TriG buffers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r from the CONSTRUCT mapping The same 4.8M-row CSV was converted three ways with the same output (110,331,470 distinct quads): one mapping per row in 55 minutes, a 50-second pre-pass then five mappings in 18, and a one-pass script in 2. The skill now orders them: the mapping by default; a pre-pass that settles keys, splits lists and writes shared documents once, leaving URLs and vocabulary to the mappings; a script when run time matters more than keeping the mapping in SPARQL. A pitfall covers a stalled docker run -i under parallel load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Following
ldh:datasetsection 4 ("build the dataset standalone") on a real 4.8M-row, 1.9 GB CSV, usingatomgraph/csv2rdfand a quadCONSTRUCTrun byarq, ran into problems the skill does not cover. The mapping was then run side by side with a one-pass script over the same rows. The two outputs match except for 146 of 110M distinct quads, both differences explained below.What changes in
plugins/ldh/skills/dataset/SKILL.mdapf:property functions orafn:functions.\b,(?:…),(?U), lookarounds.$baseand$createdwithsedwithout breaking"$1"replacements.%20, empty cells produce no triple, cell ends are trimmed of spaces and control characters, and the default--max-chars-per-columnis 4096.--results=NQ.dct:created:NOW()differs on each chunked run and gives a document several values, so substitute one constant.arqrun":awk, adding a row-number column for rows with no natural key--data, with the key defaulted byCOALESCE(…, ""); anOPTIONALon an unbound key matched every entry and made the run more than 5× slowerVALUESindex instead ofapf:strSplit(tested with Jena 6.3 andqparse --strict)arq6.1 still fails on quadCONSTRUCT; 6.3.0 writes it again (checked with the default output,--results=NQand--results=TriG).JENA_HOMEexplicitly, because a${JENA_HOME:-…}default keeps a 6.x install from the user's profile.--results=NQstreams.CHANGELOG.mdgets a line under 6.6.0 > Changed.The two differences
\betaupstream). csv2rdf trims it from the start of a cell and Python'sstrip()keeps it, so 3 entities got different names and URLs.Mapping, pre-pass or script (second commit)
The same CSV was converted three ways. All three gave 110,331,470 distinct quads:
CONSTRUCTper row, splitting lists in SPARQL (6 workers)CONSTRUCTs (6 workers)The skill now gives an order of preference:
The pre-pass output matches the one-pass script's except for the 32 rows csv2rdf trims of a control character. It also removes the duplicate titles that the single mapping gives to 27 documents.
The pitfalls gain one more entry. A
docker run -icsv2rdf conversion stalled under parallel load: the container sat idle and Docker could not remove it. The stalled chunk was rerun with the CSV2RDF jar.🤖 Generated with Claude Code