1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-03 05:35:58 +00:00

hashindex: cleanups, docstrings

This commit is contained in:
Thomas Waldmann 2024-10-25 18:20:54 +02:00
parent 2c9a5a7bb7
commit bacb923571
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01

View file

@ -2,24 +2,19 @@ from collections import namedtuple
import os
import struct
cimport cython
from borghash cimport _borghash
API_VERSION = '1.2_01'
cdef _NoDefault = object()
_MAX_VALUE = 4294966271UL # 2**32 - 1025
assert _MAX_VALUE % 2 == 1
ChunkIndexEntry = namedtuple('ChunkIndexEntry', 'refcount size')
class ChunkIndex:
"""
Mapping of 32 byte keys to (refcount, size), which are all 32-bit unsigned.
Mapping from key256 to (refcount32, size32) to track chunks in the repository.
"""
MAX_VALUE = 2**32 - 1 # borghash has the full uint32_t range
@ -83,8 +78,9 @@ FuseVersionsIndexEntry = namedtuple('FuseVersionsEntry', 'version hash')
class FuseVersionsIndex:
# key: 16 bytes, value: 4 byte version + 16 bytes file contents hash
"""
Mapping from key128 to (file_version32, file_content_hash128) to support the FUSE versions view.
"""
def __init__(self):
self.ht = _borghash.HashTableNT(key_size=16, value_format="<I16s", namedtuple_type=FuseVersionsIndexEntry)
@ -110,11 +106,13 @@ class FuseVersionsIndex:
return default
NSIndex1Entry = namedtuple('NSIndex1bEntry', 'segment offset')
NSIndex1Entry = namedtuple('NSIndex1Entry', 'segment offset')
class NSIndex1: # legacy borg 1.x
class NSIndex1:
"""
Mapping from key256 to (segment32, offset32), as used by legacy repo index of borg 1.x.
"""
MAX_VALUE = 2**32 - 1 # borghash has the full uint32_t range
MAGIC = b"BORG_IDX" # borg 1.x
HEADER_FMT = "<8sIIBB" # magic, entries, buckets, ksize, vsize