Only in apache-couchdb-1.0.1: AUTHORS.gz
Only in apache-couchdb-1.0.1/bin: couchdb
Only in apache-couchdb-1.0.1/bin: couchdb.bat.tpl
Only in apache-couchdb-1.0.1/bin: couchdb.tpl
Only in apache-couchdb-1.0.1/bin: couchjs
Only in apache-couchdb-1.0.1/bin: couchjs_dev
Only in apache-couchdb-1.0.1/bin: couchjs.tpl
Only in apache-couchdb-1.0.1/bin: Makefile
Only in apache-couchdb-1.0.1: BUGS.gz
Only in apache-couchdb-1.0.1: CHANGES.gz
Only in apache-couchdb-1.0.1: config.h
Only in apache-couchdb-1.0.1: config.log
Only in apache-couchdb-1.0.1: config.status
Only in apache-couchdb-1.0.1: DEVELOPERS.gz
Only in apache-couchdb-1.0.1/etc/couchdb: default_dev.ini
Only in apache-couchdb-1.0.1/etc/couchdb: default.ini
Only in apache-couchdb-1.0.1/etc/couchdb: default.ini.tpl
Only in apache-couchdb-1.0.1/etc/couchdb: local_dev.ini
Only in apache-couchdb-1.0.1/etc/couchdb: Makefile
Only in apache-couchdb-1.0.1/etc/default: Makefile
Only in apache-couchdb-1.0.1/etc/init: couchdb
Only in apache-couchdb-1.0.1/etc/init: couchdb.tpl
Only in apache-couchdb-1.0.1/etc/init: Makefile
Only in apache-couchdb-1.0.1/etc/launchd: Makefile
Only in apache-couchdb-1.0.1/etc/launchd: org.apache.couchdb.plist.tpl
Only in apache-couchdb-1.0.1/etc/logrotate.d: couchdb
Only in apache-couchdb-1.0.1/etc/logrotate.d: couchdb.tpl
Only in apache-couchdb-1.0.1/etc/logrotate.d: Makefile
Only in apache-couchdb-1.0.1/etc: Makefile
Only in apache-couchdb-1.0.1/etc/windows: Makefile
Only in apache-couchdb-1.0.1: INSTALL.gz
Only in apache-couchdb-1.0.1: INSTALL.Unix.gz
Only in apache-couchdb-1.0.1: INSTALL.Windows.gz
Only in apache-couchdb-1.0.1: libtool
Only in apache-couchdb-1.0.1: LICENSE.gz
Only in apache-couchdb-1.0.1: Makefile
Only in apache-couchdb-1.0.1: NEWS.gz
Only in apache-couchdb-1.0.1: NOTICE.gz
Only in apache-couchdb-1.0.1: README.gz
Only in apache-couchdb-1.0.1/share: Makefile
Only in apache-couchdb-1.0.1/share/server: main.js
Only in apache-couchdb-1.0.1/src/couchdb: couch.app
Only in apache-couchdb-1.0.1/src/couchdb: couch_app.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch.app.tpl
Only in apache-couchdb-1.0.1/src/couchdb: couch_auth_cache.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_btree.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_changes.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_config.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_config_writer.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_db.beam
diff -ur apache-couchdb-1.0.1.orig/src/couchdb/couch_db.hrl apache-couchdb-1.0.1/src/couchdb/couch_db.hrl
--- apache-couchdb-1.0.1.orig/src/couchdb/couch_db.hrl	2010-07-20 07:59:53.000000000 +0900
+++ apache-couchdb-1.0.1/src/couchdb/couch_db.hrl	2010-12-14 09:54:37.000000000 +0900
@@ -190,6 +190,7 @@
     skip = 0,
 
     group_level = 0,
+    group_numrows = false,
 
     view_type = nil,
     include_docs = false,
Only in apache-couchdb-1.0.1/src/couchdb: couch_db.hrl.orig
Only in apache-couchdb-1.0.1/src/couchdb: couch_db_update_notifier.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_db_update_notifier_sup.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_db_updater.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_doc.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_event_sup.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_external_manager.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_external_server.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_file.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd_auth.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd_db.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd_external.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd_misc_handlers.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd_oauth.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd_rewrite.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd_show.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd_stats_handlers.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd_view.beam
diff -ur apache-couchdb-1.0.1.orig/src/couchdb/couch_httpd_view.erl apache-couchdb-1.0.1/src/couchdb/couch_httpd_view.erl
--- apache-couchdb-1.0.1.orig/src/couchdb/couch_httpd_view.erl	2010-08-08 11:25:40.000000000 +0900
+++ apache-couchdb-1.0.1/src/couchdb/couch_httpd_view.erl	2010-12-14 10:08:16.000000000 +0900
@@ -155,15 +155,22 @@
         group_level = GroupLevel
     } = QueryArgs,
     CurrentEtag = view_group_etag(Group, Db),
