MapDB map entry by record id.

50 views
Skip to first unread message

NicTheNZer

unread,
Sep 22, 2017, 7:20:38 PM9/22/17
to MapDB
Hi,

I am trying to use MapDB for a particular use case and was wondering if anybody has a suggestion for how to structure a couple of maps of data.

This is for a chess database application. I want the database to support two multi-maps (e.g via composite keys), one map is indexed by the moves of the game and so the keys are quite long strings of numbers representing moves (the values in this index are the complete game data, excluding the moves). So that two games with the same moves can be stored this map will also employ a unique id number per game as part of a composite key.

The second map contains a hash of the positions reached in the games and values need to refer to the game in the primary map which contains this position. I don't want to store the full sequence of moves which is the primary key to refer to the game in the secondary index, as this is quite long and when used as values doesn't compress well. The best available solution here would be here to store the mapdb record id of the game here I think.

The issue with this is I can't work out how to store and retrieve map entries by their record id from the primary map, and thought this might not be possible as the primary entries keys are not exactly like record values in the sense of having a record id. So my question here is, how would you store or retrieve both key and value pairs from a BTreeMap via a record id, or some other similar address like thing.

There is a less good solution available to store a fragment of the moves (say the first 8 moves) and the games primary id number in the secondary index. This will make an overall lookup for a particular position quite a bit worse however as the fragment refers to a range of games which start with a particular sequence of moves. All of these would need to be
searched for the games primary id.

Thanks for any suggestions offered,
      Nic Croad.
Reply all
Reply to author
Forward
0 new messages