键值商店建议 [英] key-value store suggestion

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

问题描述

我需要一个非常基本的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?

推荐答案

使用 Berkeley DB

Use Berkeley DB.


Berkeley DB直接在磁盘上的btree中存储对象图,集合中的对象或简单二进制密钥/值数据即可。这种简单,高效的方法消除了ORM解决方案中所有不必要的开销。使用直接持久层(DPL)Java开发人员使用存储信息注释类,就像JPA一样。这种方法熟悉,高效且快速。 DPL降低了数据存储的复杂性,同时又没有牺牲速度。

Berkeley DB stores object graphs, objects in collections, or simple binary key/value data directly in an a btree on disk. This simple, highly efficient approach removes all the unnecessary overhead in ORM solutions. Using the Direct Persistence Layer (DPL) Java developers annotate classes with storage information, much like JPA. This approach is familiar, efficient, and fast. The DPL reduces the complexity of data storage while not sacrificing speed.

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

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