You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ko...@apache.org on 2015/06/27 02:38:05 UTC

couch-mrview commit: updated refs/heads/1805-respect-collation-setting-reduce-group to a4eca27

Repository: couchdb-couch-mrview
Updated Branches:
  refs/heads/1805-respect-collation-setting-reduce-group [created] a4eca27b6


Use proper collation fun for reduce grouping

We had been using raw collation for grouping keys in a MR view
regardless of the overall collation setting for the view. This patch
defers the construction of the grouping function to the btree code,
where we have access to the correct sorting function.

COUCHDB-1805


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/commit/a4eca27b
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/a4eca27b
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/a4eca27b

Branch: refs/heads/1805-respect-collation-setting-reduce-group
Commit: a4eca27b6017f0ca31e182cd4f63d1ae96a49a89
Parents: 1dc8d52
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Fri Jun 26 20:34:28 2015 -0400
Committer: Adam Kocoloski <ad...@cloudant.com>
Committed: Fri Jun 26 20:34:28 2015 -0400

----------------------------------------------------------------------
 src/couch_mrview.erl | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/a4eca27b/src/couch_mrview.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview.erl b/src/couch_mrview.erl
index f4ba6e1..5583f1f 100644
--- a/src/couch_mrview.erl
+++ b/src/couch_mrview.erl
@@ -440,8 +440,8 @@ red_fold(Db, {_Nth, _Lang, View}=RedView, Args, Callback, UAcc) ->
         update_seq=View#mrview.update_seq,
         args=Args
     },
-    GroupFun = group_rows_fun(Args#mrargs.group_level),
-    OptList = couch_mrview_util:key_opts(Args, [{key_group_fun, GroupFun}]),
+    Grouping = {key_group_level, Args#mrargs.group_level},
+    OptList = couch_mrview_util:key_opts(Args, [Grouping]),
     Acc2 = lists:foldl(fun(Opts, Acc0) ->
         {ok, Acc1} =
             couch_mrview_util:fold_reduce(RedView, fun red_fold/3,  Acc0, Opts),
@@ -530,18 +530,6 @@ make_meta(Args, UpdateSeq, Base) ->
     end.
 
 
-group_rows_fun(exact) ->
-    fun({Key1,_}, {Key2,_}) -> Key1 == Key2 end;
-group_rows_fun(0) ->
-    fun(_A, _B) -> true end;
-group_rows_fun(GroupLevel) when is_integer(GroupLevel) ->
-    fun({[_|_] = Key1,_}, {[_|_] = Key2,_}) ->
-        lists:sublist(Key1, GroupLevel) == lists:sublist(Key2, GroupLevel);
-    ({Key1,_}, {Key2,_}) ->
-        Key1 == Key2
-    end.
-
-
 default_cb(complete, Acc) ->
     {ok, lists:reverse(Acc)};
 default_cb({final, Info}, []) ->