3 NEO4J Storage Structure
NEO4J, there are 4 types of nodes, attributes, relationships and other files are used as the core storage structure, and each data item of the type of node, attribute, relation, etc. is assigned a unique ID, which is the index of the array when it is stored. This enables quick positioning with its ID as the subscript when accessed. Therefore, in the graph traversal and other operations, you can implement Free-index.
3.1 Neo4j's Store section class diagram
3.1.1 Commonabstractstore.java
Commonabstractstore is the base class for all Store classes, the following code fragment is a member variable of Commonabstractstore, and it is important to have a few of them, especially idgenerator, each of which has its own ID for each store instance. Allocation Manager; Storechannel is responsible for reading and writing the store file, and Windowspool is the cache associated with the store record to improve performance.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
</pre>
<
div
>
public abstract
class CommonAbstractStore implements IdSequence
{
public static abstract
class Configuration
{
public static final Setting store_dir = InternalAbstractGraphDatabase.Configuration.store_dir;
public static final Setting neo_store = InternalAbstractGraphDatabase.Configuration.neo_store;
public static final Setting read_only = GraphDatabaseSettings.read_only;
public static final Setting backup_slave = GraphDatabaseSettings.backup_slave;
public static final Setting use_memory_mapped_buffers = GraphDatabaseSettings.use_memory_mapped_buffers;
}
public static final String ALL_STORES_VERSION =
"v0.A.2"
;
public static final String UNKNOWN_VERSION =
"Uknown"
;
protected Config configuration;
private final IdGeneratorFactory idGeneratorFactory; private final WindowPoolFactory windowPoolFactory;
protected FileSystemAbstraction fileSystemAbstraction;
protected final File storageFileName;
protected final IdType idType;
protected StringLogger stringLogger;
private IdGenerator idGenerator = null;
private StoreChannel fileChannel = null;
private WindowPool windowPool;
private boolean storeOk =
true
;
private Throwable causeOfStoreNotOk;
private FileLock fileLock;
private boolean readOnly =
false
; private boolean backupSlave =
false
;
private long highestUpdateRecordId = -1;
|
1.2 neo4j db file and corresponding storage format type
Filename |
File storage format |
Neostore.labeltokenstore.db |
Labeltokenstore (Tokenstore) |
Neostore.labeltokenstore.db.id |
ID type |
Neostore.labeltokenstore.db.names |
Stringpropertystore (abstractdynamicstore, name_store_block_size = 30) |
Neostore.labeltokenstore.db.names.id |
ID type |
Neostore.nodestore.db |
Nodestore |
Neostore.nodestore.db.id |
ID type |
Neostore.nodestore.db.labels |
Arraypropertystore (abstractdynamicstorelabel_block_size=60) |
Neostore.nodestore.db.labels.id |
ID type |
Neostore.propertystore.db |
PropertyStore |
Neostore.propertystore.db.arrays |
Arraypropertystore (abstractdynamicstorearray_block_size=120) |
Neostore.propertystore.db.arrays.id |
ID type |
Neostore.propertystore.db.id |
ID type |
Neostore.propertystore.db.index |
Propertyindexstore |
Neostore.propertystore.db.index.id |
ID type |
Neostore.propertystore.db.index.keys |
Stringpropertystore (abstractdynamicstore, name_store_block_size = 30) |
Neostore.propertystore.db.index.keys.id |
ID type |
Neostore.propertystore.db.strings |
Stringpropertystore (abstractdynamicstorestring_block_size=120) |
Neostore.propertystore.db.strings.id |
ID type |
Neostore.relationshipgroupstore.db |
Relationshipgroupstore |
Neostore.relationshipgroupstore.db.id |
ID type |
Neostore.relationshipstore.db |
Relationshipstore |
Neostore.relationshipstore.db.id |
ID type |
Neostore.relationshiptypestore.db |
Relationshiptypetokenstore (Tokenstore) |
Neostore.relationshiptypestore.db.id |
ID type |
Neostore.relationshiptypestore.db.names |
Stringpropertystore (abstractdynamicstore, name_store_block_size = 30) |
Neostore.relationshiptypestore.db.names.id |
ID type |
Neostore.schemastore.db |
Schemastore (Abstractdynamicstore, block_size = 56) |
Neostore.schemastore.db.id |
ID type |
Graph DATABASE_NEO4J underlying storage structure Analysis (2)