Skip to main content

Software Heritage Shard File Format

Project description

This module implements the support and tooling to manipulate SWH Shard files based on a perfect hash table, typically used by the software heritage object storage.

It is both a Python extension that can be used as a library to manipulate SWH shard files, and a set of command line tools.

Quick Start

This package uses pybind11 to build the wrapper around the cmph minimal perfect hashmap library. To build the binary extension, in addition to the python development tools, you will need cmph, gtest and valgrind. On a Debian system, you can install these using:

sudo apt install build-essential python3-dev libcmph-dev libgtest-dev valgrind lcov

Command Line Tool

You may use several methods to install swh-shard, e.g. using uv or pip.

For example:

$ uv tool install swh-shard
[...]
Installed 1 executable: swh-shard

$ swh-shard
Usage: swh-shard [OPTIONS] COMMAND [ARGS]...

  Software Heritage Shard tools.

Options:
  -C, --config-file FILE  Configuration file.
  -h, --help              Show this message and exit.

Commands:
  create  Create a shard file from given files
  get     List objects in a shard file
  info    Display shard file information
  ls      List objects in a shard file

Then you can create a shard file from local files:

$ swh-shard create volume.shard *.py
There are 3 entries
Checking files to add  [####################################]  100%
after deduplication: 3 entries
Adding files to the shard  [####################################]  100%
Done

This will use the sha256 checksum of each file content given as argument as key in the shard file.

Then you can check the header of the shard file:

$ swh-shard info volume.shard
Shard volume.shard
├─version:    1
├─objects:    3
│ ├─position: 512
│ └─size:     5633
├─index
│ ├─position: 6145
│ └─size:     440
└─hash
  └─position: 6585

List the content of a shard:

$ swh-shard ls volume.shard
8bb71bce4885c526bb4114295f5b2b9a23a50e4a8d554c17418d1874b1a233ac: 834 bytes
06340a7a5fa9e18d72a587a69e4dc7e79f4d6a56632ea6900c22575dc207b07f: 4210 bytes
d39790a3af51286d2d10d73e72e2447cf97b149ff2d8e275b200a1ee33e4a3c5: 565 bytes

Retrieve an object from a shard:

$ swh-shard get volume.shard 06340a7a5fa9e18d72a587a69e4dc7e79f4d6a56632ea6900c22575dc207b07f | sha256sum
06340a7a5fa9e18d72a587a69e4dc7e79f4d6a56632ea6900c22575dc207b07f  -

And delete one or more objects from a shard:

$ swh-shard delete volume.shard 06340a7a5fa9e18d72a587a69e4dc7e79f4d6a56632ea6900c22575dc207b07f
About to remove these objects from the shard file misc/volume.shard
06340a7a5fa9e18d72a587a69e4dc7e79f4d6a56632ea6900c22575dc207b07f (4210 bytes)
Proceed? [y/N]: y
Deleting objects from the shard  [####################################]  100%
Done

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swh_shard-2.2.1.tar.gz (42.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

swh_shard-2.2.1-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (191.7 kB view details)

Uploaded PyPymanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

swh_shard-2.2.1-pp310-pypy310_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (190.6 kB view details)

Uploaded PyPymanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

swh_shard-2.2.1-cp314-cp314t-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

swh_shard-2.2.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (194.6 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

swh_shard-2.2.1-cp314-cp314-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

swh_shard-2.2.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (193.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

swh_shard-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

swh_shard-2.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (193.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

swh_shard-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

swh_shard-2.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (193.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

swh_shard-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

swh_shard-2.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (191.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

swh_shard-2.2.1-cp310-cp310-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

swh_shard-2.2.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (190.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file swh_shard-2.2.1.tar.gz.

File metadata

  • Download URL: swh_shard-2.2.1.tar.gz
  • Upload date:
  • Size: 42.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.12

File hashes

Hashes for swh_shard-2.2.1.tar.gz
Algorithm Hash digest
SHA256 b2ea8cf61a0fd6e7e74f1aaf5b04688e16a809f1ec85af65b0a55e9eba547c35
MD5 fb5a0db23ae02d6c942a22c4c54a8b1a
BLAKE2b-256 4d340ee4f640faf00c402abefd37b858b4af2f8661df2fefb9e93afc4953bc6f

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d44b217597e8c57106a503102bb89c02710d38255590c584418d9b1c95144f01
MD5 1b220031cc51bdd6e220bb16f840cf7f
BLAKE2b-256 2843abb2a01363cb2a53cbbf87d8d4e3af46a1dfe8fb78e1b890e4a3edcf6c9a

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-pp310-pypy310_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-pp310-pypy310_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5818a5f5e14b87a8a39c37845a30e9114677867442d508a4238d43415089fba3
MD5 94c4ed2068823276646c2992338518bd
BLAKE2b-256 15565fa2959fe4f05fe205e7eb793c30f460b876df374710f80a4f7c9149d958

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 76805c215b3c321e750aa64db53def396b9eb7bccf5ebc04cd2482037abf0a96
MD5 1ec13effa0844793953f3396355d0b8e
BLAKE2b-256 c8f2eaadb2ecb15eee3503844818dfedb3bd70e70168b038b8b79e9f605af23e

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cec24da19be77922fe957fb0ca2492c13b83484f00e311d1b8eac1dd0433a0fa
MD5 b3d4b843294da7e70cde7e291342ec6a
BLAKE2b-256 caba347cd77e339862c3840e2a1bcbae4d79980508b9cf6ca2b3c7b85aabc5bc

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cba07e82ea3dc019c0bc1f09440d02cda14d10c21f398ba8f32342311c45a12e
MD5 617d8465767a99b30a51cc2e72376db0
BLAKE2b-256 49c63604348a1c0b0760e57a79800735fc7ecc15852dcf32efb978cae7149fd6

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b26ba5bbb818794f3f4e64fac231bf0be14f5df32d54721d2177414b3b4617e5
MD5 97dea28e5d63de0619acc54866dd178f
BLAKE2b-256 ae44a017c250ae7bae310278148f644bb8b985167386c4c2e80bcbef17830138

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 95ded4c2b985e7ec03d50ef0ce90c44c3867ee4cf4e32c838e9fed2fe11ca9be
MD5 237b884c55d3064e4d32a3554e2ada45
BLAKE2b-256 15fe7b830b5e7ee8dd70a30f4f0943bbb8cbe629627bbdee509a09a65e2b7d79

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8139e1f63cbf9b85afce7a30eaee5e397d6ef085934590ccac79c7d4dc8cd26e
MD5 37ca17a038047a59b5fba7d2c2f44c8f
BLAKE2b-256 27919352e021d547d3e7e4fc6375ee8c50152b8e39fd9e98f9f05e3f902cbead

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 604f1717700584ec13805b9d67a846c3a5697d92cdc31025a5fbc84fce437aa0
MD5 2bd55613e669d7b0153bb0303e49d048
BLAKE2b-256 daa8600d9e8941d9f81923d0639ac3c41068d1bc2e025e523502bee21f84169b

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 009b99de60dc40e9e75a9c431234a9aeaf9eb6b1a7e6731fa581e98ba169457b
MD5 2e6e9e9c646a55ef6ff7b8b236d5722e
BLAKE2b-256 5f265892903d64455ab896755baccbe6af1da98b49cbc813dbcdfb92c6b13c2d

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6459c1e3ae0b98030d9b0796c4ffd64d2446e2a27ed63c2e6b27599a45728ad5
MD5 560dbe318482081d50119a3cf3b462e7
BLAKE2b-256 2c6a70fbe616ccfa9469e68168734c8d2aaaecac0c103c4cd88affcd1200c356

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0fcd6f9828c0e476537c0701710fbe86f96aea9f6d8b5247cff39549e33e6a35
MD5 adb57171c24a0c1f4f42dc277c09f8d6
BLAKE2b-256 f6cc1f194405641faf7fac76f1978b1ef8e055c7b76bd20d8b0673b24c1b9859

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 091e2405839223b115f4a8b4f264879ca19401d7431d1f2582351c1d91ed65a8
MD5 ceff9a32041aaf57d275934ff09b413d
BLAKE2b-256 a4e22ccdc12734ae9a5a01ab6cddf6f433e042e653d62d3f0cf02c8a00f0dbe6

See more details on using hashes here.

File details

Details for the file swh_shard-2.2.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for swh_shard-2.2.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 492dffb23085c16a40defd6a2f6c183093f56b45e53362eb4ec47882dffd4b8d
MD5 f4591bbc9ded56a6379549d51302d9c2
BLAKE2b-256 00967b60dadcc2bcaeabd75a11e7e4b345a69ef4cd40f4eff6018253e7c1e45f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page