使用 Gremlin.net 读取/保存文件



我是 gremlin的新手,但我已经成功地拥有一个 janusgraph dockerized 数据库,并使用 Gremlin.Net 3.4.7 连接到它(感谢在 stackoverflow :D 上找到的教程 PRACTICAL GREMLIN (。 我试试这个:

using (GremlinClient client = new GremlinClient(new GremlinServer("localhost", 8182)))
{
g = AnonymousTraversalSource.Traversal().WithRemote(new DriverRemoteConnection(client));
g.AddV("testV").Iterate();
var vertex = g.V().ToList();
}

连接很好,因为 AddV(( 方法成功了。 现在我想将一个 graphml 文件加载到数据库中,并将数据库内容提取到另一个文件中。 但是当我尝试阅读时:

using (GremlinClient client = new GremlinClient(new GremlinServer("localhost", 8182)))
{
g = AnonymousTraversalSource.Traversal().WithRemote(new DriverRemoteConnection(client));
g.Io<Gremlin.Net.Structure.Vertex>(@"C:GremlintoRead.graphml").Read().Iterate();
var vertex = g.V().ToList();
}

它的返回:"ServerError: C:\Gremlin\toRead.graphml 不存在" 并写道:

using (GremlinClient client = new GremlinClient(new GremlinServer("localhost", 8182)))
{
g = AnonymousTraversalSource.Traversal().WithRemote(new DriverRemoteConnection(client));
g.Io<Gremlin.Net.Structure.Vertex>(@"C:Gremlinextract.graphml").Write().Iterate();
var vertex = g.V().ToList();
}

它的回归: "服务器错误:无法检测到文件格式 - 显式指定编写器或使用标准扩展名重命名文件">

你有没有遇到过这个错误? 你能看到我错过了什么吗? 谢谢你的时间,

副移位

对于读取(和写入(,请注意位置@"C:GremlintoRead.graphml"相对于 Gremlin 服务器而不是您的本地客户端。我认为这就是找不到您的文件的原因。在写入端,请注意,要使用您正在使用的语法,该文件必须以.xml结尾才能被识别为 GraphML 文件。如果你必须使用.xml文件扩展名,那么你必须告诉Gremlin你想要GraphML格式:

g.io('extract.graphml').with(IO.writer, IO.graphml).write()

最新更新