Re: [RFC PATCH 2/2] rust: add maple tree abstractions
From: Liam R. Howlett
Date: Mon Apr 07 2025 - 21:37:42 EST
* Andrew Ballance <andrewjballance@xxxxxxxxx> [250407 16:03]:
> On Mon, Apr 07, 2025 at 09:59:21AM -0400, Liam R. Howlett wrote:
> > * Andrew Ballance <andrewjballance@xxxxxxxxx> [250405 02:03]:
> > > maple trees are sparse array like data structure that maps
> > > non-overlapping ranges to pointers.
> >
> > Why do you think the maple tree is a spare array like data structure?
> >
>
> I called the maple tree "sparse array like" because indexes that have
> no entry map to null and there can be gaps between ranges. I did not
> mean to imply that a maple tree was literally a sparse array.
Yes, I understood what you said to mean it was "like a sparse array", I
just don't see how it is like a sparse array.
My understanding is that a sparse array is sparse because not every
value is represented in the underlying storage, where as the maple tree
defines every range to an entry (including single entries, and NULL
entries). It does combine multiple NULL entries into a single range.
There is a non-node store of a single entry of range [0,0] when [1,
ULONG_MAX] is NULL, or the entire empty set - but that's an
optimisation.
I haven't implemented a sparse array, so perhaps I'm missing how they
are alike.
>
> Would you like me to reword this?
>
No, I don't think it is worth having a rust implementation right now as
there are no users and I could cause issues on the rust side without
knowing.
I was wondering if you read that it was like a sparse array somewhere
and the reason behind it. There is a plan for a sparse node type, but
there are a number of things that need to happen before I get there.
I've always said it was a b-tree variant (probably b+) for storing
ranges with a branching factor of 10 or 16 (for now, anyways).
Thanks,
Liam