markdown export: convert a location set instead of whole shards - #92
Merged
Conversation
A recovery pass knows which pages it is missing. It gets them out of a columnar query as index locations, and until now there was nothing that turned those locations into a Markdown Parquet dataset. `fetch --batch` streams records and `convert` has no language filter or dedup, so the only way to finish the pass was to export the whole shards those pages live in, which for a few thousand scattered pages is roughly a thousand times the bytes the pages are worth. `markdown export --locations` reads exactly the records the stream points at, with coalesced ranged GETs, and runs the same pipeline over them: same extractor, same language filter, same digest dedup, same schema. Only the source changes, which is why the pack now takes a recordSource rather than a reader, and why the WARC path and the location path share everything after the fetch. A part is to a location run what a shard is to a full export: the unit that gets one parquet file, one ledger entry, and one digest dedup set. `--part-size` cuts the stream in order, so an interrupted run resumes where the ledger says it stopped. A location that will not fetch is skipped rather than failing the part, because a recovery pass runs against an index that can disagree with the archive. warc_bytes reports what the ranged reads actually pulled off the wire, holes included, rather than a shard size. Comparing it against the size of the shards those records live in is the whole argument for the flag.
7 tasks
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.
Closes the second ship gate box on #67.
The gap
The recovery pass in
notes/Spec/2114/03-acquisition-and-crawl.mdends with a set of index locations for the pages we are missing, and nothing turned that set into a Markdown Parquet dataset.fetch --batchstreams the records but only as text or JSON, andconverthas neither--langnor--dedup-digest. The only way to finish the pass wasmarkdown export --shardsover every shard those pages happen to live in. For a few thousand pages scattered across a few hundred WARC files that is on the order of a thousand times the bytes the pages are worth.What this adds
markdown export --locations <file|->reads the location JSONL thatcolumnar locationsandindexemit, and converts exactly those records with coalesced ranged GETs.Everything after the fetch is the pipeline a shard export already uses: the same extractor, the same language filter, the same digest dedup, the same schema, the same ledger and resume. That is deliberate, since a recovery pass that produced a slightly different corpus from an export of the same pages would not be a recovery of anything. The pack now takes a
recordSourcerather than a reader, and the WARC path and the location path share every stage after that.New flags on
markdown export:--locations-for stdin--part-size--gap--max-spanA part is to a location run what a shard is to a full export: the unit that gets one parquet file, one ledger entry, and one digest dedup set. The stream is cut in order, so the same input cuts the same way every time and a ledger from an interrupted run still means what it said.
A location that will not fetch is skipped rather than failing the part. A recovery pass runs against an index that can disagree with the archive, and a run that dies on the first disagreement never finishes.
--locationsbypasses--shards,--source-kind, and the manifest fetch, and it is a usage error with thewetextractor, since WET files have no record offsets to point at.warc_byteson a location run is what the ranged reads actually pulled off the wire, holes between coalesced records included, rather than a shard size. That is the number worth publishing here, because comparing it against the shards those records live in is the whole argument for the flag.Tests
TestPackLocationsConvertsOnlyWhatWasAskedFor: six of twelve records in a served WARC, asserting the filler records never appear, that the six coalesce into fewer requests than one per record, and thatwarc_byteslands between zero and the whole file.TestPackLocationsAppliesLangAndDedup: the same location set with and without--dedup-digestand--lang, checking the drop count and that the kept rows are all the requested language.TestPackLocationsSurvivesABadLocation: one location pointing at a file that is not there, and the part still comes back with the records that were.TestReadLocationPartsandTestReadLocationPartsErrors: the cut into parts including the short tail, order preservation, and the four ways the flag is used wrongly.gofmt,go vet,go test -race ./...,golangci-lint run, andscripts/docs-drift.share all clean. Documented inreference/markdown.mdandreference/cli.md.