3 ms·
The showstopper with Judy arrays, for me, was that they require a lot of hairy fine control over memory layout to implement (it's been years since i looked at t
by twic 6y ago
The showstopper with Judy arrays, for me, was that they require a lot of hairy fine control over memory layout to implement (it's been years since i looked at this, so please excuse the lack of detail). You can do that in C, but not in no-sharp-edges languages like Java, which i was using at the time. It would even be quite a headache in Rust.
It doesn't help that the documentation is very weird.
- nicoburns 6y agoThere is an implementation of Judy arrays in Rust: https://github.com/adevore/rudy https://github.com/adevore/rudy Not sure how complete / usable it is.
- twic 6y agoThe docs say it's largely complete. As an example of a headache, one node type in Judy has a count, followed by that many index bytes, followed by the same number of pointers. In Rust, that would naturally be a struct with two variable-sized fields, which isn't possible, so it's done by defining a struct generic over a pair of array types: https://github.com/adevore/rudy/blob/300f2cc7842f6329a76fff012056f54bf6a37424/src/util/locksteparray.rs#L81 https://github.com/adevore/rudy/blob/300f2cc7842f6329a76fff0... It looks to me like this is only ever instantiated for 2, 7, or 31 elements, whereas i think for original Judy, it can be any size up to 31 elements (maybe?). Handling a genuinely variable length in Rust would be rather gnarly, because there have to be different types for each length.
- quicknir 6y agoI would assume that within unsafe you could simply do the same kinds of shenanigans you would do in C++, e.g. you have a fixed size struct that is just the "header", it's only created on the heap, and it's immediately followed by the variable amount of data which you get access to by casting. If you couldn't do this in unsafe rust this seems like a pretty huge limitation.
- steveklabnik 6y agoYes, you could.