Why doesn't InvertedRadixTree include all the methods in RadixTree?

50 views
Skip to first unread message

Beth Tirado

unread,
Oct 4, 2013, 11:51:48 PM10/4/13
to concurrent-t...@googlegroups.com
Hi,

I need a radix tree that allows me to do both of the following:
* get keys starting with a String.  I believe RadixTree.getKeysStartingWith() is just what I need for this.
* get keys that prefix a String.  InvertedRadixTree.getKeysPrefixing() is just what I need for this.

The problem is that although ConcurrentInvertedRadixTree holds a ConcurrentRadixTree in it, ConcurrentInvertedRadixTree does not expose the getKeysStartingWith() method of ConcurrentRadixTree.  Why not?  It looks to me from a scan of the code that it would be trivial to expose the method, and I'm wondering if there is a reason that it wasn't exposed in the first place.

Thanks!


Beth Tirado

unread,
Oct 5, 2013, 1:06:02 AM10/5/13
to concurrent-t...@googlegroups.com
Hi again,

I should have been more accurate.  I really need the flavors of the methods that return both the keys and values, that is getKeyValuePairsForKeysStartingWith() and getKeyValuePairsForKeysPrefixing().

Thanks again.  I'll echo the comment in the first thread; this looks like a very nicely put together project.  :-)

I'm happy to add it myself, but before I do, I was just wondering if there are any "gotchas" to just exposing the method(s) from ConcurrentRadixTree in ConcurrentInvertedRadixTree.

-beth

Niall

unread,
Oct 7, 2013, 6:32:26 PM10/7/13
to concurrent-t...@googlegroups.com
Hi Beth,

You are right that the underlying tree structure is the same in both RadixTree and InvertedRadixTree. But as you've probably seen with issue 6, the traversal algorithms are quite different.

Originally I kept them separate for testing purposes. When I was writing InvertedRadixTree I wanted it alone to give 100% coverage over the shared code (because it used the shared code differently). But now looking at how it turned out, it's absolutely possible to keep doing that, and have InvertedRadixTree extend the public interface of RadixTree.

So I've added the required shim methods in InvertedRadixTree, so you can now use that tree for both use cases. It's released as 2.2.0. This was a good suggestion! Thanks for this suggestion, and for the patch in issue 6 also. 2.2.0 contains this change and your patch.

Niall
Reply all
Reply to author
Forward
0 new messages