synology_apm_repo.sdk.format.chunkmap module¶
ChunkMapRecord — the 20-byte record describing one segment of a
file’s content within a composition record (FORMAT-SPEC.md: ChunkMapRecord).
Every byte of every restorable unit is reached by walking an array of
these; the ambiguity between the two record kinds (MAPPING/ZERO) is
resolved once, here.
- class synology_apm_repo.sdk.format.chunkmap.ChunkMapKind(*values)¶
Bases:
EnumType(FORMAT-SPEC.md: ChunkMapRecord). Values match the on-disk encoding exactly — do not renumber.- MAPPING = 0¶
- ZERO = 1¶
- class synology_apm_repo.sdk.format.chunkmap.ChunkMapEntry(kind, file_offset, is_inherit, addr, map_num, repeat)¶
Bases:
objectOne decoded
ChunkMapRecord.map_num’s meaning depends onkind: forChunkMapKind.MAPPINGit is the address template length in chunks (the template repeats1 + repeattimes); forChunkMapKind.ZEROit is the literal chunk count covered (repeatis always 0 there). Both come from bytes [16,20), split differently.- kind: ChunkMapKind¶
- file_offset: int¶
fileChunkIdx << 12— the byte offset within the described file where this record’s coverage begins.
- is_inherit: bool¶
The
INHERITbit, purely descriptive (“carried over unchanged from a reference version”); reading never depends on it (FORMAT-SPEC.md: Hole vs. Zero vs. INHERIT).
- addr: ChunkAddress | None¶
The chunk’s base address in Pool.
NoneforChunkMapKind.ZERO.
- synology_apm_repo.sdk.format.chunkmap.parse_chunk_map_record(data)¶
Decode one 20-byte
ChunkMapRecordfrom the start ofdata(datamay be longer; only the first 20 bytes are consulted).A Mapping record’s embedded
ChunkAddressis not range-checked (seeChunkAddress).- Raises:
FormatError –
datais shorter than 20 bytes.DataCorruptError – The type nibble is neither 0 (Mapping) nor 1 (Zero).
- synology_apm_repo.sdk.format.chunkmap.chunk_map_end_offset(page_bytes, index)¶
ChunkMapEntry.end_offsetof recordindexinpage_bytes, read without building the entry, for a binary search over a page.- Raises:
FormatError –
page_bytesends before recordindexdoes.DataCorruptError – The record has an unknown type.
- synology_apm_repo.sdk.format.chunkmap.iter_chunk_map_page(page_bytes, count)¶
Lazily decode
countconsecutiveChunkMapRecords starting at the front ofpage_bytes; the batch form ofparse_chunk_map_record.- Raises:
FormatError –
page_bytesholds fewer thancountrecords.DataCorruptError – A record has an unknown type.