2017-05-27 56 views
0

我是OrientDb的新手,但有一個問題和ETL腳本,我只是不知道爲什麼它不起作用。這是該方案:ETL腳本不創造邊緣

CSV文件:

PersonName,PersonAge,CarMake,CarAge 
John,23,Nissan,3 
Peter,45,Mini,25 
Paul,23,Morgan,15 
Jim,24,Mini,24 

的ETL JSON如下:

{ 
    "config": {"log": "INFO", 
    "fileDirectory": "/Users/johnbrogan/Downloads/orientdb-community-2.2.20/import/", 
    "fileName": "SimpleTest.csv", 
    "dbDirectory": "plocal:/Users/johnbrogan/Downloads/orientdb-community-2.2.20/databases/", 
    "dbName": "simpleTest", 
    "parallel": false 
    }, 
    "begin": [ 
    {"let": {"name": "$filePath", "expression": "$fileDirectory.append($fileName)"}}, 
    {"let": {"name": "$dbPath", "expression": "$dbDirectory.append($dbName)"}} 
    ], 
    "source": { "file": { "path": "$filePath", "lock": true } 
    }, 
    "extractor": { 
     "csv": {} 
    }, 
    "transformers": [{ 

    "vertex": { "class": "Person", "skipDuplicates": true}, 
    "edge": { 
     "unresolvedLinkAction": "CREATE", 
     "class": "hasCar", 
     "joinFieldName": "CarMake", 
     "lookup": "Car.CarMake" 
    } 
    }], 
    "loader": { 
    "orientdb": { 
     "dbURL": "$dbPath", 
     "dbType": "graph", 
     "batchCommit": 1000, 
     "dbAutoCreate": true, 
     "dbAutoDropIfExists": true, 
     "standardElementConstraints": false, 
     "classes": [ 
     {"name": "Person", "extends": "V"}, 
     {"name": "Car", "extends": "V"}, 
     {"name": "hasCar", "extends": "E"} 
     ], 
     "indexes": [ 
     {"class":"Person", "fields":["PersonName:string"], "type":"UNIQUE" }, 
     {"class":"Car", "fields":["CarMake:string"], "type":"UNIQUE" } 
     ] 
    } 
    } 
} 

腳本沒有警告和沒有錯誤運行。類和索引的創建與4 x Person記錄一樣,但Car記錄和hasCar邊不會創建。

在終端上的輸出是:

