couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kocol...@apache.org
Subject [4/4] couch-mrview commit: updated refs/heads/1805-respect-collation-setting-reduce-group to ba84fb8
Date Tue, 30 Jun 2015 02:46:43 GMT
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/ba84fb80
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/ba84fb80
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/ba84fb80

Branch: refs/heads/1805-respect-collation-setting-reduce-group
Commit: ba84fb80900e9a86ffa7a05dfcac3c092f2920e1
Parents: 14f5bba
Author: Adam Kocoloski <adam@cloudant.com>
Authored: Fri Jun 26 20:34:28 2015 -0400
Committer: Adam Kocoloski <adam@cloudant.com>
Committed: Mon Jun 29 22:45:41 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/ba84fb80/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}, []) ->


Mime
View raw message