couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [12/25] couch-mrview commit: updated refs/heads/1994-merge-rcouch to 7775266
Date Wed, 12 Feb 2014 23:29:07 GMT
couch_mrview: add couch_mrview:refresh/2 function

function to refresh a view index.


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/fcfc8d29
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/tree/fcfc8d29
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/diff/fcfc8d29

Branch: refs/heads/1994-merge-rcouch
Commit: fcfc8d29f18c60732d5798b836b01f38d299164f
Parents: 8ca6395
Author: benoitc <benoitc@apache.org>
Authored: Tue Jan 28 23:23:37 2014 +0100
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Wed Feb 12 17:27:39 2014 -0600

----------------------------------------------------------------------
 src/couch_mrview.erl    | 20 ++++++++++++++++++++
 test/08-changes_since.t |  4 ----
 2 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/fcfc8d29/src/couch_mrview.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview.erl b/src/couch_mrview.erl
index d8f092c..26538a2 100644
--- a/src/couch_mrview.erl
+++ b/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([refresh/2]).
 -export([compact/2, compact/3, cancel_compaction/2]).
 -export([cleanup/1]).
 
@@ -146,6 +147,25 @@ get_info(Db, DDoc) ->
     couch_index:get_info(Pid).
 
 
+%% @doc refresh a view index
+refresh(#db{name=DbName}, DDoc) ->
+    refresh(DbName, DDoc);
+
+refresh(Db, DDoc) ->
+    UpdateSeq = couch_util:with_db(Db, fun(WDb) ->
+                    couch_db:get_update_seq(WDb)
+            end),
+
+    case couch_index_server:get_index(couch_mrview_index, Db, DDoc) of
+        {ok, Pid} ->
+            case catch couch_index:get_state(Pid, UpdateSeq) of
+                {ok, _} -> ok;
+                Error -> {error, Error}
+            end;
+        Error ->
+            {error, Error}
+    end.
+
 compact(Db, DDoc) ->
     compact(Db, DDoc, []).
 

http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/fcfc8d29/test/08-changes_since.t
----------------------------------------------------------------------
diff --git a/test/08-changes_since.t b/test/08-changes_since.t
index 5a10f4c..58c92e9 100644
--- a/test/08-changes_since.t
+++ b/test/08-changes_since.t
@@ -146,10 +146,6 @@ test_remove_key(Db) ->
     ]},
     etap:is(Result3, Expect2, "removed key OK.").
 
-
-
-
-
 run_query(Db, Since, Opts) ->
     Fun = fun(KV, Acc) -> {ok, [KV | Acc]} end,
     {ok, R} = couch_mrview:view_changes_since(Db, <<"_design/bar">>, <<"baz">>,


Mime
View raw message