| 78 | }; |
| 79 | |
| 80 | void EptAddonWriter::HierarchyWriter::write(const std::string& hierarchyDir, NL::json& curr, |
| 81 | const ept::Key& key) const |
| 82 | { |
| 83 | auto it = m_hierarchy.find(key); |
| 84 | if (it == m_hierarchy.end()) |
| 85 | return; |
| 86 | |
| 87 | const ept::Overlap& overlap = *it; |
| 88 | if (!overlap.m_count) |
| 89 | return; |
| 90 | |
| 91 | const std::string keyName = key.toString(); |
| 92 | if (m_step && key.d && (key.d % m_step == 0)) |
| 93 | { |
| 94 | curr[keyName] = -1; |
| 95 | |
| 96 | // Create a new hierarchy subtree. |
| 97 | NL::json next {{ keyName, overlap.m_count }}; |
| 98 | |
| 99 | for (uint64_t dir(0); dir < 8; ++dir) |
| 100 | write(hierarchyDir, next, key.bisect(dir)); |
| 101 | |
| 102 | std::string filename = hierarchyDir + keyName + ".json"; |
| 103 | std::string data = next.dump(); |
| 104 | m_pool.add([this, filename, data]() |
| 105 | { |
| 106 | m_connector.put(filename, data); |
| 107 | }); |
| 108 | } |
| 109 | else |
| 110 | { |
| 111 | curr[keyName] = overlap.m_count; |
| 112 | for (uint64_t dir(0); dir < 8; ++dir) |
| 113 | write(hierarchyDir, curr, key.bisect(dir)); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | CREATE_STATIC_STAGE(EptAddonWriter, s_info) |
| 118 | |