liugh
2021 年7 月 15 日 10:56
1
从Nebula的Github上可以发现,Nebula提供了以下语言的Cilent:
nebula-cpp
nebula-java
nebula-go
nebula-python
nebula-node
nebula-rust
我们公司的主体语言是C#,没有看到Nebula提供C#版的客户端
我看nebula提供的客户端,都是基于Thrift中间语言生成的不同语言的代码,因此想通过对应的thrift文件生成C#代码
1.在windows环境中,我下载了最新的thrift编译器:
2.从Nebula-common工程下载了graph.thrift、common.thrift两个文件:
3.利用第一步中的thrift编译器,对第二步中的graph.thrift文件进行编译,生成C#代码
thrift-0.14.2.exe -r --gen java graph.thrift
4.结果报错:
[WARNING:D:/Program Files/thrift/bin/common.thrift:58] The “byte” type is a compatibility alias for “i8”. Use “i8” to emphasize the signedness of this type.
[ERROR:D:/Program Files/thrift/bin/common.thrift:106] (last token was ‘(’)
syntax error
[FAILURE:D:/Program Files/thrift/bin/common.thrift:106] Parser error during include pass.
希望Nebula的大神能协助解决一下。
1 个赞
thrift的生成只支持linux的,用的是fbthrift生成的thrift执行文件生成的,不是apache 的thrift文件。还有c#直接生成应该是不能用的。假如你有兴趣去试下,你可以编译参考文档 源码编译安装 - Nebula Graph Database 手册 去编译
GitHub - vesoft-inc/nebula-common: Common code for all Nebula projects ,在 nebula-common/build/src/common/interface/gen-csharp 下面就是你要的文件
1 个赞
liugh
2021 年7 月 15 日 14:11
3
我在Windows 下用apache 的thrift已经生成成功了!
我看了下报错的那一行是:
Vertex (cpp.type = “nebula::Vertex”) vVal (cpp.ref_type = “unique”);
改为:
Vertex vVal;
就可以了,因为我要生成的是C#的,不用管C++的
剩下的这几个都是这样改的:
9: Vertex (cpp.type = "nebula::Vertex") vVal (cpp.ref_type = "unique");
10: Edge (cpp.type = "nebula::Edge") eVal (cpp.ref_type = "unique");
11: Path (cpp.type = "nebula::Path") pVal (cpp.ref_type = "unique");
12: NList (cpp.type = "nebula::List") lVal (cpp.ref_type = "unique");
13: NMap (cpp.type = "nebula::Map") mVal (cpp.ref_type = "unique");
14: NSet (cpp.type = "nebula::Set") uVal (cpp.ref_type = "unique");
15: DataSet (cpp.type = "nebula::DataSet") gVal (cpp.ref_type = "unique");
liugh
2021 年7 月 15 日 14:14
4
至于你说的fbthrift以及手动编译的,我再研究下。
我把你们提供的Java Client的代码看完了,我计划基于生成的C#的代码,将Java Client的翻译一遍,我们只用Graph的就行,也没几个类。
对.thrift文件的生成只是生成接口的定义和解析,但是网络库和协议库还是在 fbthrift 的repo里面实现的。
liugh
2021 年7 月 19 日 08:00
6
根据你的提示,我在虚拟机中编译了一下C#的客户端,已经生成了接口的定义和解析。
我在博客中总结了一下:C#版Nebula客户端编译 - 静若清池 - 博客园
我对比了一下生成的java代码,和你们提供的Nebula的Java客户端,多了两部分的代码:
fbthrift/com/facebook/thrift
java/com/vesoft/nebula
还有你说的“网络库和协议库还是在 fbthrift 的repo里面实现的”,以上能详细解释一下吗?
1 个赞
wey
2021 年7 月 19 日 10:44
7
@liugh ,看了您的文章,真的太赞了,欢迎您继续做封装的 porting 尝试并回馈社区
cc @dingding @steam
liugh
2021 年7 月 19 日 13:52
8
从2020年8月份开始,我们一直在跟Nebula,目前已经将Nebula与Flink结合,应用在微服务链路调用关系、用户访问风控、基于知识图谱的机器画像上了,都是用Java写的代码,后面我会写文章做分享。
Nebula确实很优秀,但是我们的主要开发语言是C#,现在无法让懂C#的业务人员也享受Nebula的红利,所以我就尝试做C#的客户端,希望能和志同道合的大神一起把它搞出来。
2 个赞
liugh
2021 年7 月 19 日 22:04
9
1.fbthrift/com/facebook/thrift:
找到来源了:
https://github.com/facebook/fbthrift/tree/master/thrift/lib/java
2.java/com/vesoft/nebula
这个应该是你们自己封装的Java Client代码,这才是真正自己写的代码
看了下fbthrift提供的lib,唯独没有C#,同时检索到以下两个帖子:
已打开 09:45PM - 07 Apr 20 UTC
已关闭 09:58PM - 07 Apr 20 UTC
Are there plans to add support for C#, for example via .NET Standard?
已打开 04:06AM - 11 Nov 20 UTC
已关闭 06:03AM - 20 Jan 21 UTC
**Is your feature request related to a problem? Please describe.**
I'm a. Net d… eveloper. I want to use nebula and I hope to have a. Net client
**Describe the solution you'd like**
Increased support for. Net clients
看来提供C#版的Nebula客户端举步维艰呀。
是的,fbthrift没有提供完整,但是你可以试下用Apache的thrift lib,现在nebula node client就是直接用 Apache的thrift lib的,当然对 .thrift文件生成的接口定义和编解码也需要修改成 Apache 可用的。你可以看下 GitHub - vesoft-inc/nebula-node: Nebula Graph Client API in Node.js 里面的处理
1 个赞
liugh
2021 年7 月 20 日 11:52
12
好的,我看看。
另外您说的“当然对 .thrift文件生成的接口定义和编解码也需要修改成 Apache 可用的”,如果是这样的话,那直接用Apache 的Thrift,对Nebula的.thrift文件进行生成,有区别吗?
Apache 的Thrift 对 nebula 定义的 thrift 格式不识别,需要做修改
system
关闭
2021 年8 月 20 日 09:44
14
该话题在最后一个回复创建后30天后自动关闭。不再允许新的回复。