| 38 | } |
| 39 | |
| 40 | bool BufferAssembler::chunk(const std::string& name, |
| 41 | const std::size_t row_offset, |
| 42 | const std::size_t row_count, |
| 43 | const std::span<const std::byte> bytes) { |
| 44 | const auto it = in_progress_.find(name); |
| 45 | if (it == in_progress_.end()) { |
| 46 | return false; |
| 47 | } |
| 48 | auto& entry = it->second; |
| 49 | const auto stride = static_cast<std::size_t>(entry.params.stride); |
| 50 | const auto offset = row_offset * stride; |
| 51 | if (const auto expected = row_count * stride; |
| 52 | bytes.size() != expected || |
| 53 | offset + bytes.size() > entry.bytes.size()) { |
| 54 | return false; |
| 55 | } |
| 56 | std::memcpy(entry.bytes.data() + offset, bytes.data(), bytes.size()); |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | std::optional<AssembledBuffer> BufferAssembler::end(const std::string& name) { |
| 61 | const auto it = in_progress_.find(name); |