Orientdb最快的批量导入

Orientdb fastest batchimport

我正在尝试找到从 CSV 将边导入到 OrientDB Graph 的最快方法。 (我的OrientDB版本是2.1.15。)

现在我有一个包含 10 万个顶点和 150 万条边的图。很快我会将其大小增加到 100M 顶点和 100B+ 边,我不想等到导入结束几个月:)

我试过用不同的方法来做到这一点:

  1. 默认 JSON ETL。边缘加载率约为 200-300 rows/sec。非常慢,大约需要 1.5 小时。尝试更改 "Tx" 模式和其他属性,它没有对性能进行任何更改。

  2. Java 使用 class BatchGraph 的代码。我在这里为事务尝试了不同的缓冲区大小,大小为 10 时实现了最佳性能。但它对我来说仍然很慢:大约 45m。

  3. 从控制台导入特殊 JSON 格式(IMPORT DATABASE 命令)。 (顺便说一下,它不如前两个对我的任务好。)但它也很慢 - 大约 1 小时。

那么,是否有任何种可能性在短时间内将这样的Graph(1.5M Edges)导入OrientDB?非常适合我:不到 1 分钟。如果我可以改进我的代码,请告诉我。

我的json:

{
  "source": { "file": { "path": "/opt/orientdb/orientdb-community-2.1.15/bin/csv/1_1500k_edges.csv" } },
  "extractor": { "csv": {} },
  "transformers": [
    { "merge": { "joinFieldName": "ids", "lookup": "V.id" } },
    { "vertex": { "class": "V" } },
        { "edge": { "class": "Edges",
                "joinFieldName": "ide",
                "lookup": "V.id",
                "direction": "out",
                "edgeFields": { "val": "${input.val}" },
                "unresolvedLinkAction": "CREATE"} }
  ],
  "loader": {
    "orientdb": {
       "dbURL": "remote:localhost/graph",
       "dbType": "graph",
       "wal":false,
       "tx":true,
       "batchCommit":1000,
       "standardElementConstraints": false,
        "classes": [
         {"name": "V"},
         {"name": "Edges", "extends": "E"}
       ], "indexes": [
         {"class":"V", "fields":["id:integer"], "type":"UNIQUE" }
       ]
    }
  }
}

Java代码:

this.graph = new OrientGraph(this.host, this.name, this.pass);
this.graph.setStandardElementConstraints(false);
this.graph.declareIntent(new OIntentMassiveInsert());
BatchGraph<OrientGraph> bgraph = new BatchGraph<OrientGraph>(this.graph, VertexIDType.NUMBER, buff);
bgraph.setVertexIdKey("id");
<parsing strings from CSV in id[0], id[1] and val - edge property>:
  Vertex[] vertices = new Vertex[2];
  for (int i=0;i<2;i++) {
    vertices[i] = bgraph.getVertex(id[i]);
    if (vertices[i]==null) vertices[i]=bgraph.addVertex(id[i]);
  }
  Edge edge = bgraph.addEdge(null, vertices[0], vertices[1], "Edges");
  edge.setProperty("val", val);

我认为您必须在 ~1 分钟内完成导入的唯一方法是在 plocal 中工作:

 this.graph = new OrientGraph("plocal:/physical/path/to/db/dir", this.name, this.pass);

如果是一次性导入,您可以从 java 程序中执行,如果是重复操作并且您需要在独立实例上 运行,您可以定义一个服务器端函数来执行此操作并使用插件公开它

http://orientdb.com/docs/2.0/orientdb.wiki/Extend-Server.html