Amazon S3 配置¶
本文介绍从 Amazon S3 数据源导入数据的配置项。关于完整配置文件和配置项的信息,请参见数据导入配置。
数据源配置 ¶
下表列出了 Amazon S3 数据源特定的配置项:
| 选项 | 描述 | 类型 | 是否必选 | 默认值 |
|---|---|---|---|---|
type |
数据源的类型。设置为"s3"。 |
String | 是 | 无 |
format |
源数据的文件格式。有效值为"csv"、"json"、"orc"和"parquet"。 |
String | 否 | "csv" |
path |
Amazon S3 中源数据的路径。路径可以指定目录或文件,使用前缀s3a://加上绝对路径。 |
String | 是 | 无 |
endpoint |
Amazon S3 服务器的服务端点。填写格式为s3.<region-code>.amazonaws.com,其中<region-code>为您 AWS 账号的区域代码。更多信息,请参见区域代码。 |
String | 是 | 无 |
accessKey |
访问 Amazon S3 存储桶的 AccessKey。 | String | 是 | 无 |
secretKey |
访问 Amazon S3 存储桶的 SecretKey。 | String | 是 | 无 |
header |
CSV 文件是否包含表头。仅当format设置为"csv"时生效。若 CSV 文件不含表头,在配置 Amazon S3 数据与图元素的映射时,必须使用格式_cX指定列名。例如,_c0表示第一列,_c1表示第二列,以此类推。 |
Bool | 否 | false |
separator |
CSV 文件中使用的分隔符。仅当format设置为"csv"时生效。 |
String | 否 | "," |
通用源配置¶
下列配置项也可以作为全局设置在配置文件的sourcesCommon一节指定:
typeformatheaderseparatorendpointaccessKeysecretKey
请注意,针对特定数据源的配置会覆盖全局设置。
数据源配置示例¶
Amazon S3 源配置
sources: [
{
type:"s3"
format: "csv"
path: "s3a://bucket/path/player.csv"
endpoint: "s3.us-west-2.amazonaws.com"
accessKey: "xxx"
secretKey: "xxxx"
header: true
separator: ","
// nodetypes: []
// edgetypes: []
}
]
完整配置示例¶
将<current-password>替换为登录账号的当前密码。若已修改密码,请使用修改后的密码。
{
taskType: import
nebula: {
graphAddr: "127.0.0.1:9669"
graphName: "movie"
user: "root"
passwd: "<current-password>"
}
error: {
path: "/tmp/errors"
maxRecords: 100
}
checkPoint: {
path: "/tmp/checkpoint"
resume: false
}
sourcesCommon:{
type:"s3"
format: "csv"
endpoint: "s3.us-west-2.amazonaws.com"
accessKey: "xxx"
secretKey: "xxxx"
header: true
separator: ","
}
writeCommon:{
batchSize: 2000
enableRealTimeQPSLog: true
mode: "INSERT IGNORE"
}
sources: [
# node type Actor
{
path: "s3a://nebula-data-trans-test-us-west-2/import_movie/sub_actor.csv"
pre_processes: {
filter: ["birth_date!='\\N'"]
concatConstant: [
{
field: "name"
prefixValue: "test_"
suffixValue: ""
}
]
}
nodetypes: [
{
name: "Actor"
sourceFields: [people_id,name,birth_date]
nebulaFields: [id,name,birthDate]
}
]
}
# node type Movie
{
path: "s3a://nebula-data-trans-test-us-west-2/import_movie/sub_movie.csv"
nodetypes: [
{
name: "Movie"
sourceFields: [movie_id,name]
nebulaFields: [id,name]
}
]
}
# edge type Act
{
path: "s3a://nebula-data-trans-test-us-west-2/import_movie/sub_actor_act_movie.csv"
edgetypes: [
{
name: "Act"
sourceKeys: [people_id]
targetKeys: [movie_id]
sourceFields: []
nebulaFields: []
}
]
}
]
}