nickva opened a new pull request #3763:
URL: https://github.com/apache/couchdb/pull/3763


   We do that by matching the comparator function behavior used during row 
[merging](https://github.com/apache/couchdb/blob/3.x/src/fabric/src/fabric_view_map.erl#L244-L248)
 in with the comparison function used when sorting the rows on view 
[shards](https://github.com/apache/couchdb/blob/3.x/src/couch_mrview/src/couch_mrview_util.erl#L1103-L1107).
 This goes along with the constraint in the `lists:merge/3` docs which 
indicates that the input lists should be sorted according to the same 
[comparator](https://erlang.org/doc/man/lists.html#merge-3) as the one passed 
to the `lists:merge/3` call.
   
   The stability of returned rows results from the case when both keys match as 
equal. Now `lists:merge/3` will favor the element in the existing rows list 
instead of always 
[replacing](https://github.com/erlang/otp/blob/master/lib/stdlib/src/lists.erl#L2668-L2675)
 the older matching row with the last arriving row, since now `less(A, A)` will 
be `false`, while previously it was `true`.
   
   The fix was found by Adam when discussing issue 
[3750](https://github.com/apache/couchdb/issues/3750#issuecomment-920947424)
   
   Co-author: Adam Kocoloski <[email protected]>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to