Graph database_neo4j 底层存储结构分析(2)

3       neo4j存储结构

neo4j 中,主要有4类节点,属性,关系等文件是以数组作为核心存储结构;同时对节点,属性,关系等类型的每个数据项都会分配一个唯一的ID,在存储时以该ID 为数组的下标。这样,在访问时通过其ID作为下标,实现快速定位。所以在图遍历等操作时,可以实现 free-index。

3.1  neo4j 的 store 部分类图

neo4j-类图--store继承图

3.1.1   CommonAbstractStore.java

CommonAbstractStore 是所有 Store 类的基类,下面的代码片段是 CommonAbstractStore 的成员变量,比较重要的是飘红的几个,特别是IdGenerator,每种Store 的实例都有自己的 id 分配管理器; StoreChannel 是负责Store文件的读写和定位;WindowsPool 是与Store Record相关的缓存,用来提升性能的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
</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文件及对应的存储格式类型

文件名文件存储格式
neostore.labeltokenstore.dbLabelTokenStore(TokenStore)
neostore.labeltokenstore.db.idID 类型
neostore.labeltokenstore.db.namesStringPropertyStore (AbstractDynamicStore, NAME_STORE_BLOCK_SIZE = 30)
neostore.labeltokenstore.db.names.idID 类型
neostore.nodestore.dbNodeStore
neostore.nodestore.db.idID 类型
neostore.nodestore.db.labelsArrayPropertyStore (AbstractDynamicStorelabel_block_size=60)
neostore.nodestore.db.labels.idID 类型
neostore.propertystore.dbPropertyStore
neostore.propertystore.db.arraysArrayPropertyStore (AbstractDynamicStorearray_block_size=120)
neostore.propertystore.db.arrays.idID 类型
neostore.propertystore.db.idID 类型
neostore.propertystore.db.indexPropertyIndexStore
neostore.propertystore.db.index.idID 类型
neostore.propertystore.db.index.keysStringPropertyStore (AbstractDynamicStore, NAME_STORE_BLOCK_SIZE = 30)
neostore.propertystore.db.index.keys.idID 类型
neostore.propertystore.db.stringsStringPropertyStore (AbstractDynamicStorestring_block_size=120)
neostore.propertystore.db.strings.idID 类型
neostore.relationshipgroupstore.dbRelationshipGroupStore
neostore.relationshipgroupstore.db.idID 类型
neostore.relationshipstore.dbRelationshipStore
neostore.relationshipstore.db.idID 类型
neostore.relationshiptypestore.dbRelationshipTypeTokenStore(TokenStore)
neostore.relationshiptypestore.db.idID 类型
neostore.relationshiptypestore.db.namesStringPropertyStore (AbstractDynamicStore, NAME_STORE_BLOCK_SIZE = 30)
 neostore.relationshiptypestore.db.names.idID 类型
neostore.schemastore.dbSchemaStore(AbstractDynamicStore, BLOCK_SIZE = 56)
neostore.schemastore.db.idID 类型
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值