Skip to content

The Data Files ​

A run writes its files under the data directory Settings names, which is .cache/data under the project's root unless a setting moves it, and git tracks none of them. The table below names each file, written by mise run docs:render from the code that names it, and The Store sets out when a fetch downloads a file again and when the index is built again.

WritesReads

Commanddownloads/1.1 GBindex/459.9 MB
pgnmentor.com/manifest.jsongames.parquetleft.parquetpositions.binmanifest.json
fetchDownloads the files the store draws its games from.
scotchfetchgamesscotch fetch games writes downloads/www.pgnmentor.com/scotch fetch games writes downloads/manifest.json
indexBuilds the index of stored games from the fetched files.
scotchindexgamesscotch index games reads downloads/www.pgnmentor.com/scotch index games reads downloads/manifest.jsonscotch index games writes index/games.parquetscotch index games writes index/left.parquetscotch index games writes index/positions.binscotch index games writes index/manifest.json
matchMatches a submitted game against the stored games.
scotchmatchgamescotch match game reads downloads/manifest.jsonscotch match game reads index/games.parquetscotch match game reads index/left.parquetscotch match game reads index/positions.binscotch match game reads index/manifest.json
scotchmatchgamesscotch match games reads downloads/manifest.jsonscotch match games reads index/games.parquetscotch match games reads index/left.parquetscotch match games reads index/positions.binscotch match games reads index/manifest.json
showPrints a stored game, a position, or what the store holds.
scotchshowgamescotch show game reads downloads/manifest.jsonscotch show game reads index/games.parquetscotch show game reads index/left.parquetscotch show game reads index/positions.binscotch show game reads index/manifest.json
scotchshowpositionscotch show position reads downloads/manifest.jsonscotch show position reads index/games.parquetscotch show position reads index/left.parquetscotch show position reads index/positions.binscotch show position reads index/manifest.json
scotchshowstorescotch show store reads downloads/manifest.jsonscotch show store reads index/games.parquetscotch show store reads index/left.parquetscotch show store reads index/positions.binscotch show store reads index/manifest.json
citePrints the footnote definition citing a source.
scotchcitesource
Commands
8
Writes
6
Reads
27
Touches
6 of 6 files
The table beneath
PathWritten ByHolds
.cache/data/downloads/www.pgnmentor.com/scotch fetch gamesEach file of the host sources.toml declares, under the path its address names
.cache/data/downloads/manifest.jsonscotch fetch gamesThe record of each fetched file, keyed by its address
.cache/data/index/games.parquetscotch index gamesOne row for each stored game
.cache/data/index/left.parquetscotch index gamesOne row for each game left out, beside its reason
.cache/data/index/positions.binscotch index gamesEvery position the stored games reach, beside their moves
.cache/data/index/manifest.jsonscotch index gamesA copy of the manifest the files were read under

The Manifest ​

scotch fetch games keeps manifest.json beside the folder of each host, recording each file it fetched under the address it was fetched from, with the fields Download declares:

FieldTypeMeaning
etagA string, or nullThe entity tag the server sent with the file, which a later fetch sends back through If-None-Match, left empty where it sent none.
sha256A stringThe SHA-256 digest of the file's bytes, in hexadecimal.
size_bytesAn integer from 0The size of the file.
fetchedA date and a timeThe instant the file was fetched, in UTC.

The Games Table ​

games.parquet is an Apache Parquet table holding one row for each stored game, in the columns COLUMNS in src/scotch/index/schemas.py declares:

ColumnTypeMeaning
gameUInt32The game's place in the index's order, from 0
errorsList(String)Each error the reader recorded
originStruct({'address': String, 'place': UInt32})The address of the file the game was read from and its place there, counting from 1, as Origin holds them
pliesUInt16The count of the mainline's plies, whose positions the index keys
resultStringThe Result tag
tagsList(Struct({'name': String, 'value': String}))Every other tag pair, each as a name and a value

The Positions File ​

positions.bin holds every position the stored games reach, keyed by its Zobrist hash, beside each game's moves, so a command maps it into memory and reads only what its lookup reaches. A slot is a game's place in the file once the games are sorted by their moves. The file opens on a head locating every piece, then holds the key pieces, each the keys sharing their leading bits, then the game pieces, each a run of 128 slots, so a reader that holds the head reads, for each lookup, the one key piece holding its key and the game pieces holding the games it plays through. Its sections follow one another in the order SECTIONS in rust/src/positions.rs declares, each key piece repeating the sections from once to lists and each game piece the sections from numbers to moves:

SectionHeld AsHolds
magic8 bytesThe bytes scotch-2, which change with the layout
countAn integerThe positions the stored games reach
distinctAn integerThe distinct keys the stored games reach
gamesAn integerThe stored games
piecesAn Elias-Fano sequenceThe byte past the head each key piece opens at, beside the byte past the last
shelvesAn Elias-Fano sequenceThe byte past the last key piece each game piece opens at, beside the byte past the last
onceAn Elias-Fano sequenceThe key piece's leading bits of each key one position of one game reaches
blocksA compact vectorThe block of slots holding the game reaching each key of once
sharedAn Elias-Fano sequenceThe key piece's leading bits of each key several positions reach
boundariesAn Elias-Fano sequenceThe byte of lists each key of shared opens its list at, beside the byte past the last
listsBytesThe slots reaching each key of shared, by the ply each reaches it at
numbersA compact vectorEach of the game piece's slots' game, its row in games.parquet
standingsA compact vectorEach of its slots' rank among games tied on a run
datesA compact vectorEach of its slots' Date tag as a number
resultsA compact vectorEach of its slots' result, as its place among a win for White, a draw, a win for Black, and any other
pliesA compact vectorThe count of each of its slots' mainline plies, whose positions the index keys
offsetsAn Elias-Fano sequenceThe byte of moves each of its slots' moves open at, beside the byte past the last
startedA vectorEach of its slots whose tags name its start, by its place among them
fensA vectorThe FEN tag of each slot started lists
variantsA vectorThe Variant tag of each slot started lists
movesBytesEach of its slots' mainline, encoded
slotsA compact vectorEach game's slot

The Published Store ​

scotch publish store writes the index as the one file the Viewer reads in the browser, into store/ under the data directory beside a manifest.json naming it. The file opens on a head laid out as the head of positions.bin is, locating each piece of this file, then holds each key piece as it stands, then each game piece as a block of raw DEFLATE1 holding the piece's length as 4 bytes little-endian, the piece, and its games' tags in slot order as a JSON array, and takes its name from the first 16 hexadecimal digits of its SHA-256 digest, so the name changes whenever the bytes do and a reader finds a new store through the manifest alone. The manifest holds the file's store name and the length of its head in bytes, which a reader fetches first and reads every piece's place from, and the workflow that publishes it adds the commit the store was built from.

The Manifest Copy ​

scotch index games copies the manifest the files were read under beside the index. A command reading the index compares that copy with the manifest a later fetch wrote, and where the two record different bytes for a file, scotch match game and every other such command print the line below before their output, written here with the data directory as .cache/data, which a run prints as its full path under the project's root:

text
The files under .cache/data/downloads have changed since the index was built from them, so run `scotch index games` to rebuild it

Sources

  1. Deutsch, L. Peter. 1996. "DEFLATE Compressed Data Format Specification Version 1.3," RFC 1951. https://www.rfc-editor.org/rfc/rfc1951 ↩︎

Built from22ebd11
CodeJybbs/scotch
GamesPGN Mentor
Crateshakmaty, GPL
FacesSIL OFL 1.1
PiecesCburnett, BSD

Scotch 0.2.0, under the GPL-3.0-or-later.