-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request for NavigableMap instead of SortedMap #14
Comments
Hi, First, I think you can easily get functionality of NavigableMap was introduced in Java 6. JDBM tries to be compatible with Android which is mostly Java 5. NavigableMap was introduced to Android at version 2.3 (which I did not know until now). So I think it is good idea to include it. For me this has low priority, so it may make it to JDBM somewhere around 3.2 or 3.3 version.
|
If you're going to do this I think you should consider ConcurrentNavigableMap instead of NavigableMap. Brings 4 useful concurrency methods |
Cuncurrent interfaces are on my plan.If it is going to be ConcurrentMap+SortedMap or ConcurrentNavigableMap is other problem |
Hi Again, We have decided to go ahead and modify the code to support the NavigableMap interface. Secondly I must admit that I do not know what you mean by: Overall unit test for NavigableMap under Apache 2 license. Best regards.. |
Hi, I like your dedication. I will write and add NavigableMap soon (~week). |
Hi jankotek, We have implemented the NavigableMap interface on top of a much smaller and simpler interface that we call BaseMap, so now the task is reduced to implementing the BaseMap interface which looks like this:
(The Entry<K,V> is just the java.util.Map.Entry interface, so it can be implemented in any way found suitable) Our NavigableMap implementation takes care of iterators, submaps etc. It also does modCount and fast fail by throwing ConcurrentModificationException, so the implementation of BaseMap does not need to be concerned with any of this. As I see it the best implementation would be to have BTree implement BaseMap or we could create a separate class that either extends BTree (I personally do not like this option so much) or contains a BTree and create the implementation here. We can do this or you can do it if you prefer not having us modifying your existing code, but we are in kind of a hurry since we have an upcoming deadline. We can email our implementation of NavigableMap and the unit tests we have made and you can put on whatever license you like, as long as we can use the code for our thesis. Must say though that some of the code is heavily inspired by java's TreeMap implementation (read copy-pasted from) which is under the GNU General Public License version 2, and I have no idea if this is compatible with the Apache 2 license. I am not really into that license stuff, sorry. Hope too hear from you soon. Best Regards Tobias. |
Hi Jan, I am writing the thesis with Tobias. We have created a test file, NavigableMapInterfaceTest, extending SortedMapInterfaceTest. When we run the test on a regular java.util.TreeMap, the following two tests fail:
We think it would be a good idea to have the TreeMap in JDBM3 behave the same way as java.util.TreeMap, since this is what most people would expect. This only requires small changes like supporting null values (not null keys) and throwing a NullPointerException on entrySet().contains(null) instead of returning false. Martin |
Hi again, We began implementing the BaseMap interface in a separate class that contains a BTree, here is the code:
As you can see, we still need some implementation. Best regards Tobias. |
Hi Tobias, as I wrote I already started implementing NavigableMap. So please wait with your implementation for couple of days. |
Hi jankotek, We have nearly finished the implementation and written tests for it, so if you want to, you can just use our implementation and concentrate on other issues. Here is our NavigableMap implementation that uses the BaseMap interface I posted earlier:
If you want to use this code, feel free, otherwise we will just wait for your implementation.... Best regards Tobias. |
Hi, Rather than sending code here, please create fork and use merge requests |
TreeMap now implements ConcurrentNavigableMap interface. It supports all functions except inverted map. |
Hi there,
Would it be possible to get a NavigableMap interface to the TreeMaps instead of the SortedMap interface?
We are writing a thesis about data modelling in java and we are considering using JDBM3 for caching the data. The problem is that we need the added functionality of the NavigableMap interface, especially the subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) method, where we can choose wether or not the intervals should be open or not.
Since we are using keys with no natural successor method it is not possible for us to use the subMap method in the SortedMap interface to get all the intervals we need.
How difficult would it be to provide the NavigableMap interface instead of the SortedMap interface?
Should we try to modify the code ourself or do you know of any issues that makes this difficult, so it would be better to look for alternatives?
Best regards
Tobias and Martin.
The text was updated successfully, but these errors were encountered: