Graph DATABASE_NEO4J underlying storage structure analysis (1)

Source: Internet
Author: User
Tags neo4j

1 physical storage model for nodes and relationships in NEO4J 1.1 neo4j storage model

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 R Elationship from Node 1 to Node 2 in the case. Once we ' ve found the relationship record of interest, we can simply read its properties if there is any via the same sing ly-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, the of course give the immediate offset of both nodes in the node store file.

The above English is excerpted from <graph databases> (Ianrobinson), which describes the NEO4J storage model. The property of node and relationship is saved with a two-way list of Key-value, and node's relatsionship is saved by a two-way list, which makes it easy to find the from-to node of the relationship. Node nodes hold the 1th attribute and the 1th relationship ID.

With the above storage model, starting from a node-a, it is convenient to traverse the graph with the node-a as the starting point. Here is an example to help understand the storage model above, and the exact format of the stored file is described in detail in chapter 2nd.

1.2 Example 1

In this example, A~e represents the number of node, R1~R7 represents the relationship number, and P1~P10 represents the property's number.

    • Node's storage example diagram below, each node holds the 1th property and the 1th relationship:

    • The storage of the relationship is as follows:

As you can see, starting from Node-b, you can traverse all the relationships of the node-b through the next pointer of the relationship, and then you can reach the 1th level nodes that has a relationship with it, and at the 1th level nodes, you can reach the 2nd layer nodes,...

2 Description of storage files for NEO4J graph db

When we download neo4j-community-2.1.0-m01 and install, and then take neo4j Embedded-example's embeddedneo4j example run, you can see in target/ NEO4J-HELLO-DB will generate the following NEO4J graph DB storage file.

-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

2.1 Storing node's files

1) Storage node data and its sequence ID

    • NEOSTORE.NODESTORE.DB: Storage node array, array subscript is the ID of the node
    • Neostore.nodestore.db.id: Store the largest ID and the already free ID

2) Storage node label and its sequence ID

    • Neostore.nodestore.db.labels: Storage node label array data, array subscript is the ID of the node label
    • Neostore.nodestore.db.labels.id
2.2 Storage of relationship files

1) Store relationship data and its sequence ID

    • Neostore.relationshipstore.db Storage Relationship Record array data
    • Neostore.relationshipstore.db.id

2) Store Relationship group data and its sequence ID

    • Neostore.relationshipgroupstore.db Storage Relationship Group Array data
    • Neostore.relationshipgroupstore.db.id

3) Storage relationship type and its sequence ID

    • Neostore.relationshiptypestore.db storage Relationship Type Array data
    • Neostore.relationshiptypestore.db.id

4) name of the storage relationship type and its sequence ID

    • Neostore.relationshiptypestore.db.names Storage Relationship Type token array data
    • Neostore.relationshiptypestore.db.names.id
2.3 Storing a label file

1) Store the label token data and its sequence ID

    • Neostore.labeltokenstore.db storing lable token array data
    • Neostore.labeltokenstore.db.id

2) store the label token name data and its sequence ID

    • Neostore.labeltokenstore.db.names store names data for label tokens
    • Neostore.labeltokenstore.db.names.id
2.4 Files that store property

1) store attribute data and its sequence ID

    • Neostore.propertystore.db Storing property data
    • Neostore.propertystore.db.id

2) storing the array type data and its sequence ID in the attribute data

    • The value of the Neostore.propertystore.db.arrays store property (Key-value structure) is the data of the array.
    • Neostore.propertystore.db.arrays.id

3) property data is a long string type of storage file and its sequence ID

    • The value of the Neostore.propertystore.db.strings store property (Key-value structure) is the data of the string.
    • Neostore.propertystore.db.strings.id

4) Index data file for attribute data and its sequence ID

    • Neostore.propertystore.db.index the index data of the key that stores the property (Key-value structure).
    • Neostore.propertystore.db.index.id

5) Key value data store file and sequence ID of attribute data

    • Neostore.propertystore.db.index.keys the string value of the key that stores the property (Key-value structure).
    • Neostore.propertystore.db.index.keys.id
2.5 Other files

1) Store version information

    • Neostore
    • Neostore.id

2) Storing schema data

    • Neostore.schemastore.db
    • Neostore.schemastore.db.id

3) logical log of activity

    • Nioneo_logical.log.active

4) record the log file name of the current activity

    • Active_tx_log

Graph DATABASE_NEO4J underlying storage structure analysis (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.