Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1C0AF200C5B for ; Tue, 4 Apr 2017 23:37:45 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1A8C4160BA9; Tue, 4 Apr 2017 21:37:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 5F5CF160B90 for ; Tue, 4 Apr 2017 23:37:44 +0200 (CEST) Received: (qmail 51734 invoked by uid 500); 4 Apr 2017 21:37:43 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 51635 invoked by uid 99); 4 Apr 2017 21:37:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Apr 2017 21:37:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6996EDFE59; Tue, 4 Apr 2017 21:37:43 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: davisp@apache.org To: commits@couchdb.apache.org Date: Tue, 04 Apr 2017 21:37:44 -0000 Message-Id: <48f01c75d16a4804a44519babec1709f@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [02/27] couch commit: updated refs/heads/COUCHDB-3287-mixed-db-records to 5f6ff5a archived-at: Tue, 04 Apr 2017 21:37:45 -0000 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/COUCHDB-3287-mixed-db-records Commit: ff9fb7112ee5250af01e1b38c8cfa9caed152ae7 Parents: 8556adb Author: Paul J. Davis Authored: Sat Feb 11 15:29:14 2017 -0600 Committer: Paul J. Davis 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) ->