本文介绍了键值商店建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个非常基本的java键值存储。我从一个HashMap开始,但似乎HashMap有点空间效率低(我存储了大约2000万条记录,而且似乎需要~6GB RAM)。

I need a very basic key-value store for java. I started with a HashMap but it seems that HashMap is somewhat space inefficient (I'm storing ~20 million records, and seems to require ~6GB RAM).

地图是 Map< Integer,String> ,所以我正在考虑使用GNU Trove TIntObjectHashMap< byte []> ,并将地图值存储为ascii字节数组而不是String。

The map is Map<Integer,String>, and so I'm considering using GNU Trove TIntObjectHashMap<byte[]>, and storing the map value as an ascii byte array rather than String.

作为替代方案,是否有一个键值存储只需要添加jar文件,不会立即将整个地图保存在RAM中,并且仍然合理快?

As an alternative to that, is there a key-value store that only requires adding jar files, does not hold the entire map in RAM at once, and is still reasonably fast?

推荐答案

使用

Use Berkeley DB.

这绝对可以让你在内存和速度方面获得巨大收益,而不是增加应用程序的复杂性。享受!

This should definitely give you huge gains in memory and speed, while not increasing the complexity of your application. Enjoy!

这篇关于键值商店建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 08:14