Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 59855 invoked from network); 8 Mar 2011 19:28:33 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Mar 2011 19:28:33 -0000 Received: (qmail 27097 invoked by uid 500); 8 Mar 2011 19:28:32 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 27051 invoked by uid 500); 8 Mar 2011 19:28:32 -0000 Mailing-List: contact dev-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 dev@couchdb.apache.org Received: (qmail 27043 invoked by uid 99); 8 Mar 2011 19:28:32 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Mar 2011 19:28:32 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of randall.leeds@gmail.com designates 209.85.210.180 as permitted sender) Received: from [209.85.210.180] (HELO mail-iy0-f180.google.com) (209.85.210.180) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Mar 2011 19:28:24 +0000 Received: by iyf40 with SMTP id 40so6811295iyf.11 for ; Tue, 08 Mar 2011 11:28:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=wgRmcUTHlGIoE6CQ8Ajo0MM5jr1IRAPnwFfIUdIxGyE=; b=MqNOPWbYFVO8AUyxEfTP0txf7tVmF5ISbUZEipuQR/71Zw6wqeoyV1+kZ0h1Ccjchn 5NTHZ5tIz9/n81YEoeLE369li7TYb15ZejXjqdMZyposnS1FnnaLnSpyxxsikkCdkJ6e acIfapwGhSsiSLRjHlYp79JYJZn9uvHyTJ/jU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Pcu/r+YdUxJK5i7rlL166JuGqzsybT7OxN+bHyYInliB2VR2pGtEs8wrKeS7R+Kmos KRvNn7ZBh9Jw+ovDcyIpfhkFN6ZUbSKoEgCwtMUm+TGG4GWDFZIsuYgH7N+5I9GG7wDB G4q7kW8ipzUBiAlAngd+UVt5ENh51wNgvm3IA= MIME-Version: 1.0 Received: by 10.42.137.137 with SMTP id y9mr4317748ict.502.1299612483586; Tue, 08 Mar 2011 11:28:03 -0800 (PST) Received: by 10.42.2.75 with HTTP; Tue, 8 Mar 2011 11:28:03 -0800 (PST) Date: Tue, 8 Mar 2011 11:28:03 -0800 Message-ID: Subject: btree refactoring From: Randall Leeds To: dev@couchdb.apache.org Content-Type: multipart/alternative; boundary=90e6ba6e8b106e0923049dfd9c7b X-Virus-Checked: Checked by ClamAV on apache.org --90e6ba6e8b106e0923049dfd9c7b Content-Type: text/plain; charset=UTF-8 When I start hacking on COUCHDB-1076 a couple nights ago I found that the cleanest way I could see for allowing kp_nodes to be skipped during traversal was for the fold function to couch_btree:foldl to be arity 4, with kp_node | kv_node as the first argument. Evaluating that function for every node (instead of just kv_nodes) lets us return {skip, Acc} to skip whole subtrees. Diving back into the couch_btree code to read over Damien's patch for COUCHDB-1084, it hit me that ModifyFun could instead be a function that was called for all the actions. We wouldn't need to return the query results because this action function could send them back to the client as they're found. Then we just keep the actions list as part of the accumulator and query_modify collapses into a btree:foldl and we no longer need so many similar-looking recursive functions. Off the cuff I envision modify_node being exported and simplified to be non-recursive and query_modify being a helper function to generate a fold function that uses modify_node (or something like this). Is this similar to anything you've done already, Paul? Would you all be interested if I took a crack at doing this kind of refactor? --90e6ba6e8b106e0923049dfd9c7b--