Datastax 5.1 Graph loader - 从多个子目录加载统一文件
Datastax 5.1 Graph loader - loading uniform files from multiple subdirectories
图形加载器可以从明确定义的目录加载文件,但目前没有内置的方法可以自动递归地从多个子目录加载统一文件。
我找不到从多个子目录加载统一文件的任何示例,所以在搞清楚之后,我认为这会对 post 有所帮助,以帮助将来的其他人。有人有更好的方法吗?
//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"
}
}
图形加载器可以从明确定义的目录加载文件,但目前没有内置的方法可以自动递归地从多个子目录加载统一文件。
我找不到从多个子目录加载统一文件的任何示例,所以在搞清楚之后,我认为这会对 post 有所帮助,以帮助将来的其他人。有人有更好的方法吗?
//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"
}
}