Read Shard format#
The Read Shard has the following structure:
- bytes [0, - SHARD_OFFSET_MAGIC[: The shard magic
- bytes [ - SHARD_OFFSET_MAGIC,- objects_position[: The header (- shard_header_t)
- bytes [ - objects_position,- index_position[:- objects_counttimes the size of the object (- u_int64_t) followed by the content of the object
- bytes [ - index_position,- hash_position[: An array of index entries. The size of the array is provided by- cmph_sizeafter building the hash function. An index entry is made of the key (of- SHARD_KEY_LENbytes) and the object position (- u_int64_t) in the range [- objects_position,- index_position[. If the object position is- UINT64_MAX, this means the object has been deleted.
- bytes [ - hash_position, …[: The hash function, as written by- cmph_dump
In more details:
| Section | pos | description (length) | 
|---|---|---|
| SHARD_MAGIC | 0 | SHARD_OFFSET_MAGIC (32) | 
| header | 32 | Header (56) | 
| 
 | uint64_t (8) | |
| 
 | uint64_t (8) | |
| 
 | uint64_t (8) | |
| 
 | uint64_t (8) | |
| 
 | uint64_t (8) | |
| 
 | uint64_t (8) | |
| 
 | uint64_t (8) | |
| Objects | <op> | |
| 
 | uint64_t (8) | |
| 
 | bytes (<object0 size>) | |
| 
 | uint64_t (8) | |
| 
 | bytes (<object1 size> | |
| … | ||
| Index | <ip> | |
| 
 | SHARD_KEY_LEN (32) | |
| 
 | uint64_t (8) | |
| … | ||
| Hash map | <hp> | |
| 
 | <as written by cmph_dump> | 
SHARD_MAGIC is the constant SWHShard (with \x00 padding to 32
characters).
Index entries for deleted content are using the special value
{key=\x00...\x00, offset=2**64-1}.