标签:
The node records contain only a pointer to their first property and their first relationship (in what is oftentermed the _relationship chain). From here, we can follow the (doubly) linked-list of relationships until we find the one we’re interested in, the LIKES relationship from Node 1 to Node 2 in this case. Once we’ve found the relationship record of interest, we can simply read its properties if there are any via the same singly-linked list structure as node properties, or we can examine the node records that it relates via its start node and end node IDs. These IDs, multiplied by the node record size, of course give the immediate offset of both nodes in the node store file.
上面的英文摘自<Graph Databases>(作者:IanRobinson) 一书,描述了 neo4j 的存储模型。Node和Relationship 的 Property 是用一个 Key-Value 的双向列表来保存的; Node 的 Relatsionship 是用一个双向列表来保存的,通过关系,可以方便的找到关系的 from-to Node. Node 节点保存第1个属性和第1个关系ID。
通过上述存储模型,从一个Node-A开始,可以方便的遍历以该Node-A为起点的图。下面给个示例,来帮助理解上面的存储模型,存储文件的具体格式在第2章详细描述。
在这个例子中,A~E表示Node 的编号,R1~R7 表示 Relationship 编号,P1~P10 表示Property 的编号。
从示意图可以看出,从 Node-B 开始,可以通过关系的 next 指针,遍历Node-B 的所有关系,然后可以到达与其有关系的第1层Nodes,在通过遍历第1层Nodes的关系,可以达到第2层Nodes,…
当我们下载neo4j-community-2.1.0-M01 并安装,然后拿 neo4j embedded-example 的EmbeddedNeo4j 例子跑一下,可以看到在target/neo4j-hello-db下会生成如下neo4j graph db 的存储文件。
-rw-r–r– 11 04-11 13:28 active_tx_log
drwxr-xr-x 4096 04-11 13:28 index
-rw-r–r– 23740 04-11 13:28 messages.log
-rw-r–r– 78 04-11 13:28 neostore
-rw-r–r– 9 04-11 13:28 neostore.id
-rw-r–r– 22 04-11 13:28 neostore.labeltokenstore.db
-rw-r–r– 9 04-11 13:28 neostore.labeltokenstore.db.id
-rw-r–r– 64 04-11 13:28 neostore.labeltokenstore.db.names
-rw-r–r– 9 04-11 13:28 neostore.labeltokenstore.db.names.id
-rw-r–r– 61 04-11 13:28 neostore.nodestore.db
-rw-r–r– 9 04-11 13:28 neostore.nodestore.db.id
-rw-r–r– 93 04-11 13:28 neostore.nodestore.db.labels
-rw-r–r– 9 04-11 13:28 neostore.nodestore.db.labels.id
-rw-r–r– 307 04-11 13:28 neostore.propertystore.db
-rw-r–r– 153 04-11 13:28 neostore.propertystore.db.arrays
-rw-r–r– 9 04-11 13:28 neostore.propertystore.db.arrays.id
-rw-r–r– 9 04-11 13:28 neostore.propertystore.db.id
-rw-r–r– 61 04-11 13:28 neostore.propertystore.db.index
-rw-r–r– 9 04-11 13:28 neostore.propertystore.db.index.id
-rw-r–r– 216 04-11 13:28 neostore.propertystore.db.index.keys
-rw-r–r– 9 04-11 13:28 neostore.propertystore.db.index.keys.id
-rw-r–r– 410 04-11 13:28 neostore.propertystore.db.strings
-rw-r–r– 9 04-11 13:28 neostore.propertystore.db.strings.id
-rw-r–r– 69 04-11 13:28 neostore.relationshipgroupstore.db
-rw-r–r– 9 04-11 13:28 neostore.relationshipgroupstore.db.id
-rw-r–r– 92 04-11 13:28 neostore.relationshipstore.db
-rw-r–r– 9 04-11 13:28 neostore.relationshipstore.db.id
-rw-r–r– 38 04-11 13:28 neostore.relationshiptypestore.db
-rw-r–r– 9 04-11 13:28 neostore.relationshiptypestore.db.id
-rw-r–r– 140 04-11 13:28 neostore.relationshiptypestore.db.names
-rw-r–r– 9 04-11 13:28 neostore.relationshiptypestore.db.names.id
-rw-r–r– 82 04-11 13:28 neostore.schemastore.db
-rw-r–r– 9 04-11 13:28 neostore.schemastore.db.id
-rw-r–r– 4 04-11 13:28 nioneo_logical.log.active
-rw-r–r– 2249 04-11 13:28 nioneo_logical.log.v0
drwxr-xr-x 4096 04-11 13:28 schema
-rw-r–r– 0 04-11 13:28 store_lock
-rw-r–r– 800 04-11 13:28 tm_tx_log.1
1) 存储节点数据及其序列Id
2) 存储节点label及其序列Id
1) 存储关系数据及其序列Id
2) 存储关系组数据及其序列Id
3) 存储关系类型及其序列Id
4) 存储关系类型的名称及其序列Id
1) 存储label token数据及其序列Id
2) 存储label token名字数据及其序列Id
1) 存储属性数据及其序列Id
2) 存储属性数据中的数组类型数据及其序列Id
3) 属性数据为长字符串类型的存储文件及其序列Id
4) 属性数据的索引数据文件及其序列Id
5) 属性数据的键值数据存储文件及其序列Id
1) 存储版本信息
2) 存储 schema 数据
3) 活动的逻辑日志
4) 记录当前活动的日志文件名称
Graph database_neo4j 底层存储结构分析(1)
标签:
原文地址:http://www.cnblogs.com/gisblogs/p/4545741.html