Re: [RFC] B+Tree library V2

From: Johannes Berg
Date: Thu Jan 08 2009 - 11:33:59 EST


On Thu, 2009-01-08 at 17:24 +0100, JÃrn Engel wrote:

> > Alright, back to this. I'm going to need something like the patch below
> > (except the update facility, which I thought I needed but then changed
> > my mind) which is on top of your patch. Does that look sane?
>
> At first glance it does. The update looks like someone might need it,
> but doesn't have a user yet. The btree_merge is similar, as I used to
> need it, but no longer do. Maybe #if 0 those two.

Sure, works for me. I just had written it and didn't want to keep it
from the world after changing my mind about needing it.

> Well, I used to have heaps of btrees around and wanted to share the
> mempool between all of them. Not sure if I still do, I believe not.
> Will check.
>
> If mempools aren't shared, I agree that encapsulating those bits is much
> nicer.

Just made the API a bit quirky, maybe just support both ways of using
things? Would only need a flag somewhere in the btree structure, I'd
think; ultimately it doesn't matter much to me though.

> > Another thing that I need is a visitor that deletes _some_ entries. How
> > can I do that? Additionally, it would be nice to be able to abort a tree
> > walk, when you have determined that you can't continue for whatever
> > reason.
>
> If you want to open-code it, you can use btree_lookup_less(). I added
> that function sometime last month. Basically something like this:
> key = btree_last(head, geo);
> while (key) {
> /* do something with key */
> key = btree_lookup_less(head, geo, key);
> }
>
> Maybe it should be renamed to btree_get_prev_key(). I never noticed how
> confusing it was because my head was busy with other problems. The code
> is currently burried within my logfs tree:
> http://logfs.org/git?p=logfs;a=summary

I don't think I've understood this yet. That code above there is a
backwards walk over the key space, and it's safe to call
btree_remove(key) at /* do something with key */?

> Will merge it with your patch and respin later tonight or tomorrow...

Cool, thanks. Mainly making it a module for testing anyway.

johannes

Attachment: signature.asc
Description: This is a digitally signed message part