+    Pid = case get_group_numrows_type(Req) of 
+            true -> spawn(fun() -> group_numrows_server() end);
+              _  -> false
+          end,
     couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
         {ok, GroupRowsFun, RespFun} = make_reduce_fold_funs(Req, GroupLevel,
                 QueryArgs, CurrentEtag, Group#group.current_seq,
-                #reduce_fold_helper_funs{}),
+                #reduce_fold_helper_funs{}, Pid),
         FoldAccInit = {Limit, Skip, undefined, []},
         {ok, {_, _, Resp, _}} = couch_view:fold_reduce(View,
                 RespFun, FoldAccInit, [{key_group_fun, GroupRowsFun} |
                 make_key_options(QueryArgs)]),
-        finish_reduce_fold(Req, Resp)
+        case get_group_numrows_type(Req) of
+          true -> finish_reduce_fold(Req, Resp, [], Pid);
+             _ -> finish_reduce_fold(Req, Resp)
+        end
     end);
 
 output_reduce_view(Req, Db, View, Group, QueryArgs, Keys) ->
@@ -173,10 +180,14 @@
         group_level = GroupLevel
     } = QueryArgs,
     CurrentEtag = view_group_etag(Group, Db, Keys),
+    Pid = case get_group_numrows_type(Req) of 
+            true -> spawn(fun() -> group_numrows_server() end);
+              _  -> false
+          end,
     couch_httpd:etag_respond(Req, CurrentEtag, fun() ->
         {ok, GroupRowsFun, RespFun} = make_reduce_fold_funs(Req, GroupLevel,
                 QueryArgs, CurrentEtag, Group#group.current_seq,
-                #reduce_fold_helper_funs{}),
+                #reduce_fold_helper_funs{}, Pid),
         {Resp, _RedAcc3} = lists:foldl(
             fun(Key, {Resp, RedAcc}) ->
                 % run the reduce once for each key in keys, with limit etc
@@ -190,7 +201,10 @@
                 {Resp2, RedAcc2}
             end,
         {undefined, []}, Keys), % Start with no comma
-        finish_reduce_fold(Req, Resp, [{update_seq,Group#group.current_seq}])
+        case get_group_numrows_type(Req) of
+          true -> finish_reduce_fold(Req, Resp, [{update_seq,Group#group.current_seq}], Pid);
+             _ -> finish_reduce_fold(Req, Resp, [{update_seq,Group#group.current_seq}])
+          end
     end).
 
 reverse_key_default(?MIN_STR) -> ?MAX_STR;
@@ -203,6 +217,9 @@
 get_reduce_type(Req) ->
     list_to_existing_atom(couch_httpd:qs_value(Req, "reduce", "true")).
 
+get_group_numrows_type(Req) ->
+    list_to_existing_atom(couch_httpd:qs_value(Req, "group_numrows", "false")).
+
 load_view(Req, Db, {ViewDesignId, ViewName}, Keys) ->
     Stale = get_stale_type(Req),
     Reduce = get_reduce_type(Req),
@@ -303,6 +320,8 @@
     [{reduce, parse_bool_param(Value)}];
 parse_view_param("include_docs", Value) ->
     [{include_docs, parse_bool_param(Value)}];
+parse_view_param("group_numrows", Value) ->
+    [{group_numrows, parse_bool_param(Value)}];
 parse_view_param("list", Value) ->
     [{list, ?l2b(Value)}];
 parse_view_param("callback", _) ->
@@ -385,6 +404,8 @@
 % Use the view_query_args record's default value
 validate_view_query(include_docs, _Value, Args) ->
     Args;
+validate_view_query(group_numrows, _Value, Args) ->
+    Args;
 validate_view_query(extra, _Value, Args) ->
     Args.
 
@@ -393,7 +414,7 @@
         start_response = StartRespFun,
         send_row = SendRowFun,
         reduce_count = ReduceCountFun
-    } = apply_default_helper_funs(HelperFuns),
+    } = apply_default_helper_funs(HelperFuns, Req, Req),
 
     #view_query_args{
         include_docs = IncludeDocs
@@ -425,10 +446,13 @@
     end.
 
 make_reduce_fold_funs(Req, GroupLevel, _QueryArgs, Etag, UpdateSeq, HelperFuns) ->
+  make_reduce_fold_funs(Req, GroupLevel, _QueryArgs, Etag, UpdateSeq, HelperFuns, nil).
+
+make_reduce_fold_funs(Req, GroupLevel, _QueryArgs, Etag, UpdateSeq, HelperFuns, Pid) ->
     #reduce_fold_helper_funs{
         start_response = StartRespFun,
         send_row = SendRowFun
-    } = apply_default_helper_funs(HelperFuns),
+    } = apply_default_helper_funs(HelperFuns, Req, Pid),
 
     GroupRowsFun =
         fun({_Key1,_}, {_Key2,_}) when GroupLevel == 0 ->
@@ -488,7 +512,7 @@
         #view_fold_helper_funs{
             start_response = StartResp,
             send_row = SendRow
-        }=Helpers) ->
+        }=Helpers, _Req, _Pid) ->
     StartResp2 = case StartResp of
     undefined -> fun json_view_start_resp/6;
     _ -> StartResp
@@ -504,19 +528,21 @@
         send_row = SendRow2
     };
 
-
 apply_default_helper_funs(
         #reduce_fold_helper_funs{
             start_response = StartResp,
             send_row = SendRow
-        }=Helpers) ->
+        }=Helpers, Req, Pid) ->
     StartResp2 = case StartResp of
     undefined -> fun json_reduce_start_resp/4;
     _ -> StartResp
     end,
 
     SendRow2 = case SendRow of
