java.util.Map 的现有基于文件的实现
我正在开发一个使用自定义 Map
我搜索并发现Java版的Berkeley DB有java.util.Collection API(包括Map),但为此目的使用成熟的数据库似乎是多余的(它使用包含许多文件的目录,有几个额外的管理线程) 。有更简单的解决方案吗?
I'm working on a project that uses custom Map<String, Entry> (where Entry is a pair of ints) implementation based on B-tree to store from 10 to 100 millions of records, the code for this class is slow and dirty. I need efficient implementation of the Map, which uses a file for storage and a small amount of memory.
I searched and found that Java Edition Of Berkeley DB has java.util.Collection API (including Map), but it seems superfluous to use a fully fledged database for this purpose (it uses directory with many files, has several additional threads for management). Is there a simpler solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我最近遇到了同样的问题,并研究了一切,包括 NoSQL 和缓存。您需要一个基于磁盘/文件/支持的哈希图。
Berkeley DB Java 版是迄今为止最好的。它速度快、可扩展且完整,但如果不分发源代码或从 Oracle 购买商业版本,则无法将其分发给客户。
除了重新发明轮子之外,唯一的选择是 JDBM2。它还具有哈希图和树图。您负责定期刷新到磁盘以防止 OutOfMemoryError,它的速度不如 Berkeley DB,但它是一个非常好的第二选择。
I had this very same problem recently and looked at everything under the sun, including NoSQL and caches. You want a disk/file based/backed hashmap.
Berkeley DB Java Edition is by far the best. It's fast, scalable, and complete, but you can't distribute it to clients without distributing your source code or buying the commercial version from Oracle.
The only other choice, besides reinventing the wheel, is JDBM2. It also has a hashmap and a tree map. You are responsible for regularly flushing to disk to prevent OutOfMemoryError and it isn't near as fast as Berkeley DB but it is a very good 2nd choice.
看一下 Kyoto Cabininet,一个磁盘支持的 DBM 实现。我使用过以前的版本,Tokyo Cabinet - 它非常容易使用,基本上就像原生< code>Map,而且速度非常快。
Take a look at Kyoto Cabininet, a disk-backed DBM implementation. I've used the previous version, Tokyo Cabinet - it was dead easy to use, basically just like a native
Map
, and very fast.JDBM 是一个轻量级、纯 Java B-Tree 实现。
JDBM is a lightweight, pure Java B-Tree implementation.