【问题标题】:Read/save a file with Gremlin.net使用 Gremlin.net 读取/保存文件
【发布时间】:2020-07-05 16:12:37
【问题描述】:

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

        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:\Gremlin\toRead.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:\Gremlin\extract.graphml").Write().Iterate();
            var vertex = g.V().ToList();
        }

它的回报: "ServerError: 无法检测文件格式 - 明确指定作者或使用标准扩展名重命名文件"

你遇到过这个错误吗?你能看到我错过了什么吗? 感谢您的宝贵时间,

变形

【问题讨论】:

    标签: c# janusgraph tinkerpop3 gremlin-server gremlinnet


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多