当前位置:网站首页>隐藏在 Nebula Graph 背后的星辰大海
隐藏在 Nebula Graph 背后的星辰大海
2022-07-02 12:22:00 【图数据库NebulaGraph】
作者介绍
大家好,我是 Anyzm,graph-ocean(GitHub:https://github.com/nebula-contrib/graph-ocean)项目发起人,目前就职于 360数科,岗位是高级 JAVA 开发工程师。
介绍完自己,这里来介绍下 graph-ocean 是什么?
graph-ocean 简介
graph-ocean 是一款基于 nebula-java 客户端的 ORM(Object Relational Mapping)框架,熟悉 ORM 的小伙伴应该都知道 ORM 是创建可在编程语言里使用的“虚拟对象数据库”,让开发人员更高效地开发业务。
而我将 Java ORM 取名为 graph-ocean 源自 Ocean 与 Nebula Graph 的 Nebula(星辰)相呼应,意为星辰大海。
为什要设计一款 Java ORM
社区用户如果对 360数科熟悉的话,读过我们技术团队写的《JanusGraph 到 NebulaGraph 迁移》(链接:https://discuss.nebula-graph.com.cn/t/topic/1172)便知道我们在 Nebula Graph 很早期便开始使用它,在官方正式发布 v1.0.0 之前就已经在测试环境跑起来了。
在 360数科使用 Nebula Graph v1.0.0 过程中,我们 Java 客户端是用枚举来呈列用到的 Tag 和 Edge 数据,而将 API 解析成 nGQL 的过程中也强依赖枚举,对业务代码侵入性强。
所以,在后来接触项目的过程中我就决心改变这种局面。
解决代码入侵问题
我们都知道无论是什么框架与数据库连接,框架最终都是会解析成数据库所能识别的语言。对于 Nebula Graph 而言,用户可以使用 openCypher,也可以使用 Nebula Graph 原生查询语言 nGQL。
在我们项目中习惯于使用 nGQL,所以将业务代码解析成 nGQL 这一步骤在使用 v1.0.0 的过程中已经完成了很大一部分。业务代码侵入性的特性是由于顶点和边的枚举所带来的,枚举的作用是定位 Tag 或者 Edge,而想要从实体类上无侵入地获取这些信息,我想到了模仿 JPA(Java Persistence API)注解的方式。
于是,graph-ocean 在脑海中便有了初步模样,实体类一旦确定,对应的 Tag 或者 Edge 应该也是确定的,所以可以用到缓存来提高性能。
(整体设计图)
简单设计之后,graph-ocean 就诞生了。开发出来之后,我和同事们用起来都感觉很爽,于是便决定将框架开源出来反哺给社区。
graph-ocean 特性
graph-ocean 可以让开发者更加优雅、更加灵活地对 Nebula Graph 读写,并且可以帮助我们快速地将实体和数据库数据实现互转(这也是 ORM 框架的特点),同时因为有缓存存在,所以性能方面也不必担心。
graph-ocean 的简单使用
graph-ocean 是由 Java 注解、反射、缓存、字符串拼接、nebula-java 连接池、session 管理等部分组成的。使用者如果有熟练的反射和连接池的开发经验就可以快速上手了,如果没有也没关系,主要抓住 NebulaSessionPoolManager(session 管理)、GraphMapper(基础的数据库操作类)、@GraphEdge(边注解)、@GraphVertex(顶点注解)、@GraphProperty(属性注解)、GraphQuery(查询API)、QueryResult(查询结果)这几个类或者接口就可以了。
graph-ocean 的未来规划
graph-ocean 目前还未支持 Nebula Graph 所有的内置函数(不过也已经满足大部分业务场景),由于 graph-ocean 依赖 nebula-java,所以随着 nebula-java 的版本更替,graph-ocean 也需要长期维护版本问题。
由于 graph-ocean 目前基本是由我一人在维护,文档也还不齐全,还有很多需要完善的点。
所以,下阶段是逐步完善使用文档,以及完善 API,同时希望有更多志同道合的人一起参与进来,维护 graph-ocean 这片星辰大海。
交流图数据库技术?加入 Nebula 交流群请先填写下你的 Nebula 名片,Nebula 小助手会拉你进群~~
边栏推荐
- Golang MD5 encryption and MD5 salt value encryption
- [2. Basics of Delphi grammar] 3 Object Pascal constants and variables
- 使用FFmpeg命令行进行UDP、RTP推流(H264、TS),ffplay接收
- Deux séquences ergodiques connues pour construire des arbres binaires
- List of sergeant schools
- 制作p12证书[通俗易懂]
- 已知兩種遍曆序列構造二叉樹
- (Video + graphic) machine learning introduction series - Chapter 5 machine learning practice
- Experiment collection of University "Fundamentals of circuit analysis". Experiment 6 - observation and measurement of typical signals
- Folium, diagnosis and close contact trajectory above
猜你喜欢
[development environment] install Visual Studio Ultimate 2013 development environment (download software | install software | run software)
全是精华的模电专题复习资料:基本放大电路知识点
Comparison between rstan Bayesian regression model and standard linear regression model of R language MCMC
使用 percona 工具给 MySQL 表加字段中断后该如何操作
Experiment collection of University "Fundamentals of circuit analysis". Experiment 4 - Research on linear circuit characteristics
动态规划入门一,队列的bfs(70.121.279.200)
PTA 天梯赛习题集 L2-001 城市间紧急救援
PHP static members
Loss function and positive and negative sample allocation: Yolo series
[salesforce] how to confirm your salesforce version?
随机推荐
[leetcode] 577 reverse word III in string
Lseek error
Review materials for the special topic of analog electronics with all essence: basic amplification circuit knowledge points
Experiment collection of University Course "Fundamentals of circuit analysis". Experiment 5 - Research on equivalent circuit of linear active two terminal network
树-二叉搜索树
beforeEach
全是精华的模电专题复习资料:基本放大电路知识点
将点云坐标转换成世界坐标的demo
【Salesforce】如何确认你的Salesforce版本?
Analysis of the difference between array and linked list
SQL FOREIGN KEY
Locate: cannot execute stat() `/var/lib/mlocate/mlocate Db ': there is no such file or directory
使用FFmpeg命令行进行UDP、RTP推流(H264、TS),ffplay接收
Soul torture, what is AQS???
College entrance examination admission score line climbing
[leetcode] 486 predict winners
[leetcode] 876 intermediate node of linked list
Jsp+mysql006 community management system
《大学“电路分析基础”课程实验合集.实验四》丨线性电路特性的研究
(4) Flink's table API and SQL table schema