1719
1719
result = CHKInventory(search_key_name)
1720
1720
result.revision_id = inventory.revision_id
1721
1721
result.root_id = inventory.root.file_id
1723
entry_to_bytes = result._entry_to_bytes
1724
parent_id_basename_key = result._parent_id_basename_key
1725
id_to_entry_dict = {}
1726
parent_id_basename_dict = {}
1727
for path, entry in inventory.iter_entries():
1728
id_to_entry_dict[(entry.file_id,)] = entry_to_bytes(entry)
1729
p_id_key = parent_id_basename_key(entry)
1730
parent_id_basename_dict[p_id_key] = entry.file_id
1722
1732
search_key_func = chk_map.search_key_registry.get(search_key_name)
1723
result.id_to_entry = chk_map.CHKMap(chk_store, None, search_key_func)
1724
result.id_to_entry._root_node.set_maximum_size(maximum_size)
1733
root_key = chk_map.CHKMap.from_dict(chk_store, id_to_entry_dict,
1734
maximum_size=maximum_size, key_width=1,
1735
search_key_func=search_key_func)
1736
result.id_to_entry = chk_map.CHKMap(chk_store, root_key,
1738
root_key = chk_map.CHKMap.from_dict(chk_store,
1739
parent_id_basename_dict,
1740
maximum_size=maximum_size, key_width=2,
1741
search_key_func=search_key_func)
1726
1742
result.parent_id_basename_to_file_id = chk_map.CHKMap(chk_store,
1727
None, search_key_func)
1728
result.parent_id_basename_to_file_id._root_node.set_maximum_size(
1730
result.parent_id_basename_to_file_id._root_node._key_width = 2
1731
parent_id_delta = []
1732
for path, entry in inventory.iter_entries():
1733
file_id_delta.append((None, (entry.file_id,),
1734
result._entry_to_bytes(entry)))
1735
parent_id_delta.append(
1736
(None, result._parent_id_basename_key(entry),
1738
result.id_to_entry.apply_delta(file_id_delta)
1739
result.parent_id_basename_to_file_id.apply_delta(parent_id_delta)
1743
root_key, search_key_func)
1742
1746
def _parent_id_basename_key(self, entry):