如何使用 MongoDB-Java 实现基于磁盘的哈希映射 [英] How to implement Disk Based Hash Map using MongoDB-Java
问题描述
我必须在我的 HashMultiMap 中存储超过 1 亿个键值(键可以有多个值).任何人都可以帮助我,这可以使用 Java-MongoDB 实现吗?MongoDB 的性能是否与内存中的哈希映射大致相同?关于如何在 MongoDB 中创建和维护 HashMap 的一些不错的教程的指针也对我有帮助.
I have to store more than 100 millions of key-values in my HashMultiMap (key can have multiple values). Can anybody help me, is this possible to implement using Java-MongoDB ? Is the performance of MongoDB approximately identical to in-memory hash map ? Pointer to some nice tutorial about how to create and maintain HashMap in MongoDB is also helpful to me.
推荐答案
同样,我不知道你的 HashMultiMap 将如何工作,但在 MongoDB 中你基本上将对象存储在 JSON 中(从技术上讲,增强的二进制 JSON).
Again, I don't know how is your HashMultiMap is going to work, but in MongoDB you basically store objects in JSON (enhanced binary JSON, technically speaking).
因此您的文档可能如下所示:
So your document could look like this:
{
key1: [value1, value2, value3, ...],
key2: [value1, value2, value3, ...],
...
}
如果这对你有用 - 太好了.
If that's gonna work for you - great.
这篇关于如何使用 MongoDB-Java 实现基于磁盘的哈希映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!