I've got a question about using MapDB, especially about querying a submap. I'm taking the code snippet from the official example at https://github.com/jankotek/MapDB/blob/release-1.0/src/test/java/examples/TreeMap_Composite_Key.java. This example is easy to understand. For testing purposes I interchanged the key parts "Town" and "Street" and adjusted the submap
call the same way. Unfortunately now the map is not limited by the submap
call. Instead the whole map (200 entries) is returned. Following are the adapted code snippets (out of the example mentioned above)
// Initializing map
for (final String town : towns) {
for (final String street : streets) {
for (final int houseNum : houseNums) {
final Fun.Tuple3<String, String, Integer> address = Fun.t3(street, town,
houseNum);
final int income = r.nextInt(50000);
map.put(address, income);
}
}
}
...
final Map<Fun.Tuple3, Integer> housesInCong = map.subMap(
Fun.t3(null, "Cong", null), Fun.t3(Fun.HI, "Cong", Fun.HI));
//housesInCong.size() == 200 (should be 40)
System.out.println("There are " + housesInCong.size()+ " houses in Cong");
Can someone explain to me why this happens and how this can be avoided? I've got a similar use case in my project.
Thanks in advance and regards :)