Show More
@@ -310,3 +310,30 b' def _to_value(item, block_map):' | |||||
310 | return block_map[id(item)] |
|
310 | return block_map[id(item)] | |
311 | else: |
|
311 | else: | |
312 | return _transform_rev(item) |
|
312 | return _transform_rev(item) | |
|
313 | ||||
|
314 | ||||
|
315 | def parse_data(data): | |||
|
316 | """parse parse nodemap data into a nodemap Trie""" | |||
|
317 | if (len(data) % S_BLOCK.size) != 0: | |||
|
318 | msg = "nodemap data size is not a multiple of block size (%d): %d" | |||
|
319 | raise error.Abort(msg % (S_BLOCK.size, len(data))) | |||
|
320 | if not data: | |||
|
321 | return Block() | |||
|
322 | block_map = {} | |||
|
323 | new_blocks = [] | |||
|
324 | for i in range(0, len(data), S_BLOCK.size): | |||
|
325 | block = Block() | |||
|
326 | ondisk_id = len(block_map) | |||
|
327 | block_map[ondisk_id] = block | |||
|
328 | block_data = data[i : i + S_BLOCK.size] | |||
|
329 | values = S_BLOCK.unpack(block_data) | |||
|
330 | new_blocks.append((block, values)) | |||
|
331 | for b, values in new_blocks: | |||
|
332 | for idx, v in enumerate(values): | |||
|
333 | if v == NO_ENTRY: | |||
|
334 | continue | |||
|
335 | elif v >= 0: | |||
|
336 | b[idx] = block_map[v] | |||
|
337 | else: | |||
|
338 | b[idx] = _transform_rev(v) | |||
|
339 | return block |
General Comments 0
You need to be logged in to leave comments.
Login now