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 2017/03/30 16:44:36 UTC

[3/4] couch commit: updated refs/heads/feat-optimize-compaction-docid-phase to 14766b3

Use the parallel write API when updating btrees.


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

Branch: refs/heads/feat-optimize-compaction-docid-phase
Commit: 880b6b7e34c47bc1bcccc5eaba8f7b2660ab544b
Parents: ce6778f
Author: Paul J. Davis <pa...@gmail.com>
Authored: Thu Mar 30 11:43:43 2017 -0500
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Thu Mar 30 11:43:43 2017 -0500

----------------------------------------------------------------------
 src/couch_btree.erl | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/880b6b7e/src/couch_btree.erl
----------------------------------------------------------------------
diff --git a/src/couch_btree.erl b/src/couch_btree.erl
index adbc92b..e4b85ad 100644
--- a/src/couch_btree.erl
+++ b/src/couch_btree.erl
@@ -427,17 +427,14 @@ write_node(#btree{fd = Fd, compression = Comp} = Bt, NodeType, NodeList) ->
     % split up nodes into smaller sizes
     NodeListList = chunkify(NodeList),
     % now write out each chunk and return the KeyPointer pairs for those nodes
-    ResultList = [
-        begin
-            {ok, Pointer, Size} = couch_file:append_term(
-                Fd, {NodeType, ANodeList}, [{compression, Comp}]),
-            {LastKey, _} = lists:last(ANodeList),
-            SubTreeSize = reduce_tree_size(NodeType, Size, ANodeList),
-            {LastKey, {Pointer, reduce_node(Bt, NodeType, ANodeList), SubTreeSize}}
-        end
-    ||
-        ANodeList <- NodeListList
-    ],
+    ToWrite = [{NodeType, ANodeList} || ANodeList <- NodeListList],
+    WriteOpts = [{compression, Comp}],
+    {ok, PointerSizePairs} = couch_file:append_terms(Fd, ToWrite, WriteOpts),
+    ResultList = lists:zipwith(fun(ANodeList, {Pointer, Size}) ->
+        {LastKey, _} = lists:last(ANodeList),
+        SubTreeSize = reduce_tree_size(NodeType, Size, ANodeList),
+        {LastKey, {Pointer, reduce_node(Bt, NodeType, ANodeList), SubTreeSize}}
+    end, NodeListList, PointerSizePairs),
     {ok, ResultList}.
 
 modify_kpnode(Bt, {}, _LowerBound, Actions, [], QueryOutput) ->