Github user banjiewen commented on a diff in the pull request:

    https://github.com/apache/couchdb-fabric/pull/43#discussion_r57255762
  
    --- Diff: src/fabric_view_map.erl ---
    @@ -149,15 +161,15 @@ handle_message(complete, Worker, State) ->
         Counters = fabric_dict:update_counter(Worker, 1, 
State#collector.counters),
         fabric_view:maybe_send_row(State#collector{counters = Counters}).
     
    -merge_row(fwd, undefined, Row, Rows) ->
    +merge_row(fwd, undefined, Row, Rows, SortFun) ->
         lists:merge(fun(#view_row{key=KeyA, id=IdA}, #view_row{key=KeyB, 
id=IdB}) ->
    -        couch_ejson_compare:less_json_ids({KeyA, IdA}, {KeyB, IdB})
    +        SortFun({KeyA, IdA}, {KeyB, IdB})
         end, [Row], Rows);
    -merge_row(rev, undefined, Row, Rows) ->
    +merge_row(rev, undefined, Row, Rows, SortFun) ->
         lists:merge(fun(#view_row{key=KeyA, id=IdA}, #view_row{key=KeyB, 
id=IdB}) ->
    -        couch_ejson_compare:less_json_ids({KeyB, IdB}, {KeyA, IdA})
    +        SortFun({KeyB, IdB}, {KeyA, IdA})
         end, [Row], Rows);
    -merge_row(_, KeyDict, Row, Rows) ->
    +merge_row(_, KeyDict, Row, Rows, _) ->
    --- End diff --
    
    > The purpose of KeyDict is to capture the original order of the keys 
posted by the user and ensure that we respond in the same order.
    
    That makes more sense now - I'll add a comment before I'm done here - but 
I'm not quite convinced that the `fetch` is the whole problem. Shouldn't the 
`IdA < IdB` comparison on L174 be done using the configured collator, since 
those results are for identical keys? The same argument might apply for the `A 
=:-= B` comparison on L174 as well, though I don't know of any values that 
compare equal under ICU that don't under Erlang's `=:=`...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to