willscott / ip2country

A standalone ip -> country lookup table. Prebuilt & Redistributable.
Apache License 2.0
27 stars 8 forks source link

Investigate use of a 'perfect hash function' #2

Open willscott opened 9 years ago

willscott commented 9 years ago

since there are only 200 odd values, there should be some hash function that can compactly represent the current mapping. Likely this would need to be used in conjunction with a bloom filter to know if the entry is present or not. Potentially gets the result down to something really small.

willscott commented 9 years ago

There's a JS implementation of perfect hash generator here: http://npmjs.org/package/perfect although it doesn't do any minimization.

There's a paper on current best practices here: http://cmph.sourceforge.net/papers/wads07.pdf