LevelDB vs std :: map

In our application, we use std::mapto store data (key, value) and use serialization to store this data on disk. With this approach, we find that disk I / O is a performance bottleneck, and finding values ​​using a key is not very fast.

I came across LevelDB and thought about using it. But I have some questions.

  • The LevelDB documentation says that it is made for a pair of values ​​(string, string). Does this mean that I cannot use key values ​​for custom pairs?
  • It seems that the difference between std::mapand LevelDB is that LevelDB is permanent, but std::mapworks in memory. Does this mean that an I / O disk bottleneck would be more problematic for levelDB.

In particular, can anyone explain if LevelDB could be a better choice than std::map?

PS: I tried to use hash_map, but it looks slower thanstd::map

+5
source share
2 answers

LevelDB just does something else than std :: map.

Are you really saying that you want (high performance) persistence for std :: map?

  • Look at std :: map with a special distributor. Select records from the memory-mapped area and use fsync to ensure that information gets to disk at strategic times.

  • EASTL ( std:: map ), )

  • hash_map (std:: unorderded_map); hash_maps , (a) loadfactor (b) -

  • , : Boost Serialization ( ). Boost Serialization .

+7

:

, 1000000 . std:: map, 1000000 . find/insert / , ( 20 ). , 1000000 .

, std:: map. std:: map (), .

, . , , , . SQLite, LevelDB .

+2

All Articles