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/01 21:16:03 UTC

[2/3] couch commit: updated refs/heads/master to 0080f15

Ensure multi-item chunks in couch_btree:chunkify/1

If the last element of a chunk has a huge reduction it was possible to
return a btree node that had a single key. This prevents the edge case
by forcing it into the previous chunk. Without this we can end up with a
case where a path in the tree can extend for many levels with only a
single key in each node.

COUCHDB-3298


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

Branch: refs/heads/master
Commit: ff9fb7112ee5250af01e1b38c8cfa9caed152ae7
Parents: 8556adb
Author: Paul J. Davis <pa...@gmail.com>
Authored: Sat Feb 11 15:29:14 2017 -0600
Committer: Paul J. Davis <pa...@gmail.com>
Committed: Sat Feb 11 15:29:14 2017 -0600

----------------------------------------------------------------------
 src/couch_btree.erl | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/ff9fb711/src/couch_btree.erl
----------------------------------------------------------------------
diff --git a/src/couch_btree.erl b/src/couch_btree.erl
index 8f2395c..adbc92b 100644
--- a/src/couch_btree.erl
+++ b/src/couch_btree.erl
@@ -352,6 +352,9 @@ chunkify(InList) ->
 
 chunkify([], _ChunkThreshold, [], 0, OutputChunks) ->
     lists:reverse(OutputChunks);
+chunkify([], _ChunkThreshold, [Item], _OutListSize, [PrevChunk | RestChunks]) ->
+    NewPrevChunk = PrevChunk ++ [Item],
+    lists:reverse(RestChunks, [NewPrevChunk]);
 chunkify([], _ChunkThreshold, OutList, _OutListSize, OutputChunks) ->
     lists:reverse([lists:reverse(OutList) | OutputChunks]);
 chunkify([InElement | RestInList], ChunkThreshold, OutList, OutListSize, OutputChunks) ->