Counting primitives in Neo4j

北城余情 提交于 2019-12-18 16:57:38

问题


I have been reading through the documentation for neo4j and it's components and have yet to come across functionality that lets me query the total number of primitives (nodes, relationships, and properties) in the graph. Does this functionality exist somewhere or am I going to have to write code that traverses the entire graph counting as it goes?


回答1:


Thanks for the question! I'm on the Neo4j team, and we currently have commercial tools which report this kind of information. However, an extension of the API is scheduled for the next open source version. For the time being you can use the following non-official API:

EmbeddedNeo.getConfig().getNeoModule().getNodeManager().getNumberOfIdsInUse(Class)

where the class would be Node.class, Relationship.class or PropertyStore.class.




回答2:


This worked for me:

import org.neo4j.kernel.impl.nioneo.store.PropertyStore

graph.getConfig().getGraphDbModule().getNodeManager().getNumberOfIdsInUse(Node.class);
graph.getConfig().getGraphDbModule().getNodeManager().getNumberOfIdsInUse(Relationship.class);
graph.getConfig().getGraphDbModule().getNodeManager().getNumberOfIdsInUse(PropertyStore.class)


来源:https://stackoverflow.com/questions/1111252/counting-primitives-in-neo4j

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!