[ZODB-Dev] How to avoid ConflictErrors in BTrees ?

Tarek Ziadé ziade.tarek at gmail.com
Fri Feb 1 07:02:20 EST 2008


I did, but not the right way I guess -> now it works.

Here's my prototype to avoid conflict errors (done quickly, I guess ot can
be done better
to merge the indexes):


class NoConflictBtree(IOBTree):
    def _p_resolveConflict(self, oldState, savedState, newState):
        if oldState is None and savedState is None:
            return newState
        else:
            def _getBucket(el):
                if el is None:
                    return tuple()
                return el[0][0][0]

            def _mergeBuckets(*buckets):
                res = []
                for bucket in buckets:
                    for el in bucket:
                        if el not in res:
                            res.append(el)
                return tuple(res)

            res = _mergeBuckets(*[_getBucket(el) for el in (oldState,
savedState,
                                  newState)])
            return (((tuple(res),),),)

Is this the right way to do it ?



Andreas Jung-5 wrote:
> 
> 
> 
> --On 1. Februar 2008 03:03:53 -0800 Tarek Ziadé <ziade.tarek at gmail.com> 
> wrote:
>>
>> Since BTrees are written in C, I couldn't add my own conflict manager to
>> try to merge buckets. (and this is
>> way over my head)
>>
> 
> But you can inherit from the BTree classes and hook your 
> _p_resolveConflict() handler into the Python class - or?
> 
> Andreas
>  
> _______________________________________________
> For more information about ZODB, see the ZODB Wiki:
> http://www.zope.org/Wikis/ZODB/
> 
> ZODB-Dev mailing list  -  ZODB-Dev at zope.org
> http://mail.zope.org/mailman/listinfo/zodb-dev
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-avoid-ConflictErrors-in-BTrees---tp15224628p15225209.html
Sent from the Zope - ZODB-Dev mailing list archive at Nabble.com.



More information about the ZODB-Dev mailing list