Performance 使用Ignite集群中另一个缓存中的数据充实缓存中的每个现有值

Performance 使用Ignite集群中另一个缓存中的数据充实缓存中的每个现有值,performance,ignite,Performance,Ignite,使用来自同一集群中另一个缓存的数据以最高效的方式更新Ignite缓存中每个现有值的字段的最佳方法是什么?每个字段大约有一个KB的数千万条记录 伪代码: try (mappings = getCache("mappings")) { try (entities = getCache("entities")) { entities.foreach((key, entity) -> entity.setInternalId(mappings.getValue(entity

使用来自同一集群中另一个缓存的数据以最高效的方式更新Ignite缓存中每个现有值的字段的最佳方法是什么?每个字段大约有一个KB的数千万条记录

伪代码:

try (mappings = getCache("mappings")) {
    try (entities = getCache("entities")) {
        entities.foreach((key, entity) -> entity.setInternalId(mappings.getValue(entity.getExternalId());
    }
}

我建议使用compute并向缓存拓扑中的所有节点发送闭包。然后,在每个节点上,您将迭代本地主集并执行更新。即使使用这种方法,您还是最好批量更新,并通过putAll调用或使用IgniteDataStreamer发布更新

注意:对于下面的示例,重要的是映射和实体缓存中的键是相同的或是共位的。有关搭配的更多信息,请参见:

伪代码如下所示:

ClusterGroup cacheNodes = ignite.cluster().forCache("mappings");

IgniteCompute compute = ignite.compute(cacheNodes.nodes());

compute.broadcast(() -> {
    IgniteCache<> mappings = getCache("mappings");
    IgniteCache<> entities = getCache("entities");

    // Iterate over local primary entries.
    entities.localEntries(CachePeekMode.PRIMARY).forEach((entry) -> {
       V1 mappingVal = mappings.get(entry.getKey());
       V2 entityVal = entry.getValue();

       V2 newEntityVal = // do enrichment;

       // It would be better to create a batch, and then call putAll(...)
       // Using simple put call for simplicity.
       entities.put(entry.getKey(), newEntityVal);
    }
});