Skip to content

Commit be17daf

Browse files
committed
split iterator
1 parent 6ca84a6 commit be17daf

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/index/inverted_index_reader.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,17 @@ impl InvertedIndexReader {
373373
// we could do without an iterator, but this allows us access to coalesce which simplify
374374
// things
375375
let posting_ranges_iter =
376-
std::iter::from_fn(move || stream.next().map(|(_k, v)| v.postings_range.clone()))
377-
.coalesce(|range1, range2| {
378-
if range1.end + MERGE_HOLES_UNDER_BYTES >= range2.start {
379-
Ok(range1.start..range2.end)
380-
} else {
381-
Err((range1, range2))
382-
}
383-
});
384-
385-
for posting_range in posting_ranges_iter {
376+
std::iter::from_fn(move || stream.next().map(|(_k, v)| v.postings_range.clone()));
377+
378+
let merged_posting_ranges_iter = posting_ranges_iter.coalesce(|range1, range2| {
379+
if range1.end + MERGE_HOLES_UNDER_BYTES >= range2.start {
380+
Ok(range1.start..range2.end)
381+
} else {
382+
Err((range1, range2))
383+
}
384+
});
385+
386+
for posting_range in merged_posting_ranges_iter {
386387
if let Err(_) = sender.unbounded_send(posting_range) {
387388
// this should happen only when search is cancelled
388389
return Err(io::Error::other("failed to send posting range back"));

0 commit comments

Comments
 (0)