a K/V part pulled from its owner straight into the file block (sizing pass: counted, never read)
| 650 | } |
| 651 | // a K/V part pulled from its owner straight into the file block (sizing pass: counted, never read) |
| 652 | void source(const SessionKvSource& s, size_t part) { |
| 653 | const size_t size = s.sizes[part]; |
| 654 | u64(size); |
| 655 | if (!f) { count(size); return; } |
| 656 | for (size_t at = 0; at < size && ok;) { |
| 657 | size_t room = 0; |
| 658 | uint8_t* d = f->span(room); |
| 659 | const size_t c = std::min(room, size - at); |
| 660 | if (!s.read || !s.read(part, at, d, c)) { |
| 661 | ok = false; |
| 662 | read_failed = true; |
| 663 | if (s.error) read_error = s.error(); |
| 664 | return; |
| 665 | } |
| 666 | if (hash) hash->update(d, c); |
| 667 | count(c); |
| 668 | ok = ok && f->commit(c); |
| 669 | at += c; |
| 670 | } |
| 671 | } |
| 672 | bool read_failed = false; |
| 673 | std::string read_error; |
| 674 | }; |