目录
图存储比较
社区
Install and Start gremlin.sh
图存储比较
- titan 停止更新, janus 还未发布。
- neo4j 单机性能超高,分布式瓶颈大。
中文入门资料
图数据库JanusGraph介绍及使用(一):简介https://blog.csdn.net/gobitan/article/details/80939224
图数据库JanusGraph介绍及使用(二):架构https://blog.csdn.net/gobitan/article/details/80939276
图数据库JanusGraph介绍及使用(三):安装与初步使用:https://blog.csdn.net/gobitan/article/details/81068459
JanusGraph的schema及数据建模
JanusGraph查询和数据类型.https://docs.janusgraph.org/latest/search-predicates.html
社区
- https://groups.google.com/forum/#!forum/janusgraph-users Goole论坛
Architecture
一般来说,应用程序可以通过如下两种方式与JanusGraph交互:
- 嵌入式JanusGraph:它与执行Gremlin查询语言的应用程序运行在同一个JVM中。查询执行,JanusGraph图缓存和事务处理都发生在同一个JVM中,但后端的数据存储可以是本地也可以在远程。
- JanusGraph服务器:通过提交Gremlin语言到JanusGraph服务器来交互。
下面是JanusGraph的架构图
Gremlin是Apache TinkerPop的一个模块。
实战笔记
- JanusGraph的EdgeLabel和PropertyKey的name不能相同。
About JanusGraph as RDF Store or Sparql Supporting
- Simple Conclusion
- load rdf file to GREMLIN
-
https://groups.google.com/forum/#!topic/gremlin-users/nIE6uaSck8g
-
import org.openrdf.sail.memory.MemoryStore;
g = new SailGraph(new MemoryStore())
g.loadRDF('./test2.rdf', 'rdf-xml'))
-
Invalid import definition: 'org.openrdf.sail.memory.MemoryStore'; reason: startup failed:
script1532930094647133709938.groovy: 1: unable to resolve class org.openrdf.sail.memory.MemoryStore
@ line 1, column 1.
import org.openrdf.sail.memory.MemoryStore;
^
1 error
-
I cant understand SailGraph well, it need me to read the Tinkpop Documention
-
File Format SupportedJanusGraph supports 3 file formats that are provided via Apache TinkerPop -- Gryo, GraphML, and GraphSON.
Install and Start gremlin.sh
- 解压JanusGraph 0.1.1
- 安装hadoop和elasticsearch.
- 在下面这张众神图上做练习

visual symbol |
meaning |
---|
bold key
|
a graph indexed key
|
bold key with star
|
a graph indexed key that must have a unique value
|
underlined key
|
a vertex-centric indexed key
|
hollow-head edge
|
a functional/unique edge (no duplicates)
|
tail-crossed edge
|
a unidirectional edge (can only traverse in one direction)
|
- JanusGraph 0.1.1无需改动即可顺利运行以下命令。
- #Start gremlin.sh
- sudo ./gremlin.sh
- graph = JanusGraphFactory.build().set('storage.backend', 'inmemory').set('index.search.backend', 'elasticsearch').open()
- graph = JanusGraphFactory.build().set('storage.backend', 'inmemory').open() #不使用索引
- GraphOfTheGodsFactory.load(graph)
- Unknown external index backend: search
Type ':help' or ':h' for help.
- 貌似是必须要有set('index.search.backend', 'elasticsearch'),否则打不开。
- g = graph.traversal()
- saturn = g.V().has('name', 'saturn').next()
- 写入数据
- 同一个顶点同样的属性key写多次测试
JanusGraph·Java写数据.http://www.k6k4.com/chapter/show/aafiizxav1531746415578
graph = JanusGraphFactory.build().set('storage.backend', 'inmemory').open()
Vertex v1 = graph.addVertex("USER")
v1.property("uid", "100")
v1.property("uid").value()
==>100
v1.property("uid", "1001") #属性的修改
v1.property("uid").value()
==>1001
mgmt = graph.openManagement()
//创建了一个名字为name的属性,并设置值类型为String,且可以保存可以重复的多个值
nameKey = mgmt.makePropertyKey('name').dataType(String.class).cardinality(Cardinality.LIST).make()
mgmt.commit()
//存储并查询values为list类型的键值对
gremlin> v1.property("name","name1")
==>vp[name->name1]
gremlin> v1.property("name","name2")
==>vp[name->name2]
gremlin> v1.properties("name")
==>vp[name->name1]
==>vp[name->name2]
v1.property("age", 23);
Vertex v2 = graph.addVertex("PHONE");
v2.property("phone", "13811111111");
//创建边
Edge e12 = v1.addEdge("USER_PHONE", v2);
e12.property("create_time", "2018-08-08");
graph.tx().commit();
graph.close();
Load/Import Data
https://github.com/vsantosu/gremlin-importer
category, id, name, born_place, salary, siblings, rank, first_battle label, numeric, string, string, numeric, numeric, numeric, date hero, 1,3-D Man, Dmitriyevka,8.46,1,7,12/17/1995 villain, 2,A-Bomb (HAS), Roma,7.6,5,5,4/3/02004
- To our dataset, the first three lines will be:
category, id, srcUri
label, numeric, string
source,1,<http://dbpedia.org/ontology/description>
- edge.csv
- Each edge is represented as a combination of3 rows.Sourcerow,targetrow, andedgerow. For example:
id, numeric, 1428 id, numeric, 1 out,worked,hours, numeric, 1,date, date, 8/1/1984
- a ***label*** with value "worked"
- a numeric field named ***hours*** with value 1, and a date field named ***date*** with value "8/1/1984"
|