Crystalia Data Model¶
Crystalia is a set of tools for describing and comparing large datasets. The Collector surveys data, Viz shows and compares the results, and the Tower coordinates the work. The data model is the format they share: a LinkML schema and a Python package that describe a dataset by its content.
The problem it solves¶
A large dataset gets copied, moved, renamed, repackaged and partly updated. After a while it is hard to say whether two copies still hold the same data, which one is complete, or whether one dataset sits inside another. Hashing every byte of every copy answers the question, but it is slow, it cannot run in parallel over one file, and it says nothing when the copies differ only a little.
Crystalia answers with descriptors: small facts computed from content.
- Several levels of cost. A descriptor can be the size of a file and a hash of its first blocks, a hash of both ends, or a hash of every byte. A cheap descriptor rules out most mismatches; a costly one confirms a match.
- Stated strength. Each descriptor type declares how strong it is as evidence and how much of the item it covers, so a tool knows what a match proves.
- Trees, not only files. The descriptor of a directory is built from the names and descriptors of its entries. Two directories with equal content have the same descriptor, and a dataset inside a larger one shows up as a shared descriptor.
- Computed in parallel. Descriptors of separate files and directories are independent, so many workers can produce them and their results merge into one catalog.
- Content gives the id. The id of a descriptor is computed from its type and values. Equal content has the same id in every catalog, so comparing two datasets is finding the descriptors they share.
DCAT records what a dataset is about and where to get it. BagIt lists one checksum per file. Crystalia records evidence about the content itself, at several strengths, for files and whole trees.
The model in brief¶
A survey walks a dataset and writes a catalog. The catalog lists root items; every file and directory under a root is an item. Each item carries descriptors.
| Class | What it is |
|---|---|
| Survey | One run of a collector: when it ran, who ran it, on which host, with which methods |
| Catalog | What a survey wrote: the root items, the counts, and the dataset's identifier and licence |
| Item | A file or a directory, named within its parent and linked to it with isPartOf |
| Descriptor | A fact computed from content, identified by that content |
| Method | The procedure and parameters that produced a descriptor |
| StorageLocation | The address of one copy of a dataset, attached to its root item |
| Collector, Person, Host | The software, the operator and the machine of a survey |
What the data is and where it is kept are recorded apart: descriptors hold the first, the storage location of a root item holds the second. Moving a dataset changes its location and none of its descriptors.
The Data Dictionary is the full reference for every class and slot.
A short example¶
from crystalia_data_model.types import (
get_coverage,
grade,
mint_file_size,
mint_glimpse_content,
mint_glimpse_dir_content,
mint_md5,
mint_md5_region,
)
# The same bytes give the same descriptor, whatever the file is called and wherever it is kept.
here = mint_md5("9e107d9d372bb6826bd81d3542a419d6", length=1_048_576)
there = mint_md5("9e107d9d372bb6826bd81d3542a419d6", length=1_048_576)
assert here.id == there.id
print(here.id, grade(here), get_coverage(here))
# cryd:8c60c6f8a67ebb13f8dde19c11ad8d06 comparison 1.0
# A cheaper descriptor: the size of a file and the hash of its first 2 KiB.
def glimpse(size: int, head_md5: str):
head = mint_md5_region(0, min(size, 2048), head_md5)
return mint_glimpse_content(file_size=mint_file_size(size), head=head)
# A folder descriptor is built from the names and descriptors of its entries.
entries = [
("specimen.tiff", glimpse(1_048_576, "0cc175b9c0f1b6a831c399e269772661")),
("notes.txt", glimpse(512, "92eb5ffee6ae2fec3ad71c777531578f")),
]
folder = mint_glimpse_dir_content(2, entries)
print(folder.id, grade(folder))
# cryd:2aff9d3463da96a21aff81b6f7dc50b2 comparison
The Consumer Contract lists the rules a tool must follow to write or read catalogs, and the whole Python API.
Standards it builds on¶
- W3C PROV for provenance. A survey is an activity, a collector and its operator are agents, and items, descriptors and catalogs are entities, so a PROV tool can read a catalog.
- Dublin Core for
containment (
isPartOf) and for a dataset's identifier, licence and conformance. - schema.org for software version, repository and runtime.
- LinkML as the schema language, from which the artifacts below are generated.
The schema is five files in
src/crystalia_data_model/schema:
linkml_crystalia.yaml and the subsets it imports, prov.yaml, dcterms.yaml, schemaorg.yaml
and crystalia_base.yaml.
Generated artifacts¶
Generated from the schema, in the
project/ directory:
| Artifact | File | Use |
|---|---|---|
| OWL | linkml_crystalia.owl.ttl |
Ontology in Turtle |
| Pydantic | linkml_crystalia.py |
Python models |
| Protobuf | linkml_crystalia.proto |
Protocol Buffers schema |
| JSON Schema | linkml_crystalia.schema.json |
Validation of JSON data |
| JSON-LD | linkml_crystalia.context.jsonld |
Context for linked data |
| SHACL | linkml_crystalia.shacl.ttl |
Validation of RDF data |
| TypeScript | linkml_crystalia.ts |
Type definitions |
Working on the model¶
git clone https://github.com/vladistan/crystalia-data-model.git
cd crystalia-data-model
uv sync --group dev # install dependencies
just gen-project # regenerate the artifacts and the data dictionary
just test # run the tests
just serve-docs # serve this site locally
Citation¶
If you use Crystalia in your research, please cite:
V. Korolev and A. Joshi, "Crystalia: Flexible and Efficient Method for Large Dataset Lineage Tracking," 2024 IEEE International Conference on Big Data (BigData), Washington, DC, USA, 2024, pp. 3431-3440, doi: 10.1109/bigdata62323.2024.10826067.
@inproceedings{korolev2024crystalia,
author = {Korolev, Vladimir and Joshi, Anupam},
title = {Crystalia: Flexible and Efficient Method for Large Dataset Lineage Tracking},
booktitle = {2024 IEEE International Conference on Big Data (BigData)},
year = {2024},
pages = {3431--3440},
doi = {10.1109/bigdata62323.2024.10826067},
address = {Washington, DC, USA}
}
Source¶
- Repository: github.com/vladistan/crystalia-data-model
- Documentation: crystalia.link
- Licence: MIT