couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dav...@apache.org
Subject [1/2] couch commit: updated refs/heads/feat-improve-compaction-task-status to 552446d
Date Tue, 28 Mar 2017 21:57:30 GMT
Repository: couchdb-couch
Updated Branches:
  refs/heads/feat-improve-compaction-task-status [created] 552446d80


Redo mix


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

Branch: refs/heads/feat-improve-compaction-task-status
Commit: 552446d80d7bdc873719b2d24a37ea85343fc5ec
Parents: 6e8fdcf
Author: Paul J. Davis <paul.joseph.davis@gmail.com>
Authored: Tue Mar 28 16:24:58 2017 -0500
Committer: Paul J. Davis <paul.joseph.davis@gmail.com>
Committed: Tue Mar 28 16:57:22 2017 -0500

----------------------------------------------------------------------
 src/couch_db_updater.erl | 50 ++++++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/552446d8/src/couch_db_updater.erl
----------------------------------------------------------------------
diff --git a/src/couch_db_updater.erl b/src/couch_db_updater.erl
index be441b9..39ed436 100644
--- a/src/couch_db_updater.erl
+++ b/src/couch_db_updater.erl
@@ -1407,31 +1407,18 @@ copy_meta_data(#db{fd=Fd, header=Header}=Db, DocCount) ->
         rem_seqs=[],
         infos=[]
     },
-    Acc = merge_docids(Iter, Acc0),
-    {ok, IdTree} = couch_btree:add(Acc#merge_st.id_tree, Acc#merge_st.infos),
-    {ok, Seqtree} = couch_btree:add_remove(
-        Acc#merge_st.seq_tree, [], Acc#merge_st.rem_seqs
-    ),
-    update_compact_task(Acc#merge_st.infos),
+    Acc1 = merge_docids(Iter, Acc0),
+    Acc2 = flush_merge_st(Acc1),
+    #merge_st{
+        id_tree = Idtree,
+        seq_tree = SeqTree
+    } = Acc2,
     Db#db{id_tree=IdTree, seq_tree=SeqTree}.
 
 
-merge_docids(Iter, #merge_st{infos=Infos}=Acc) when length(Infos) > 1000 ->
-    #merge_st{
-        id_tree=IdTree0,
-        seq_tree=SeqTree0,
-        rem_seqs=RemSeqs
-    } = Acc,
-    {ok, IdTree1} = couch_btree:add(IdTree0, Infos),
-    {ok, SeqTree1} = couch_btree:add_remove(SeqTree0, [], RemSeqs),
-    update_compact_task(length(Infos)),
-    Acc1 = Acc#merge_st{
-        id_tree=IdTree1,
-        seq_tree=SeqTree1,
-        rem_seqs=[],
-        infos=[]
-    },
-    merge_docids(Iter, Acc1);
+merge_docids(Iter, #merge_st{docid_seqs = DocIdSeqs} = Acc)
+        when length(DocIdSeqs) > 1000 ->
+    merge_docids(Iter, flush_merge_st(Acc)),
 merge_docids(Iter, #merge_st{curr=Curr}=Acc) ->
     case next_info(Iter, Curr, []) of
         {NextIter, NewCurr, FDI, Seqs} ->
@@ -1470,6 +1457,25 @@ next_info(Iter, {Id, Seq, FDI}, Seqs) ->
     end.
 
 
+flush_merge_st(MergeSt) ->
+    #merge_st{
+        id_tree=IdTree0,
+        seq_tree=SeqTree0,
+        rem_seqs=RemSeqs,
+        docid_seqs=DocIdSeqs
+    } = Acc,
+    {ok, FDIKVs, SeqTree1} = couch_btree:query_modify(
+            SeqTree0, DocIdSeqs, [], RemSeqs),
+    FDIs = lists:map(fun({ok, #full_doc_info{} = FDI}) -> FDI end, FDIKVs),
+    {ok, IdTree1} = couch_btree:add(IdTree0, FDIs),
+    Acc#merge_st{
+        id_tree=IdTree1,
+        seq_tree=SeqTree1,
+        rem_seqs=[],
+        docid_seqs=[]
+    }.
+
+
 update_compact_task(NumChanges) ->
     [Changes, Total] = couch_task_status:get([changes_done, total_changes]),
     Changes2 = Changes + NumChanges,


Mime
View raw message