couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject couch-index commit: updated refs/heads/COUCHDB-3326-clustered-purge to 79b45e1
Date Wed, 15 Mar 2017 18:37:06 GMT
Repository: couchdb-couch-index
Updated Branches:
  refs/heads/COUCHDB-3326-clustered-purge [created] 79b45e1c1


Update couch_index to use new purge API

COUCHDB-3326


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

Branch: refs/heads/COUCHDB-3326-clustered-purge
Commit: 79b45e1c1dbe65ea708058f2231f9dfd8430f3c8
Parents: 4e779f2
Author: Mayya Sharipova <mayyas@ca.ibm.com>
Authored: Mon Aug 15 09:37:05 2016 -0400
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Wed Mar 15 13:35:48 2017 -0500

----------------------------------------------------------------------
 src/couch_index_updater.erl | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-index/blob/79b45e1c/src/couch_index_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_index_updater.erl b/src/couch_index_updater.erl
index bf31460..21a9ad5 100644
--- a/src/couch_index_updater.erl
+++ b/src/couch_index_updater.erl
@@ -133,10 +133,7 @@ update(Idx, Mod, IdxState) ->
         DbUpdateSeq = couch_db:get_update_seq(Db),
         DbCommittedSeq = couch_db:get_committed_update_seq(Db),
 
-        PurgedIdxState = case purge_index(Db, Mod, IdxState) of
-            {ok, IdxState0} -> IdxState0;
-            reset -> exit({reset, self()})
-        end,
+        {ok, PurgedIdxState} = purge_index(Db, Mod, IdxState),
 
         NumChanges = couch_db:count_changes_since(Db, CurrSeq),
 
@@ -201,11 +198,19 @@ purge_index(Db, Mod, IdxState) ->
     {ok, DbPurgeSeq} = couch_db:get_purge_seq(Db),
     IdxPurgeSeq = Mod:get(purge_seq, IdxState),
     if
-        DbPurgeSeq == IdxPurgeSeq ->
+        IdxPurgeSeq == DbPurgeSeq ->
             {ok, IdxState};
-        DbPurgeSeq == IdxPurgeSeq + 1 ->
-            {ok, PurgedIdRevs} = couch_db:get_last_purged(Db),
-            Mod:purge(Db, DbPurgeSeq, PurgedIdRevs, IdxState);
         true ->
-            reset
+            FoldFun = fun({PurgeSeq, _UUId, Id, Revs}, Acc) ->
+                Mod:purge(Db, PurgeSeq, [{Id, Revs}], Acc),
+            end,
+            {ok, NewStateAcc} = couch_db:fold_purged_docs(
+                    Db,
+                    IdxPurgeSeq,
+                    FoldFun,
+                    IdxState,
+                    []
+                ),
+            Mod:update_local_purge_doc(Db, NewStateAcc),
+            {ok, NewStateAcc}
     end.


Mime
View raw message