Gremlin公司服务器等相关资料 郝伟 2021/05/18 [TOC]

1. 1 简介

1.1. HugeGraph 测试服务器

目前公司有两个测试服务器:

1.2. HG集群信息

现在HG的服务器有4台,所有SSH登陆信息均为 root,1。 相关信息如下: | 名称 | 服务器名 | IP地址 | |:---:|:---:|:---:| | HugeGraphTest | Master.Hdoop | 192.168.3.111 | | HugeGraphData0 | Slave2.Hadoop | 192.168.3.117 | | HugeGraphData1 | Slave0.Hadoop | 192.168.3.110 | | HugeGraphData2 | Slave1.Hadoop | 192.168.3.115 |

其中117还建立了内存模拟(与上面的集群独立),可以通过网址 http://192.168.3.117:8088/ 访问。

1.3. 服务器数据初始化代码

参考Gremlin入门

// 创建基本属性
graph.schema().propertyKey("name").asText().ifNotExist().create()
graph.schema().propertyKey("age").asInt().ifNotExist().create()
graph.schema().propertyKey("city").asText().ifNotExist().create()
graph.schema().propertyKey("lang").asText().ifNotExist().create()
graph.schema().propertyKey("date").asText().ifNotExist().create()
graph.schema().propertyKey("price").asInt().ifNotExist().create()

// 创建person顶点
person = graph.schema().vertexLabel("person").properties("name", "age", "city").primaryKeys("name").ifNotExist().create()
marko = graph.addVertex(T.label, "person", "name", "marko", "age", 29, "city", "Beijing")
vadas = graph.addVertex(T.label, "person", "name", "vadas", "age", 27, "city", "Hongkong")
josh = graph.addVertex(T.label, "person", "name", "josh", "age", 32, "city", "Beijing")
peter = graph.addVertex(T.label, "person","name", "peter", "age", 29, "city", "Shanghai")

// 创建software顶点
software = graph.schema().vertexLabel("software").properties("name", "lang", "price").primaryKeys("name").ifNotExist().create()
lop = graph.addVertex(T.label, "software", "name", "lop", "lang", "java", "price", 328)
ripple = graph.addVertex(T.label, "software", "name", "ripple", "lang", "java", "price", 199)

// 创建knows边
knows = graph.schema().edgeLabel("knows").sourceLabel("person").targetLabel("person").properties("date").ifNotExist().create()
marko.addEdge("knows", vadas, "date", "20160110")
marko.addEdge("knows", josh, "date", "20130220")
marko.addEdge("created", lop, "date", "20171210", "city", "Shanghai")

// 创建created边
created = graph.schema().edgeLabel("created").sourceLabel("person").targetLabel("software").properties("date", "city").ifNotExist().create()
josh.addEdge("created", ripple, "date", "20151010", "city", "Beijing")
josh.addEdge("created", lop, "date", "20171210", "city", "Beijing")
peter.addEdge("created", lop, "date", "20171210", "city", "Beijing")

2. 2 Gremlin 参考资料

2.1. Gremlin 常用语法总结 (难度★★)

URL:http://tang.love/2018/11/15/gremlin_traversal_language/ 发表于 2018-11-15 | 更新于 2021-01-12 | 分类于 知识图谱 | 评论数: | 阅读次数:

Gremlin是 Apache TinkerPop 框架下的图遍历语言。Gremlin是一种函数式数据流语言,可以使得用户使用简洁的方式表述复杂的属性图(property graph)的遍历或查询。每个Gremlin遍历由一系列步骤(可能存在嵌套)组成,每一步都在数据流(data stream)上执行一个原子操作。

Gremlin 语言包括三个基本的操作:map-step:对数据流中的对象进行转换;filter-step:对数据流中的对象就行过滤;和 sideEffect-step:对数据流进行计算统计;

Tinkerpop3 模型核心概念:

  • Graph: 维护节点&边的集合,提供访问底层数据库功能,如事务功能
  • Element: 维护属性集合,和一个字符串label,表明这个element种类
  • Vertex: 继承自Element,维护了一组入度,出度的边集合
  • Edge: 继承自Element,维护一组入度,出度vertex节点集合.
  • Property: kv键值对
  • VertexProperty: 节点的属性,有一组健值对kv,还有额外的properties 集合。同时也继承自element,必须有自己的id, label.
  • Cardinality: 「single, list, set」 节点属性对应的value是单值,还是列表,或者set。

    2.2. Gremlin:图遍历语言 (难度★★)

    URL:https://www.cnblogs.com/myitroad/p/7727570.html

Gremlin包括三个基本的操作:

  • map-step 对数据流中的对象进行转换;
  • filter-step 对数据流中的对象就行过滤;
  • sideEffect-step 对数据流进行计算统计;

包括了Gremlin在一些场景中的很多具体应用。

2.3. gremlin语句详解 (难度★★★★)

https://blog.csdn.net/weixin_42076409/article/details/80856911

讲解了 一、Lambda Step,包括map ,flatMap ,filter,sideEffect,branch,值得学习。

2.4. 深入学习图数据库语言Gremlin系列汇总 (难度★★★★★)

URL: https://blog.csdn.net/javeme/article/details/82631834) 内容很丰富,推荐阅读。主要有25个章构成,包括以下内容: 图基本概念与操作、边的遍历操作、has条件过滤、图查询返回结果数限制、查询路径path、循环操作、查询结果排序、数据分组与去重、条件和过滤、逻辑运算、统计运算、数学运算、路径选取与过滤、分支、合并、结果聚集与展开、模式匹配、随机过滤与注入、结果存取口袋sack、遍历栅栏barrier、局部操作local、遍历终止terminal、转换操作map/flatMap、附加操作sideEffect、执行统计和分析等。

2.5. Apache TinkerPop™ (难度★★)

http://tinkerpop.apache.org/ 推荐阅读,网站内有大量系统、查询语言、驱动和应用示例。

2.6. Gremlin中文文档 (难度★★★★)

http://tinkerpop-gremlin.cn/ 注意:此文档是官方gremlin文档的中文翻译。对于操作阿里云GDB图数据库而言,是在gremlin语言框架下的实现, 这就意味着很多单步具有特殊的实现和约定。使用特定的语义和方式能够让图遍历更有效率。 阿里云GDB团队翻译,如有疑问,订正,和转载需求,请发信至 nosql@list.alibaba-inc.com

2.7. 百度官方文档:Welcome to HugeGraph

https://hugegraph.github.io/hugegraph-doc/

HugeGraph是一款易用、高效、通用的开源图数据库系统(Graph Database,GitHub项目地址), 实现了Apache TinkerPop3框架及完全兼容Gremlin查询语言, 具备完善的工具链组件,助力用户轻松构建基于图数据库之上的应用和产品。HugeGraph支持百亿以上的顶点和边快速导入,并提供毫秒级的关联关系查询能力(OLTP), 并可与Hadoop、Spark等大数据平台集成以进行离线分析(OLAP)。

2.8. HugeGraph&Gremlin 常用语句汇总 (难度★★)

https://www.it610.com/article/1281653249346125824.htm 包括:Schema、顶点和边、索引、检索等内容的语法。

results matching ""

    No results matching ""