The build pipeline
Building a graph takes four commands. Each one reads the output of the one before.
dumps.wikimedia.org ──download──▶ dumps/*.gz ──decompress──▶ dumps/*.sql
Wikidata query service ──download──▶ dumps/frwiki-wikidata-categories.tsv
dumps/*.sql ──provision──▶ MariaDB tables
MariaDB tables + categories .tsv + clickstream .tsv ──build──▶ dumps/graph.wgrf
1. download
Fetches, from a Wikimedia dumps mirror:
| File | Used for |
|---|---|
frwiki-<date>-page.sql.gz | Titles, namespaces, which pages are redirects |
frwiki-<date>-redirect.sql.gz | Where each redirect points |
frwiki-<date>-linktarget.sql.gz | Link targets, by title |
frwiki-<date>-pagelinks.sql.gz | Links, from a page to a link target |
frwiki-<date>-page_props.sql.gz | The Wikidata item of each article |
clickstream-frwiki-<month>.tsv.gz | How often readers follow each link |
With --date latest (the default), it picks the newest dump run where all five tables are
finished.
It then asks the Wikidata Query Service which items are dates or countries, and writes
frwiki-wikidata-categories.tsv. See download.
2. decompress
Unpacks every .gz file in the directory, several files at once. See
decompress.
3. provision
Loads every .sql file into MariaDB with the mariadb client. Each table is dropped and created
again. This is the slow step: pagelinks alone is about 9 GB of SQL. See
provision.
4. build
Reads five tables from MariaDB, the categories file and the clickstream when there is one, then
writes graph.wgrf. The database is only read, never changed. See build.
Safe to stop and run again
Every step writes to a temporary name first (.part or .tmp) and renames the file only when it
is complete. A file under its final name is always complete.
downloadskips files that are already there with the right size, and resumes a.partfile with an HTTP range request.decompressskips files that are already decompressed.downloaddoes not query Wikidata again if the categories file exists. Delete it to refresh.
provision is the exception: it starts each table over.