Repository navigation
[FIX] DistanceMatrix::setValue keeps the cached minimum correct (#9488 DATA-24) - #9610
Conversation
…MS#9488 DATA-24) Part of OpenMS#9488 (POLS high-severity checklist — **CONCEPT / DATASTRUCTURES / KERNEL**). ### [DATA-24] `DistanceMatrix::setValue` — stale cached minimum `setValue()` keeps a cached minimum coordinate (`min_element_`) up to date on the fast path. The guard for that fast path used `&&`: ```cpp if (i != min_element_.first && j != min_element_.second) // before ``` so a cell that shares **exactly one** index with the current min coordinate (e.g. same column) skipped the fast path and fell into the `else` branch, which never refreshes `min_element_` when the new value is *smaller*. Writing a new minimum into such a cell left `getMinElementCoordinates()` pointing at a stale (larger) cell. **Fix:** one-character change to `||` — i.e. "take the fast path whenever `(i,j)` is **not** the min cell". Writing into any non-min cell can only introduce a new (smaller) minimum, never invalidate the existing one, so the fast path is always correct there; the `else` branch now fires only when `(i,j)` *is* the min cell (where a recompute may be needed). **ABI:** source-compatible (inline template body only). **Test:** `DistanceMatrix_test` — writing a smaller value into a cell sharing one index with the min now updates the cached min coordinate. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesDistanceMatrix cached-minimum fix
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Adversarial review result: no blocking behavioral issue found in this pass. Required source cleanup before merge: the added implementation/test comments include tracker references. Please remove those references from source comments and keep the comments focused on the cached-minimum invariant. I did not run the tests locally. |
Add entries for all substantive non-test PRs merged since the last changelog update: - #9623 ThermoRawFile full mzML metadata extraction + polarity fix - #9602 New FileInfo library class usable from C++ and pyOpenMS - #9521 IMAGING multi-region support (add missing PR reference) - #9620 Deisotoper::isToleranceSupported + ProSE/SSE crash fix on low-res data - #9610 DistanceMatrix::setValue cached-minimum guard fix - #9497 DistanceMatrix::operator==, ClusteringGrid, File path guard fixes - #9583 LogStreamBuf thread-safety fix - #9514 CI Windows migration to Visual Studio 2026 Claude-Session: https://claude.ai/code/session_01YLg6pWyjyTxpWAU6mgrDzC Co-authored-by: Claude <[email protected]>
Part of #9488 (POLS high-severity checklist — CONCEPT / DATASTRUCTURES / KERNEL).
[DATA-24]
DistanceMatrix::setValue— stale cached minimumsetValue()keeps a cached minimum coordinate (min_element_) up to date on the fast path. The guard for that fast path used&&:so a cell that shares exactly one index with the current min coordinate (e.g. same column) skipped the fast path and fell into the
elsebranch, which never refreshesmin_element_when the new value is smaller. Writing a new minimum into such a cell leftgetMinElementCoordinates()pointing at a stale (larger) cell.Fix: one-character change to
||— i.e. "take the fast path whenever(i,j)is not the min cell". Writing into any non-min cell can only introduce a new (smaller) minimum, never invalidate the existing one, so the fast path is always correct there; theelsebranch now fires only when(i,j)is the min cell (where a recompute may be needed).ABI: source-compatible (inline template body only).
Test:
DistanceMatrix_test— writing a smaller value into a cell sharing one index with the min now updates the cached min coordinate.🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests