该文档有示例:https ://docs.datastax.com/en/latest-dse/datastax_enterprise/graph/dgl/dglCSV.html
下面是一个适用于 JSON 数据的示例加载器脚本,但它显示了如何从同一记录加载顶点和边,使用映射器来决定使用哪些元素。
config load_threads: 8
config batch_size: 1000
config load_new: true
config driver_retry_attempts: 10
config driver_retry_delay: 1000
/** SAMPLE INPUT
{"actor_name":"'Bear'Boyd, Steven","title_name":"The Replacements","year":"2000","role":"Defensive Tackle - Washington Sentinels","episode":"The Replacements"}
*/
input = File.json(filename )
//Defines the mapping from input record to graph elements
actorMapper = {
key "actor_name" // the unique id for an actor
label "actor"
ignore "title_name"
ignore "role"
ignore "year"
ignore "episode"
}
titleMapper = {
key "title_name" // the unique id for a title
label "title"
ignore "sex"
ignore "actor_name"
ignore "role"
ignore "episode"
}
castMapper = {
label "cast"
outV "actor_name", {
label "actor"
key "actor_name"
}
inV "title_name", {
label "title"
key "title_name"
}
ignore "year"
ignore "sex"
// remaining should be edge properties
// pickup role as property
// pickup episode as property
}
//Load vertex records from the input according to the mapping
load(input).asVertices(actorMapper)
load(input).asVertices(titleMapper)
load(input).asEdges(castMapper)