| 75 | void addEntryToIovecs(AsyncDataCacheEntry& entry, std::vector<iovec>& iovecs) { |
| 76 | if (entry.tinyData() != nullptr) { |
| 77 | iovecs.push_back({entry.tinyData(), static_cast<size_t>(entry.size())}); |
| 78 | return; |
| 79 | } |
| 80 | const auto& data = entry.data(); |
| 81 | iovecs.reserve(iovecs.size() + data.numRuns()); |
| 82 | int64_t bytesLeft = entry.size(); |
| 83 | for (auto i = 0; i < data.numRuns(); ++i) { |
| 84 | auto run = data.runAt(i); |
| 85 | iovecs.push_back( |
| 86 | {run.data<char>(), std::min<size_t>(bytesLeft, run.numBytes())}); |
| 87 | bytesLeft -= run.numBytes(); |
| 88 | if (bytesLeft <= 0) { |
| 89 | break; |
| 90 | }; |
| 91 | } |
| 92 | } |
| 93 | } // namespace |
| 94 | |
| 95 | SsdPin::SsdPin(SsdFile& file, SsdRun run) : file_(&file), run_(run) { |
| 96 | file_->checkPinned(run_.offset()); |
| 97 | } |