目录
源码解析一:open(String properties-path)
源码解析二:open(ReadConfiguration configuration)
代码
一般情况下,我们有两种形式打开JanusGraph图查询引擎
(1)在终端中
graph = JanusGraphFactory.open('conf/janusgraph-cql-es.properties')
(2)在java代码中
JanusGraph graph = JanusGraphFactory.open(properties-path);
源码解析一:open(String properties-path)
public static JanusGraph open(String shortcutOrFile) {
return open(getLocalConfiguration(shortcutOrFile));
}
public static JanusGraph open(ReadConfiguration configuration) {
return open(configuration, null);
}
public static JanusGraph open(ReadConfiguration configuration, String backupName) {
}
可以看到properties文件从String类型的路径被转成ReadConfiguration类,然后生成了JanusGraph。JanusGraph源码中涉及到很多不同的configuration类,我们稍后会介绍open阶段从JG到Hbase底层用到的不同配置类的继承和依赖关系。
源码解析二:open(ReadConfiguration configuration)
return new StandardJanusGraph(new GraphDatabaseConfigurationBuilder().build(configuration));
除了上面大段的验证功能代码,最后一行才是open的核心代码。分为两部分
open源码解析一:build
GraphDatabaseConfigurationBuilder().build(configuration)
可以看到GraphDatabaseConfiguration需要四个参数作为实例化条件。基本都是由ReadConfiguration转化而来。其中我们可以注意到底层搜索需要的KeyColumnValueStoreManager类此时已经实例化。
open源码解析二:StandardJanusGraph
StandardJanusGraph(GraphDatabaseConfiguration configuration)
我们在下一篇解析实例化代码
本文是JanusGraph入坑笔记的第二部分,主要探讨如何通过`open`方法开启JanusGraph图查询引擎。内容涵盖两种开启方式:终端和Java代码。源码解析集中在`open(String properties-path)`和`open(ReadConfiguration configuration)`,分析了配置文件转化为ReadConfiguration的过程,以及在open过程中的关键步骤,包括GraphDatabaseConfiguration的构建和StandardJanusGraph的实例化。

730

被折叠的 条评论
为什么被折叠?



