Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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:

FileUsed for
frwiki-<date>-page.sql.gzTitles, namespaces, which pages are redirects
frwiki-<date>-redirect.sql.gzWhere each redirect points
frwiki-<date>-linktarget.sql.gzLink targets, by title
frwiki-<date>-pagelinks.sql.gzLinks, from a page to a link target
frwiki-<date>-page_props.sql.gzThe Wikidata item of each article
clickstream-frwiki-<month>.tsv.gzHow 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.

  • download skips files that are already there with the right size, and resumes a .part file with an HTTP range request.
  • decompress skips files that are already decompressed.
  • download does not query Wikidata again if the categories file exists. Delete it to refresh.

provision is the exception: it starts each table over.