-    undefined -> fun send_json_reduce_row/3;
+    undefined -> case get_group_numrows_type(Req) of
+                   true -> gen_send_json_reduce_row(Pid);
+                      _ -> fun send_json_reduce_row/3
+                 end;
     _ -> SendRow
     end,
 
@@ -586,6 +612,24 @@
     send_chunk(Resp, RowFront ++ ?JSON_ENCODE({[{key, Key}, {value, Value}]})),
     {ok, ",\r\n"}.
 
+gen_send_json_reduce_row(Pid) ->
+  fun(_Req, _KV, _RowFront) ->
+    Pid ! {countup},
+    {ok, ",\r\n"}
+  end.
+
+group_numrows_server() ->
+  group_numrows_server(0).
+group_numrows_server(X) ->
+  receive
+    {status, From} ->
+      From ! X, group_numrows_server(X);
+    {countup} ->
+      group_numrows_server(X+1);
+    {stop, From} ->
+      From ! X
+  end.
+
 view_group_etag(Group, Db) ->
     view_group_etag(Group, Db, nil).
 
@@ -651,6 +695,25 @@
 finish_reduce_fold(Req, Resp) ->
     finish_reduce_fold(Req, Resp, []).
 
+get_group_numrows_final_results(Pid) ->
+  Pid ! {stop, self()},
+  receive
+    X -> X
+  end.
+
+finish_reduce_fold(Req, Resp, Fields, Pid) ->
+    case Resp of
+    undefined ->
+        send_json(Req, 200, {[
+            {rows, []},
+            {group_numrows, 0}
+        ] ++ Fields});
+    Resp ->
+        X = get_group_numrows_final_results(Pid),
+        send_chunk(Resp, "{\"group_numrows\":\"" ++ integer_to_list(X) ++ "\"}"),
+        end_json_response(Resp)
+    end.
+ 
 finish_reduce_fold(Req, Resp, Fields) ->
     case Resp of
     undefined ->
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd_view.erl.20101213.180122
Only in apache-couchdb-1.0.1/src/couchdb: couch_httpd_view.erl.orig
Only in apache-couchdb-1.0.1/src/couchdb: couch_key_tree.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_log.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_native_process.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_os_process.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_query_servers.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_ref_counter.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_rep_att.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_rep.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_rep_changes_feed.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_rep_httpc.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_rep_missing_revs.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_rep_reader.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_rep_sup.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_rep_writer.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_server.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_server_sup.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_stats_aggregator.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_stats_collector.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_stream.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_task_status.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_util.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_uuids.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_view.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_view_compactor.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_view_group.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_view_updater.beam
Only in apache-couchdb-1.0.1/src/couchdb: couch_work_queue.beam
Only in apache-couchdb-1.0.1/src/couchdb: Makefile
Only in apache-couchdb-1.0.1/src/couchdb/priv: couch_icu_driver.la
Only in apache-couchdb-1.0.1/src/couchdb/priv: couch_icu_driver_la-couch_icu_driver.lo
Only in apache-couchdb-1.0.1/src/couchdb/priv: couchjs
Only in apache-couchdb-1.0.1/src/couchdb/priv: couchjs-http.o
Only in apache-couchdb-1.0.1/src/couchdb/priv: couchjs-main.o
Only in apache-couchdb-1.0.1/src/couchdb/priv: couchjs-utf8.o
Only in apache-couchdb-1.0.1/src/couchdb/priv: couchspawnkillable
Only in apache-couchdb-1.0.1/src/couchdb/priv: .deps
Only in apache-couchdb-1.0.1/src/couchdb/priv: .libs
Only in apache-couchdb-1.0.1/src/couchdb/priv: Makefile
Only in apache-couchdb-1.0.1/src/couchdb/priv: stat_descriptions.cfg
Only in apache-couchdb-1.0.1/src/erlang-oauth: Makefile
Only in apache-couchdb-1.0.1/src/erlang-oauth: oauth.app
Only in apache-couchdb-1.0.1/src/erlang-oauth: oauth.beam
Only in apache-couchdb-1.0.1/src/erlang-oauth: oauth_hmac_sha1.beam
Only in apache-couchdb-1.0.1/src/erlang-oauth: oauth_http.beam
Only in apache-couchdb-1.0.1/src/erlang-oauth: oauth_plaintext.beam
Only in apache-couchdb-1.0.1/src/erlang-oauth: oauth_unix.beam
Only in apache-couchdb-1.0.1/src/erlang-oauth: oauth_uri.beam
Only in apache-couchdb-1.0.1/src/etap: etap_application.beam
Only in apache-couchdb-1.0.1/src/etap: etap.beam
Only in apache-couchdb-1.0.1/src/etap: etap_can.beam
Only in apache-couchdb-1.0.1/src/etap: etap_exception.beam
Only in apache-couchdb-1.0.1/src/etap: etap_process.beam
Only in apache-couchdb-1.0.1/src/etap: etap_report.beam
Only in apache-couchdb-1.0.1/src/etap: etap_request.beam
Only in apache-couchdb-1.0.1/src/etap: etap_string.beam
Only in apache-couchdb-1.0.1/src/etap: etap_web.beam
Only in apache-couchdb-1.0.1/src/etap: Makefile
Only in apache-couchdb-1.0.1/src/ibrowse: ibrowse.app
Only in apache-couchdb-1.0.1/src/ibrowse: ibrowse_app.beam
Only in apache-couchdb-1.0.1/src/ibrowse: ibrowse.beam
Only in apache-couchdb-1.0.1/src/ibrowse: ibrowse_http_client.beam
Only in apache-couchdb-1.0.1/src/ibrowse: ibrowse_lb.beam
Only in apache-couchdb-1.0.1/src/ibrowse: ibrowse_lib.beam
Only in apache-couchdb-1.0.1/src/ibrowse: ibrowse_sup.beam
Only in apache-couchdb-1.0.1/src/ibrowse: ibrowse_test.beam
Only in apache-couchdb-1.0.1/src/ibrowse: Makefile
Only in apache-couchdb-1.0.1/src: Makefile
Only in apache-couchdb-1.0.1/src/mochiweb: Makefile
Only in apache-couchdb-1.0.1/src/mochiweb: mochifmt.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochifmt_records.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochifmt_std.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochihex.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochijson2.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochijson.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochinum.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb.app
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_app.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_charref.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_cookies.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_echo.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_headers.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_html.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_http.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_multipart.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_request.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_response.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_skel.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_socket_server.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_sup.beam
Only in apache-couchdb-1.0.1/src/mochiweb: mochiweb_util.beam
Only in apache-couchdb-1.0.1/src/mochiweb: reloader.beam
Only in apache-couchdb-1.0.1: stamp-h1
Only in apache-couchdb-1.0.1/test/bench: Makefile
Only in apache-couchdb-1.0.1/test/bench: run
Only in apache-couchdb-1.0.1/test/etap: Makefile
Only in apache-couchdb-1.0.1/test/etap: run
Only in apache-couchdb-1.0.1/test/etap: test_util.beam
Only in apache-couchdb-1.0.1/test/etap: test_util.erl
Only in apache-couchdb-1.0.1/test/javascript: Makefile
Only in apache-couchdb-1.0.1/test/javascript: run
Only in apache-couchdb-1.0.1/test: Makefile
Only in apache-couchdb-1.0.1/test/view_server: Makefile
Only in apache-couchdb-1.0.1: THANKS.gz
Only in apache-couchdb-1.0.1/utils: Makefile
Only in apache-couchdb-1.0.1/utils: run
Only in apache-couchdb-1.0.1/var: Makefile
