将所有Neo4J db加载到RAM [英] Loading all Neo4J db to RAM

查看:65
本文介绍了将所有Neo4J db加载到RAM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试将所有Neo4j DB加载到RAM,因此查询将更快地进行.将属性映射传递到图形创建时,我看不到该过程像以前那样占用更多的内存空间,并且它也不与磁盘上文件的空间成比例. 可能是什么问题呢?以及如何解决... 谢谢

I am trying to load all my Neo4j DB to the RAM so querying will work faster. When passing the properties map to the graph creation, I do not see the process taking more space in memory as it did before, and it is also not proportional to the space of files at disk. What could be the problem? and how can it be fixed.... Thanks

推荐答案

Neo4j延迟加载所有数据,这意味着它将在第一次访问时将它们加载到内存中.缓存选项仅与GC策略有关,因此何时(或是否)将对引用进行GC.要将整个图加载到内存中,您的缓存类型必须很强,并且需要遍历整个图一次.您可以这样做:

Neo4j loads all the data lazily, meaning it loads them into memory at first access. The caching option is just about the GC strategy, so when (or if) the references will be GCed. To load the whole graph into memory, your cache type must be strong and you need to traverse the whole graph once. You can do it like this:

// untested java code

import org.neo4j.helpers.collection.IteratorUtil;

// ...

for(Node node : graph.getAllNodes()) {
  IteratorUtil.count(node.getRelationships());
}

这样,所有节点和关系都将被使用一次,并因此加载到缓存中.

This way all nodes and relationships will be used once and thus loaded into the cache.

这篇关于将所有Neo4J db加载到RAM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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