OrientDB etl v.2.2.20 (build 76ab59e72943d0ba196188ed100c882be4315139) https://www.orientdb.com 
[file] INFO Load from file /Users/johnbrogan/Downloads/orientdb-community-2.2.20/import/SimpleTest.csv 
[orientdb] INFO Dropping existent database 'plocal:/Users/johnbrogan/Downloads/orientdb-community-2.2.2 
0/databases/simpleTest'... 
BEGIN ETL PROCESSOR 
[file] INFO Reading from file /Users/johnbrogan/Downloads/orientdb-community-2.2.20/import/SimpleTest.c 
sv with encoding UTF-8 
Started execution with 1 worker threads 
[orientdb] DEBUG - OrientDBLoader: created vertex class 'Person' extends 'V' 
[orientdb] DEBUG orientdb: found 0 vertices in class 'null' 
[orientdb] DEBUG - OrientDBLoader: created vertex class 'Car' extends 'V' 
[orientdb] DEBUG orientdb: found 0 vertices in class 'null' 
[orientdb] DEBUG - OrientDBLoader: created edge class 'hasCar' extends 'E' 
[orientdb] DEBUG orientdb: found 0 vertices in class 'null' 
[orientdb] DEBUG orientdb: found metadata field 'null' 
[orientdb] DEBUG - OrientDBLoader: created property 'Person.PersonName' of type: string 
[orientdb] DEBUG - OrientDocumentLoader: created index 'Person.PersonName' type 'UNIQUE' against Class 
'Person', fields [PersonName:string] 
[orientdb] DEBUG orientdb: found metadata field 'null' 
[orientdb] DEBUG - OrientDBLoader: created property 'Car.CarMake' of type: string 
[orientdb] DEBUG - OrientDocumentLoader: created index 'Car.CarMake' type 'UNIQUE' against Class 'Car', 
fields [CarMake:string] 
Start extracting 
[csv] DEBUG document={CarMake:Nissan,PersonName:John,CarAge:3,PersonAge:23} 
[1:vertex] DEBUG Transformer input: {CarMake:Nissan,PersonName:John,CarAge:3,PersonAge:23} 
[csv] DEBUG document={CarMake:Mini,PersonName:Peter,CarAge:25,PersonAge:45} 
[csv] DEBUG document={CarMake:Morgan,PersonName:Paul,CarAge:15,PersonAge:23} 
[csv] DEBUG document={CarMake:Mini,PersonName:Jim,CarAge:24,PersonAge:24} 
Extraction completed 
[1:vertex] DEBUG Transformer output: v(Person)[#25:0] 
[2:vertex] DEBUG Transformer input: {CarMake:Mini,PersonName:Peter,CarAge:25,PersonAge:45} 
[2:vertex] DEBUG Transformer output: v(Person)[#26:0] 
[3:vertex] DEBUG Transformer input: {CarMake:Morgan,PersonName:Paul,CarAge:15,PersonAge:23} 
[3:vertex] DEBUG Transformer output: v(Person)[#27:0] 
[4:vertex] DEBUG Transformer input: {CarMake:Mini,PersonName:Jim,CarAge:24,PersonAge:24} 
[4:vertex] DEBUG Transformer output: v(Person)[#28:0] 
[orientdb] INFO committing 
Pipeline worker done without errors: true 
END ETL PROCESSOR 
+ extracted 4 rows (0 rows/sec) - 4 rows -> loaded 4 vertices (0 vertices/sec) Total time: 256ms [0 war 
nings, 0 errors] 

它看起來像邊緣變換沒有運行,任何想法,爲什麼?

回答

1

回答我自己的問題,爲任何其他Orientdb新手有類似問題的好處。這僅僅是一個不夠的{}案例。每個變壓器需要按照以下方式分配在他們自己的一套{}中

{ 
    "config": {"log": "INFO", 
    "fileDirectory": "/Users/johnbrogan/Downloads/orientdb-community-2.2.20/import/", 
    "fileName": "InventoryResults-05-17-2017-08h27m56s_top25.csv", 
    "dbDirectory": "plocal:/Users/johnbrogan/Downloads/orientdb-community-2.2.20/databases/", 
    "dbName": "msamlin-test001" 
    }, 
    "begin": [ 
    {"let": {"name": "$filePath", "expression": "$fileDirectory.append($fileName)"}}, 
    {"let": {"name": "$dbPath", "expression": "$dbDirectory.append($dbName)"}} 
    ], 
    "source": { "file": { "path": "$filePath", "lock": true } 
    }, 
    "extractor": { 
     "csv": {} 
    }, 
    "transformers": [ 

    {"vertex": { "class": "Asset", "skipDuplicates": true}}, 
    {"edge": { 
     "unresolvedLinkAction": "CREATE", 
     "class": "hasStatus", 
     "joinFieldName": "WMIStatus", 
     "lookup": "Status.name", 
     "targetVertexFields": { 
      "name": "${input.WMIStatus}" 
     } 
    }} 
    ], 
    "loader": { 
    "orientdb": { 
     "dbURL": "$dbPath", 
     "dbType": "graph", 
     "batchCommit": 1000, 
     "dbAutoCreate": true, 
     "dbAutoDropIfExists": true, 
     "classes": [ 
     {"name": "Asset", "extends": "V"}, 
     {"name": "Status", "extends": "V"}, 
     {"name": "hasStatus", "extends": "E"} 
     ], 
     "indexes": [ 
     {"class":"Asset", "fields":["ComputerName:string"], "type":"UNIQUE" }, 
     {"class":"Status", "fields":["name:string"], "type":"UNIQUE" } 
     ] 
    } 
    } 
}