You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/02/13 00:29:00 UTC

[05/25] couch-mrview commit: updated refs/heads/1994-merge-rcouch to 7775266

couch_mrview: fix changes log

This changes make sure we pass correct keys to remove to the seq and
key_byseq btrees in views.


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

Branch: refs/heads/1994-merge-rcouch
Commit: 26d16a6ae266e70c2f6ddb9cdd59f55c16c619ab
Parents: 880103a
Author: benoitc <be...@apache.org>
Authored: Mon Jan 27 10:24:25 2014 +0100
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Wed Feb 12 17:27:39 2014 -0600

----------------------------------------------------------------------
 src/couch_mrview_updater.erl | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-mrview/blob/26d16a6a/src/couch_mrview_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_mrview_updater.erl b/src/couch_mrview_updater.erl
index 782502a..58ee9d2 100644
--- a/src/couch_mrview_updater.erl
+++ b/src/couch_mrview_updater.erl
@@ -279,13 +279,15 @@ write_kvs(State, UpdateSeq, ViewKVs, DocIdKeys, Log) ->
             true ->
                 SToRem = couch_util:dict_find(ViewId, SeqsToRemove, []),
                 SToAdd = couch_util:dict_find(ViewId, SeqsToAdd, []),
+                RemSKs = [{Seq, Key} || {Key, Seq, _} <- SToRem],
+                RemKSs = [{[Seq, Key], DocId} || {Key, Seq, DocId} <- SToRem],
                 SKVs1 = SKVs ++ SToAdd,
                 {ok, SBt} = couch_btree:add_remove(View#mrview.seq_btree,
-                                                   SKVs1, SToRem),
+                                                   SKVs1, RemSKs),
 
                 {ok, KSbt} = couch_btree:add_remove(View#mrview.key_byseq_btree,
                                                     couch_mrview_util:to_key_seq(SKVs1),
-                                                    couch_mrview_util:to_key_seq(SToRem)),
+                                                    RemKSs),
                 {SBt, KSbt};
             _ -> {nil, nil}
         end,
@@ -350,8 +352,9 @@ update_log(Btree, Log, UpdatedSeq, _) ->
                                 true ->
                                     %% the log is updated, deleted old
                                     %% record from the view
-                                    DelAcc5 = dict:append(ViewId, {Seq, Key},
-                                                        DelAcc4),
+                                    DelAcc5 = dict:append(ViewId,
+                                                          {Key, Seq, DocId},
+                                                          DelAcc4),
                                     {Log4, AddAcc4, DelAcc5};
                                 false when Op /= del ->
                                     %% an update operation has been
@@ -364,8 +367,9 @@ update_log(Btree, Log, UpdatedSeq, _) ->
                                                        {ViewId,
                                                         {Key,UpdatedSeq, del}},
                                                        Log4),
-                                    DelAcc5 = dict:append(ViewId, {Seq, Key},
-                                                        DelAcc4),
+                                    DelAcc5 = dict:append(ViewId,
+                                                          {Key, Seq, DocId},
+                                                          DelAcc4),
                                     AddAcc5 = dict:append(ViewId,
                                                           {{UpdatedSeq, Key},
                                                            {DocId, RemValue}},