• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Using incomplete key to get a value from map.

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem where I have a lookup table of about 1,000,000 key/value pairs, and the ids that I have to find are not always exactly complete. Easier to show in an example:

IDs
----------
ABCD
EFGH
IJKL
1234


Lookup Table
----------------
Key/ Value
-----/ ------------
ABCD:ILK/ Val1
EI:1234 / Val2
cIJKL:39D9/ Val3


One thing I tried was to nix everything after the colon in the key, but as you can see on the last one there is sometimes a character before the ID. One very inefficient way is to read them into parallel arrays and search through the keys for each ID I am trying to look up and use a string.contains(). But like I said there are approx. 1 million key/value pairs and this is just to slow...ran it for about 15 minutes and still wasn't finished. BTW, just thinking about iterating through the keys and doing my lookups in my ID list, but that list is 1500+ so that is less than ideal as well.

So does anyone have any other ideas on how I could complete these lookups?
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like you need the kind of data structure which spell checkers use to suggest possible words from partial words.

Here is a link to one open sources spell checker which might help inspire you.

Bill
 
Get meta with me! What pursues us is our own obsessions! But not this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic