I'm curious about how key-value data storage store their data and query on it.
Normally, when give it a key to query, it will need to loop through the data and find the matched key then get its data to response. But I saw that key-value storage can quickly find the data with the given key, so is there any way that key-value storage can jump directly to the position which hold that key?
Anyone who know this theory please explain it, a simple example will be appreciated. Thanks in advance.
Yes, the fundamental data structure involved here is a hashmap. This in contrast to arrays allows jumping directly to the key to retrieve the value. Technically stated hashmap supports O(1) lookup as opposed to an array loop which is O(n)
Most programming languages come with a hashmap built in