You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by be...@apache.org on 2014/02/08 22:51:10 UTC
couchdb commit: updated refs/heads/1994-merge-rcouch to 1e6114c
Updated Branches:
refs/heads/1994-merge-rcouch 4357ef76b -> 1e6114c56
couch_mrview: add API to retrieve view info.
Add couch_mrview:get_view_info/3 to retrieve the internal informations
of a view like the last update seq in this view or the number of rows.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/1e6114c5
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/1e6114c5
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/1e6114c5
Branch: refs/heads/1994-merge-rcouch
Commit: 1e6114c56da5f7592718a7eecb6adfd5b56fc3e2
Parents: 4357ef7
Author: Benoit Chesneau <be...@apache.org>
Authored: Sat Feb 8 22:49:42 2014 +0100
Committer: Benoit Chesneau <be...@apache.org>
Committed: Sat Feb 8 22:49:42 2014 +0100
----------------------------------------------------------------------
apps/couch_mrview/src/couch_mrview.erl | 25 +++++++++++++++++++++++++
apps/couch_mrview/test/04-index-info.t | 10 +++++++++-
2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/1e6114c5/apps/couch_mrview/src/couch_mrview.erl
----------------------------------------------------------------------
diff --git a/apps/couch_mrview/src/couch_mrview.erl b/apps/couch_mrview/src/couch_mrview.erl
index 26538a2..e5b0d99 100644
--- a/apps/couch_mrview/src/couch_mrview.erl
+++ b/apps/couch_mrview/src/couch_mrview.erl
@@ -17,6 +17,7 @@
-export([view_changes_since/6, view_changes_since/7]).
-export([count_view_changes_since/4, count_view_changes_since/5]).
-export([get_info/2]).
+-export([get_view_info/3]).
-export([refresh/2]).
-export([compact/2, compact/3, cancel_compaction/2]).
-export([cleanup/1]).
@@ -147,6 +148,30 @@ get_info(Db, DDoc) ->
couch_index:get_info(Pid).
+%% get informations on a view
+get_view_info(Db, DDoc, VName) ->
+ {ok, {_, View}, _, _Args} = couch_mrview_util:get_view(Db, DDoc, VName,
+ #mrargs{}),
+
+ %% get the total number of rows
+ {ok, TotalRows} = couch_mrview_util:get_row_count(View),
+
+ %% get the total number of sequence logged in this view
+ SeqBtree = View#mrview.seq_btree,
+ {ok, TotalSeqs} = case SeqBtree of
+ nil -> {ok, 0};
+ _ ->
+ {ok, {Count, _Reds}} = couch_btree:full_reduce(SeqBtree),
+ {ok, Count}
+ end,
+
+ {ok, [{update_seq, View#mrview.update_seq},
+ {purge_seq, View#mrview.purge_seq},
+ {total_rows, TotalRows},
+ {total_seqs, TotalSeqs}]}.
+
+
+
%% @doc refresh a view index
refresh(#db{name=DbName}, DDoc) ->
refresh(DbName, DDoc);
http://git-wip-us.apache.org/repos/asf/couchdb/blob/1e6114c5/apps/couch_mrview/test/04-index-info.t
----------------------------------------------------------------------
diff --git a/apps/couch_mrview/test/04-index-info.t b/apps/couch_mrview/test/04-index-info.t
index 34fb192..e95db1c 100644
--- a/apps/couch_mrview/test/04-index-info.t
+++ b/apps/couch_mrview/test/04-index-info.t
@@ -15,7 +15,7 @@
% the License.
main(_) ->
- etap:plan(9),
+ etap:plan(12),
case (catch test()) of
ok ->
etap:end_tests();
@@ -46,6 +46,14 @@ test() ->
etap:is(getval(compact_running, Info), false, "No compaction running."),
etap:is(getval(waiting_clients, Info), 0, "No waiting clients."),
+
+ {ok, ViewInfo} = couch_mrview:get_view_info(Db, <<"_design/bar">>,
+ <<"baz">>),
+ etap:is(getval(update_seq, ViewInfo), 11, "View Update seq is ok."),
+ etap:is(getval(purge_seq, ViewInfo), 0, "View Update seq is ok."),
+ etap:is(getval(total_rows, ViewInfo), 10, "View total rows is ok."),
+
+
test_util:stop_couch(),
ok.