2
votes

I have a simple tree structure in a MySQL table (id, parentId) with about 3 million vertices and wanted to import this into a OrientDB Graph database. The ETL importer imports the vertices smoothly, but can't create edges (NullPointerException). The ETL does not even work on a plain database with the given examples in the documentation (http://orientdb.com/docs/last/Import-a-tree-structure.html throws the same exception), so I just imported the vertices and wanted to create the edges manually.

I have a Vertex class (Address) with two properties (id, parentId) and I want to create the Edges between these Vertices (parentId -> id). Is there a simple way to do this instead of inserting the edges in a loop? Something like in SQL

INSERT INTO E (out, in) VALUES (SELECT parentId, id FROM Address)

Since edges shall only be created with CREATE EDGE, I guess OrientDB does not support such an operation by default. But maybe there is a workaround to create these 3 million edges?

I found it is easy to create a link between the two records:

CREATE LINK parentLink TYPE LINK FROM Address.parentId TO Address.Id

However, I cannot create Edges in such a way. I tried working with variables

CREATE EDGE isParentOf FROM (SELECT FROM Address) TO (SELECT FROM Address WHERE id = $current.parentId)

But that does not work.

1
Did you already created the issue on ETL project? What release are you using?Lvca
No, I will create the issue on the ETL project next week. I am using orient db community edition 2.1Stephan

1 Answers

-1
votes

Have you tried this ETL Json:

{
  "config": {"log": "debug", "parallel": true },    
  "extractor" : {
    "jdbc": { "driver": "oracle.jdbc.driver.OracleDriver",
              "url": "jdbc:oracle:thin:hostname/db",    
              "userName": "username",    
              "userPassword": "password",    
              "query": "select id, A.parentId from Address a where rownum<2"     }    
  },    
  "transformers": [`enter code here`

    { "vertex": { "class": "Address" }},

    { "edge": { "class": "isParentOf",
      "joinFieldName": "parentId",
      "lookup": "Address.Id",
      "direction": "in",
      "skipDuplicates":true
    }
    }
    ],
    "loader": {
    "orientdb": {
      "dbURL": "remote:server/db",
      "dbUser": "user",
      "dbPassword": "passwd!",
      "dbType": "graph",
      "classes": [
        {"name": "Address", "extends": "V"},
        {"name": "isParentOf", "extends": "E"}
      ], "indexes": [
        {"class":"Address", "fields":["ID:string"], "type":"UNIQUE" }
      ]
    }
  }
}