前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >JanusGraph·上手JanusGraph

JanusGraph·上手JanusGraph

作者头像
陈黎栋
发布2020-02-18 10:14:42
2.1K0
发布2020-02-18 10:14:42
举报

目录

图存储比较

社区

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论坛
  • Chat: join us on Gitter
  • Stack Overflow: see the janusgraph tag
  • Twitter: follow @JanusGraph for news and updates
  • Mailing lists:
    • janusgraph-users (at) googlegroups.com (archives) for questions about using JanusGraph, installation, configuration, integrations To join with a Google account, use the web UI; to subscribe/unsubscribe with an arbitrary email address, send an email to:
      • janusgraph-users+subscribe (at) googlegroups.com
      • janusgraph-users+unsubscribe (at) googlegroups.com
    • janusgraph-dev (at) googlegroups.com (archives) for internal implementation of JanusGraph itself To join with a Google account, use the web UI; to subscribe/unsubscribe with an arbitrary email address, send an email to:
      • janusgraph-dev+subscribe (at) googlegroups.com
      • janusgraph-dev+unsubscribe (at) googlegroups.com

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.
    • http://tinkerpop.apache.org/docs/current/reference/#_gremlin_i_o You can load it like this: gremlin> graph = JanusGraphFactory.open("conf/janusgraph-hbase.properties") ==>standardjanusgraph[hbase:[127.0.0.1]] gremlin> graph.io(gryo()).readGraph("data/tinkerpop-modern.kryo") gremlin> graph.io(graphml()).readGraph("data/tinkerpop-modern.xml") gremlin> graph.io(graphson()).readGraph("data/tinkerpop-modern.json") If you have some other format file, you'll need to write code to read it in the data file, and then construct the graph elements based on the data.

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 of 3 rows. Source row, target row, and edge row. 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"
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 图存储比较
  • 中文入门资料
  • 社区
  • Architecture
  • About JanusGraph as RDF Store or Sparql Supporting
  • Install and Start gremlin.sh
  • Load/Import Data
相关产品与服务
图数据库 KonisGraph
图数据库 KonisGraph(TencentDB for KonisGraph)是一种云端图数据库服务,基于腾讯在海量图数据上的实践经验,提供一站式海量图数据存储、管理、实时查询、计算、可视化分析能力;KonisGraph 支持属性图模型和 TinkerPop Gremlin 查询语言,能够帮助用户快速完成对图数据的建模、查询和可视化分析。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档