0

我正在从 datastax 图中的 dataloader 加载 csv 文件。

我的 csv 文件结构如下

第一个文件(Year_2015.txt)

年号

第二个文件(BaseVehicle_2005.txt)

BaseVehicleID|YearID|MakeID|ModelID

对于第一个文件,我将顶点级别创建为年份,将键创建为 YearID,第二个我将顶点级别创建为 BaseVehicle,而键创建为 BaseVehicleID,并忽略 YearID、MakeID、ModelID。现在我想使用边缘级别年份和属性 YearID 在第二(BaseVehicle)和第一(年份)之间创建边缘,但没有什么对我有用。请让我知道我需要改变什么?

4

1 回答 1

0

该文档有示例: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)
于 2016-10-13T18:23:55.550 回答