0
圖形加載器可以從明確定義的目錄加載文件,但目前沒有內置的方式來自動遞歸加載來自多個子目錄的統一文件。Datastax 5.1圖形加載器 - 從多個子目錄加載統一文件
圖形加載器可以從明確定義的目錄加載文件,但目前沒有內置的方式來自動遞歸加載來自多個子目錄的統一文件。Datastax 5.1圖形加載器 - 從多個子目錄加載統一文件
我找不到任何加載來自多個子目錄的統一文件的例子,所以在弄清楚之後,我認爲在這裏發佈這個文件以幫助未來的其他人是有幫助的。有沒有人有更方便的方法?
//configure graphloader
config dryrun: false, load_vertex_threads: 2, load_edge_threads: 3,
read_threads: 1, preparation: true, create_schema: false,
abort_on_prep_errors: true
import java.io.File as javaFile; //this must be aliased so as to not conflict with graphloader's File.directory()
inputBaseDir = /path/to/base/dir
//base directory has many subdirectories that have many uniform files to load
//create a list of the subdirectory paths
def list = []
new javaFile(inputBaseDir).eachDir() { dir ->
list << dir.getAbsolutePath()
}
//loop through the list of subdirectory paths
for (item in list){
def fileBuilder = File.directory(item)
def theData = fileBuilder.map{
it["specificDataLabel"] = it["data"]["specificData"][0];
it["otherSpecificDataLabel"] = it["data"]["otherSpecificData"][0];
it.remove("data")
it
}
load(theData).asVertices {
label "theLabel"
key "specificDataLabel"
vertexProperty "otherSpecificDataLabel",{
value "metaPropertyLabel"
value "otherMetaPropertyLabel"
}
}