ontometer_corpus.store.index¶
The tracked object index (corpus/objects.tsv) and local store verification.
The index lists every object the corpus references: its SHA-256, its size and
its path relative to the store root. A store satisfies an index when every
listed hash is present with the listed size (and, with deep, the listed
hash). Presence is decided by hash, not by path, because the fetcher keeps the
extension of the first download of a given content.
Attributes¶
INDEX_HEADER = 'file_hash\tsize\tpath'
module-attribute
¶
HASH_LEN = 64
module-attribute
¶
Classes¶
IndexMissingAtRev
¶
MissingObjects
¶
ObjectEntry
dataclass
¶
One referenced object: content hash, size in bytes, store-relative POSIX path.
Source code in ontometer_corpus/store/index.py
VerifyReport
dataclass
¶
Differences between a local store and an index.
Source code in ontometer_corpus/store/index.py
Attributes¶
missing = field(default_factory=list)
class-attribute
instance-attribute
¶
wrong_size = field(default_factory=list)
class-attribute
instance-attribute
¶
wrong_hash = field(default_factory=list)
class-attribute
instance-attribute
¶
orphans = field(default_factory=list)
class-attribute
instance-attribute
¶
Methods:¶
__init__(missing=list(), wrong_size=list(), wrong_hash=list(), orphans=list())
¶
ok()
¶
Functions:¶
build_index(paths)
¶
Index every object corpus.db references, sized from the local store.
Raises:
| Type | Description |
|---|---|
MissingObjects
|
some referenced object is not in the store. |
Source code in ontometer_corpus/store/index.py
write_index(entries, dest)
¶
Write the index canonically: header, rows sorted by hash, LF endings.
Source code in ontometer_corpus/store/index.py
parse_index(text)
¶
Read an index written by :func:write_index.
Raises:
| Type | Description |
|---|---|
ValueError
|
the text is not an object index. |
Source code in ontometer_corpus/store/index.py
index_at_rev(corpus_dir, rev)
¶
The index in the working tree (rev=None) or at a git revision.
Raises:
| Type | Description |
|---|---|
IndexMissingAtRev
|
there is no index there. |
Source code in ontometer_corpus/store/index.py
local_objects(paths)
¶
Every object file in the local store, by the hash its name starts with.
Source code in ontometer_corpus/store/index.py
verify(paths, entries, *, deep=False)
¶
Compare the local store with an index; deep re-hashes every present object.
Source code in ontometer_corpus/store/index.py
move_orphans(report, dest)
¶
Move orphaned objects under dest, keeping their store-relative paths.