gpt4 book ai didi

java - 在 Java 中用 Chronicle-Map 替换 Roaring64NavigableMap 的正确方法是什么?

转载 作者:行者123 更新时间:2023-12-02 09:48:50 27 4
gpt4 key购买 nike

我有一个使用 Roaring64NavigableMap 的代码作为 neo4j 插件,节点的长值使用 getId()来自Neo4J API .

我想使用Chronicle-Map 。我看到这个例子:

ChronicleSet<UUID> uuids =
ChronicleSet.of(Long.class)
.name("ids")
.entries(1_000_000)
.create();
  1. 如果我不知道要预测多少个值怎么办?确实.entries(1_000_000)限制缓存或数据库最大输入数
  2. 有没有办法处理大约十亿个条目的大量数据?
  3. 有没有更有效的方法来创建Chronicle-Map
  4. 我可以控制它使用的缓存大小吗?
  5. 我可以控制数据库存储的卷吗?

最佳答案

What if I don't know how many values to anticipate? does .entries(1_000_000) limit the cache or the DB max number of entries

来自 entries() 的 Javadoc方法:

Configures the target number of entries, that is going be inserted into the hash containers, created by this builder. If ChronicleHashBuilder.maxBloatFactor(double) is configured to 1.0 (and this is by default), this number of entries is also the maximum. If you try to insert more entries, than the configured maxBloatFactor, multiplied by the given number of entries, IllegalStateException might be thrown.

This configuration should represent the expected maximum number of entries in a stable state, maxBloatFactor - the maximum bloat up coefficient, during exceptional bursts.

To be more precise - try to configure the entries so, that the created hash container is going to serve about 99% requests being less or equal than this number of entries in size.

You shouldn't put additional margin over the actual target number of entries. This bad practice was popularized by HashMap.HashMap(int) and HashSet.HashSet(int) constructors, which accept capacity, that should be multiplied by load factor to obtain the actual maximum expected number of entries. ChronicleMap and ChronicleSet don't have a notion of load factor.

所以这是最大条目数,除非您指定 maxBloatFactor(2.0) (或 10.0 等)。目前,Chronicle Map 不支持这种情况:“我真的不知道我会有多少条目;也许 1;也许 10 亿;但我想创建一个可以有机增长到所需大小的 Map”。 This is a known limitation.

Is there a way to handle really big amount of data around a billion entries?

是的,如果你有足够的内存。尽管是内存映射的,但 Chronicle Map 的设计并不能在数据量显着大于内存时高效工作。在这种情况下,请使用 LMDB、RocksDB 或类似的东西。

关于java - 在 Java 中用 Chronicle-Map 替换 Roaring64NavigableMap 的正确方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56466187/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com