(
mut commits: CommitsWithVersion<R>,
de: D,
range: impl RangeBounds<u64>,
)
| 616 | } |
| 617 | |
| 618 | fn fold_transactions_internal<R, D>( |
| 619 | mut commits: CommitsWithVersion<R>, |
| 620 | de: D, |
| 621 | range: impl RangeBounds<u64>, |
| 622 | ) -> Result<(), D::Error> |
| 623 | where |
| 624 | R: Repo, |
| 625 | D: Decoder, |
| 626 | D::Error: From<error::Traversal>, |
| 627 | { |
| 628 | use std::ops::Bound::*; |
| 629 | |
| 630 | // Avoid reading the first commit if it wouldn't be in the range anyway. |
| 631 | if range_is_empty(&range) { |
| 632 | return Ok(()); |
| 633 | } |
| 634 | |
| 635 | // `true` if `offset` is outside `range`, s.t. it is smaller than the start |
| 636 | // bound. |
| 637 | let before_start = |offset: &u64| match range.start_bound() { |
| 638 | Included(x) => offset < x, |
| 639 | Excluded(x) => offset <= x, |
| 640 | Unbounded => false, |
| 641 | }; |
| 642 | // `true` if `offset` is outside `range`, s.t. it is greater than the end |
| 643 | // bound. |
| 644 | let past_end = |offset: &u64| match range.end_bound() { |
| 645 | Included(x) => offset > x, |
| 646 | Excluded(x) => offset >= x, |
| 647 | Unbounded => false, |
| 648 | }; |
| 649 | |
| 650 | while let Some(commit) = commits.next() { |
| 651 | let (version, commit) = match commit { |
| 652 | Ok(version_and_commit) => version_and_commit, |
| 653 | Err(e) => { |
| 654 | // Ignore it if the very last commit in the log is broken. |
| 655 | // The next `append` will fix the log, but the `decoder` |
| 656 | // has no way to tell whether we're at the end or not. |
| 657 | // This is unlike the consumer of an iterator, which can |
| 658 | // perform below check itself. |
| 659 | if commits.next().is_none() { |
| 660 | return Ok(()); |
| 661 | } |
| 662 | |
| 663 | return Err(e.into()); |
| 664 | } |
| 665 | }; |
| 666 | trace!("commit {} n={} version={}", commit.min_tx_offset, commit.n, version); |
| 667 | |
| 668 | let max_tx_offset = commit.min_tx_offset + commit.n as u64; |
| 669 | // Skip if no transaction in the commit is in range. |
| 670 | if before_start(&max_tx_offset) { |
| 671 | continue; |
| 672 | } |
| 673 | |
| 674 | let records = &mut commit.records.as_slice(); |
| 675 | for n in 0..commit.n { |
no test coverage detected
searching dependent graphs…