4 ms·
Hash the string to convert to integer -> double hash or truncate to lowest 32 bits and this technique works for strings as well. You can replace string with an
by throw-qqqqq 2y ago
Hash the string to convert to integer -> double hash or truncate to lowest 32 bits and this technique works for strings as well.
You can replace string with any data structure you can hash or index really.
- vlovich123 2y agoAh but this then absolutely fails for range queries but makes sense if you want to build an index for point lookups.
- throw-qqqqq 2y agoDefinitely! If the integers are (truncated) hashes, ranges are completely meaningless. But what would a range over strings even represent? Perhaps if you e.g. use string indices into an array of sorted strings (by length, by prefix or whatever), you could use it for something. Depends on the application I guess :)
- vlovich123 2y agoRange queries over strings are extremely common. For example, databases like cockroachdb and yuggabytedb use the table name as a prefix which then requires a range query to narrow down queries against a specific table.
- throw-qqqqq 2y agoAh, I misunderstood what you meant by range :) For such prefix queries, I think a radix-tree/Trie or ordered collections are more useful (than the index-based collection I initially mentioned). Thanks for following up :)
- vlovich123 2y agoBut then why bother with any of this at all instead of building a perfect hash function like BoomPHF