[MS-973] Fix sorting logic in MatchResultSet to handle equal confidence scores#1170
Conversation
…idence scores by subject ID
5b35568 to
923b091
Compare
|
| ) | ||
|
|
||
| fun add(element: T): MatchResultSet<T> { | ||
| if (lowestConfidence > element.confidence) { |
There was a problem hiding this comment.
Hm, am I reading this wrong or if we first add a high confidence score (say 99), then we would not add any lower results and return a list of just 1 result? Is this the behaviour that we want?
There was a problem hiding this comment.
Ah, lowestConfidence is updated only when the set is full. That's confusing...
There was a problem hiding this comment.
It looks like if confidence and subjectId are now a composite comparison key, so should work as intended.
There was a problem hiding this comment.
Here we are comparing confidence only. The confusion comes from the fact that lowestConfidence is initialized with 0 and updated only when the set is full.
There was a problem hiding this comment.
This is a classic LeetCode problem 🥇. If we only need the top N elements, fully sorting the entire list is unnecessary and can be avoided to enhance performance.
| ) | ||
|
|
||
| fun add(element: T): MatchResultSet<T> { | ||
| if (lowestConfidence > element.confidence) { |
There was a problem hiding this comment.
It looks like if confidence and subjectId are now a composite comparison key, so should work as intended.



JIRA ticket
Will be released in: 2025.2.0
Root cause analysis (for bugfixes only)
When two subjects have the same confidence score during matching, only one is returned in the identification response. Please refer to the ticket for more details.
First known affected version: All recent versions
Notable changes
Testing guidance
Additional work checklist
no.duplicates.mp4
allow.duplicates.mp4