| 193 | } |
| 194 | |
| 195 | void EptAddonWriter::writeOne(const PointViewPtr view, const ept::Addon& addon, |
| 196 | HierarchyWriter& writer) const |
| 197 | { |
| 198 | std::vector<std::vector<char>> buffers(m_hierarchy->size()); |
| 199 | |
| 200 | // Create an addon buffer for each node we're going to write. |
| 201 | |
| 202 | size_t itemSize = Dimension::size(addon.type()); |
| 203 | for (const ept::Overlap& overlap : *m_hierarchy) |
| 204 | { |
| 205 | std::vector<char>& b = buffers[overlap.m_nodeId - 1]; |
| 206 | b.resize(overlap.m_count * itemSize); |
| 207 | } |
| 208 | |
| 209 | // Fill in our buffers with the data from the view. |
| 210 | PointRef pr(*view); |
| 211 | uint64_t nodeId(0); |
| 212 | uint64_t pointId(0); |
| 213 | for (PointId i = 0; i < view->size(); ++i) |
| 214 | { |
| 215 | pr.setPointId(i); |
| 216 | nodeId = pr.getFieldAs<uint64_t>(m_nodeIdDim); |
| 217 | |
| 218 | // Node IDs are 1-based to distinguish points that do not come from the |
| 219 | // EPT reader. |
| 220 | if (!nodeId) |
| 221 | continue; |
| 222 | |
| 223 | pointId = pr.getFieldAs<uint64_t>(m_pointIdDim); |
| 224 | |
| 225 | auto& buffer(buffers.at(nodeId - 1)); |
| 226 | assert(pointId * itemSize + itemSize <= buffer.size()); |
| 227 | char* dst = buffer.data() + pointId * itemSize; |
| 228 | pr.getField(dst, addon.externalId(), addon.type()); |
| 229 | } |
| 230 | |
| 231 | std::string dataDir = addon.dataDir(); |
| 232 | |
| 233 | m_connector->makeDir(dataDir); |
| 234 | |
| 235 | // Write the binary dimension data for the addon. |
| 236 | for (const ept::Overlap& overlap : *m_hierarchy) |
| 237 | { |
| 238 | std::vector<char>& buffer = buffers.at(overlap.m_nodeId - 1); |
| 239 | std::string filename = dataDir + overlap.m_key.toString() + ".bin"; |
| 240 | m_pool->add([this, filename, &buffer]() |
| 241 | { |
| 242 | m_connector->put(filename, buffer); |
| 243 | }); |
| 244 | } |
| 245 | |
| 246 | m_pool->await(); |
| 247 | |
| 248 | // Write the addon hierarchy data. |
| 249 | NL::json h; |
| 250 | ept::Key key; |
| 251 | key.b = m_info->bounds(); |
| 252 |
nothing calls this directly
no test coverage detected