Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Judy array for managed languages

Judy array is fast data structure that may represent a sparse array or a set of values. Is there its implementation for managed languages such as C#? Thanks

like image 589
LicenseQ Avatar asked Feb 15 '09 02:02

LicenseQ


1 Answers

It's worth noting that these are often called Judy Trees or Judy Tries if you are googling for them.

I also looked for a .Net implementation but found nothing. Also worth noting that:

The implementation is heavily designed around efficient cache usage, as such implementation specifics may be highly dependent on the size of certain constructs used within the sub structures. A .Net managed implementation may be somewhat different in this regard.

There are some significant hurdles to it that I can see (and there are probably more that my brief scan missed)

  • The API has some fairly anti OO aspects (for example a null pointer is viewed as an empty tree) so simplistic, move the state pointer to the LHS and make functions instance methods conversion to C++ wouldn't work.
  • The implementation of the sub structures I looked at made heavy use of pointers. I cannot see these efficiently being translated to references in managed languages.
  • The implementation is a distillation of a lot of very complex ideas that belies the simplicity of the public api.
  • The code base is about 20K lines (most of it complex), this doesn't strike me as an easy port.

You could take the library and wrap the C code in C++/CLI (probably simply holding internally a pointer that is the c api trie and having all the c calls point to this one). This would provide a simplistic implementation but the linked libraries for the native implementation may be problematic (as might memory allocation). You would also probably need to deal with converting .Net strings to plain old byte* on the transition as well (or just work with bytes directly)

like image 74
ShuggyCoUk Avatar answered Sep 22 '22 14:09

ShuggyCoUk