How to use widcard search from a MapDB multimap

650 views
Skip to first unread message

eluke

unread,
Feb 9, 2014, 5:10:29 AM2/9/14
to ma...@googlegroups.com
I have a multimap as in:

NavigableSet<Fun.Tuple2<String,Human>> multiMap = db.getTreeSet("information");

How do I use wildcard searches based on the String key above without iterating the whole map?

Jan Kotek

unread,
Feb 9, 2014, 5:40:16 AM2/9/14
to ma...@googlegroups.com, eluke
What exactly you mean by wildcard?

To find all Humans associated with primary String:
https://github.com/jankotek/MapDB/blob/master/src/test/java/examples/MultiMap.java

To find all Humans where strings starts with "A" you need to specify upper and
lower limits:

for(Human l: Fun.filter(multiMap, "A", true, "B", false)){
System.out.println("value for key : "+l);
signature.asc

eluke

unread,
Feb 9, 2014, 5:49:22 AM2/9/14
to ma...@googlegroups.com, eluke, j...@kotek.net
I mean for example:

Thanks for your speedy response to a troubled soul. I want to retrieve all Human objects with a key starting with "wil", so that I can get Wilson, William, Williams, Wilbert etc

eluke

unread,
Feb 9, 2014, 6:18:36 AM2/9/14
to ma...@googlegroups.com, eluke, j...@kotek.net
Jan, your a champ. The second post worked a treat. I am getting addicted to using MapDB.


On Sunday, February 9, 2014 8:40:16 PM UTC+10, Jan Kotek wrote:

eluke

unread,
Feb 9, 2014, 7:14:23 AM2/9/14
to ma...@googlegroups.com, eluke, j...@kotek.net
Still with the same multiMap. How can a search for a key that contains a given string fragment at any position so much that starts with as used earlier fails?


On Sunday, February 9, 2014 8:40:16 PM UTC+10, Jan Kotek wrote:
Reply all
Reply to author
Forward
0 new messages