incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Anderson <jch...@apache.org>
Subject Re: Tree structure: how to calculate branch node sum, using results from a view that calculates leaf node sums.
Date Sat, 05 Sep 2009 07:20:10 GMT
On Fri, Sep 4, 2009 at 11:34 PM, Metin Akat<akat.metin@gmail.com> 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<akat.metin@gmail.com> 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

Mime
View raw message