janusgraph批量导入数据-IBM( janusgraph-utils)的使用

 janusgraph-utils的简介

  

可与JanusGraph一起使用的实用工具,包括:

参考:https://github.com/IBM/janusgraph-utils/blob/master/doc/users_guide.md  

IBM导入工具使用手册

源数据准备(四个文件):

顶点文件,边文件,数据结构文件,数据关系映射文件

要求:

         顶点文件和边文件必须是csv文件

         数据结构文件和数据关系映射文件是json文件

数据结构文件:描述该图中的数据结构

包括:

    propertyKeys包含属性定义的数组。每个属性都在一个对象中定义

 vertexLabels包含顶点定义的数组。每个顶点都在一个对象中定义
 edgeLabels包含边的定义的数组。每个边都在一个对象中定义
 vertexIndexes顶点的索引定义的数组
 edgeIndexes边的索引定义的数组
 vertexCentricIndexes包含以顶点为中心的索引定义的数组。每个以顶点为中心的索引都在一个对象中定义

数据关系映射文件:指定数据文件中的字段和数据结构中的关系

  vertexMap顶点文件的关系映射,
  edgeMap边文件的关系映射

 注:在使用前,需要理解再程序中的datamapping文件和schema文件,编写自己的文件

  

使用步骤:

         注:该工具需要maven编译,所以在外部进行编译,公司内网无法进行编译

         1.在有网的环境下

                   1.1 下载编译

git clone https://github.com/IBM/janusgraph-utils.git

cd janusgraph-utils

mvn package

        1.2 编译完成以后使用

    2. 使用

            这是用的是自带的脚本run.sh进行导入

        2.1 创建文件夹

            mkdir law

        2.2 上传源数据文件到law文件

        2.3 修改run.sh的脚本权限

            chmod 777 run.sh

        2.4 编辑janusgraph的环境变量

            vi /etc/profile

export JANUSGRAPH_HOME=/opt/app/janusgraph-0.3.1-hadoop2
export PATH=$PATH:$JANUSGRAPH_HOME/bin

        2.5 编写运行命令

            示例:run.sh import <janusgraph-config-file> <data-files-directory> <schema.json> <data-mapping.json>

./run.sh import $JANUSGRAPH_HOME/conf/gremlin-server/janusgraph-hbase-es.properties 

/opt/app/janusgraph-utils/law 

/opt/app/janusgraph-utils/law/law_item_schema.json 

/opt/app/janusgraph-utils/law/law_item_datamapper.json
原文地址:https://www.cnblogs.com/learndata/p/10636067.html