Skip to content

Commit 9f03ca8

Browse files
committed
Resolve off-by-one error in run builder
1 parent 26b2a3c commit 9f03ca8

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

mdio/coordinate_selector.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ class CoordinateSelector {
282282
} else if (!is_match && isInRun) {
283283
// The end of a run
284284
isInRun = false;
285-
for (auto i=run_idx; i<idx; ++i) {
285+
// Use 1 less than the current index to ensure we get the correct end location.
286+
for (auto i=run_idx; i<idx-1; ++i) {
286287
_current_position_increment<T>(current_pos, intervals);
287288
}
288289
// _current_position_stride<T>(current_pos, intervals, idx - run_idx);
@@ -291,6 +292,8 @@ class CoordinateSelector {
291292
for (auto i=0; i<current_pos.size(); ++i) {
292293
last_run[i].exclusive_max = current_pos[i].inclusive_min + 1;
293294
}
295+
// We need to advance to the actual current position
296+
_current_position_increment<T>(current_pos, intervals);
294297
} else if (!is_match && !isInRun) {
295298
// No run at all
296299
// do nothing TODO: Remove me
@@ -375,6 +378,7 @@ class CoordinateSelector {
375378
// do nothing TODO: Remove me
376379
} else if (!is_match && isInRun) {
377380
// The end of a run
381+
// TODO(BrianMichell): Ensure we are using the correct index (see above)
378382
isInRun = false;
379383
for (auto i=run_idx; i<idx; ++i) {
380384
_current_position_increment<T>(current_pos, intervals);

0 commit comments

Comments
 (0)