Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 25672 invoked from network); 5 Sep 2009 07:20:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 5 Sep 2009 07:20:43 -0000 Received: (qmail 19042 invoked by uid 500); 5 Sep 2009 07:20:42 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 18961 invoked by uid 500); 5 Sep 2009 07:20:42 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 18950 invoked by uid 99); 5 Sep 2009 07:20:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Sep 2009 07:20:42 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jchris@gmail.com designates 209.85.212.171 as permitted sender) Received: from [209.85.212.171] (HELO mail-vw0-f171.google.com) (209.85.212.171) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Sep 2009 07:20:31 +0000 Received: by vws1 with SMTP id 1so1117630vws.13 for ; Sat, 05 Sep 2009 00:20:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type; bh=EiVZhcEhnRzMzQLVxr90piR+SSRfwOH8jMLMgpWt7EI=; b=Nb9o+7EraYEmLUu5c1WGc3n2D7nHDUtRUKO8uYu6Ag6NdOV8hAGIknak9vfjwTd0ql soHIYLtFYCrW7JZN/LfEEFk0LUlzSvfZ2pa6wC+M+d8Oi0N/oRswbAd5iPH9Ws4DfHPW GkIzj6aNAPsi7VMzg13ckq3A1BTsldnmsUdY4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; b=Vu/uAaW9B3GGUQSvbqYSeFhMHzUgYMwMcczyv8fEC4PFJbcKrDMQTR0ix8AqwVEsm6 B/nZqZv4b+RBgHJiUTiB8hb0sFnnlXjgrntdO6NH/ANjngLi+0nuW/zOvlgJ5qfZb5Go w1NnMQyYjCbPDYSJnSmbAaTXr+rSODqXTetZs= MIME-Version: 1.0 Sender: jchris@gmail.com Received: by 10.220.68.226 with SMTP id w34mr9806516vci.116.1252135210133; Sat, 05 Sep 2009 00:20:10 -0700 (PDT) In-Reply-To: <98a246a10909042334i38fbd7ccu5446ce8f7950881f@mail.gmail.com> References: <98a246a10909030535r59b1ecc2m32bfb1b0dc93fe46@mail.gmail.com> <98a246a10909030606q4c02cfe1id2312054bea11b04@mail.gmail.com> <98a246a10909042334i38fbd7ccu5446ce8f7950881f@mail.gmail.com> Date: Sat, 5 Sep 2009 00:20:10 -0700 X-Google-Sender-Auth: f08530ca32d33170 Message-ID: Subject: Re: Tree structure: how to calculate branch node sum, using results from a view that calculates leaf node sums. From: Chris Anderson To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org On Fri, Sep 4, 2009 at 11:34 PM, Metin Akat wrote: > One way I can think of is to bulk update all transactions "belonging" > to a leaf account when moving that leaf account around. > I can live with having to wait some time till this gets executed. > Is this "bad thinking" or is it OK to some extent? > It can be problematic if you need ACID compliance as bulk updates aren't transactional. (Especially consider what can happen during replication.) This can often be remedied in your app model, but this is can get complex. > > On Thu, Sep 3, 2009 at 4:06 PM, Metin Akat wrote: >> Well, there is a problem with this. I don't like the idea of recording >> the whole path in each transaction, because it is anticipated that >> accounts are able to change places in the tree. So my TRANSACTION only >> holds information for only the "actual" account it's issued against, >> not for its whole lineage. >> >> On the other hand, ACCOUNTS do have the information for THEIR >> path(lineage), exactly as you suggested. >> So the problem now is making the connection between an account and its >> balance :) >> >> >>> >>> query your reduce view with group_level=1 (or 2 or 3 .. depending on how >>> many level you want to descend into your tree). Your "path" to the root node >>> should be an array as in: ["toplevel", "firstlevel", "secondlevel"] as the >>> key of your view. >>> >>> Cheers >>> Jan >>> -- >>> >>> >>> >> > -- Chris Anderson http://jchrisa.net http://couch.io