blob: 70ff7261a69e7e7bec7851ff4a9522d26f1ffe6d [file] [log] [blame]
<!doctype html><html lang=cn class=no-js><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name=generator content="Hugo 0.102.3"><link rel=canonical type=text/html href=/cn/docs/quickstart/><link rel=alternate type=application/rss+xml href=/cn/docs/quickstart/index.xml><meta name=robots content="noindex, nofollow"><link rel="shortcut icon" href=/favicons/favicon.ico><link rel=apple-touch-icon href=/favicons/apple-touch-icon-180x180.png sizes=180x180><link rel=icon type=image/png href=/favicons/favicon-16x16.png sizes=16x16><link rel=icon type=image/png href=/favicons/favicon-32x32.png sizes=32x32><link rel=icon type=image/png href=/favicons/android-36x36.png sizes=36x36><link rel=icon type=image/png href=/favicons/android-48x48.png sizes=48x48><link rel=icon type=image/png href=/favicons/android-72x72.png sizes=72x72><link rel=icon type=image/png href=/favicons/android-96x96.png sizes=96x96><link rel=icon type=image/png href=/favicons/android-144x144.png sizes=144x144><link rel=icon type=image/png href=/favicons/android-192x192.png sizes=192x192><title>Quick Start | HugeGraph</title><meta name=description content><meta property="og:title" content="Quick Start"><meta property="og:description" content="Apache HugeGraph 官网"><meta property="og:type" content="website"><meta property="og:url" content="/cn/docs/quickstart/"><meta property="og:site_name" content="HugeGraph"><meta itemprop=name content="Quick Start"><meta itemprop=description content="Apache HugeGraph 官网"><meta name=twitter:card content="summary"><meta name=twitter:title content="Quick Start"><meta name=twitter:description content="Apache HugeGraph 官网"><link rel=preload href=/scss/main.min.14ea575cb35d93d46ff8681b2334f40fd46243c100c5c39f5a841b931fae2d40.css as=style><link href=/scss/main.min.14ea575cb35d93d46ff8681b2334f40fd46243c100c5c39f5a841b931fae2d40.css rel=stylesheet integrity><script src=https://code.jquery.com/jquery-3.5.1.min.js integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin=anonymous></script>
<link rel=stylesheet href=/css/prism.css><script type=application/javascript>var doNotTrack=!1;doNotTrack||(window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)},ga.l=+new Date,ga("create","UA-00000000-0","auto"),ga("send","pageview"))</script><script async src=https://www.google-analytics.com/analytics.js></script></head><body class=td-section><header><nav class="js-navbar-scroll navbar navbar-expand navbar-dark flex-column flex-md-row td-navbar"><a class=navbar-brand href=/cn/><span class=navbar-logo><svg id="图层_1" data-name="图层 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 16 16"><defs><style>.cls-1{fill:none;stroke:#fff;stroke-miterlimit:10;stroke-width:.5px;opacity:.3}.cls-2{fill:#229efa}.cls-3{fill:#9948f7}.cls-4{fill:#33bc7a}.cls-5{fill:url(#未命名的渐变_3)}.cls-6{fill:url(#未命名的渐变_13)}.cls-7{fill:url(#未命名的渐变_11)}</style><linearGradient id="未命名的渐变_3" x1="6.16" y1="14.63" x2="6.16" y2="6.01" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#2e3192"/><stop offset="0" stop-color="#229efa"/><stop offset=".44" stop-color="#239cf8"/><stop offset=".6" stop-color="#2795f2"/><stop offset=".71" stop-color="#2d8ae8"/><stop offset=".81" stop-color="#3679d9"/><stop offset=".89" stop-color="#4263c6"/><stop offset=".95" stop-color="#5048af"/><stop offset="1" stop-color="#5c319b"/></linearGradient><linearGradient id="未命名的渐变_13" x1="10.75" y1="8.2" x2="4.49" y2="1.94" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#991146"/><stop offset="0" stop-color="#326b4e"/><stop offset=".02" stop-color="#3a685c"/><stop offset=".07" stop-color="#506180"/><stop offset=".13" stop-color="#645aa0"/><stop offset=".19" stop-color="#7554bc"/><stop offset=".26" stop-color="#8250d2"/><stop offset=".35" stop-color="#8d4ce3"/><stop offset=".45" stop-color="#944aee"/><stop offset=".6" stop-color="#9848f5"/><stop offset="1" stop-color="#9948f7"/></linearGradient><linearGradient id="未命名的渐变_11" x1="15.34" y1="6.67" x2="7.88" y2="10.98" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#33bc7a"/><stop offset=".45" stop-color="#32ba7a"/><stop offset=".61" stop-color="#2fb37c"/><stop offset=".73" stop-color="#29a87e"/><stop offset=".82" stop-color="#219782"/><stop offset=".9" stop-color="#168186"/><stop offset=".97" stop-color="#09668b"/><stop offset="1" stop-color="#03598e"/></linearGradient></defs><title>logo</title><rect class="cls-1" x="-143.14" y="-373.46" width="597.8" height="424.44"/><circle class="cls-2" cx="12.02" cy="1.83" r="1.33"/><circle class="cls-3" cx="12.02" cy="14.17" r="1.33"/><circle class="cls-4" cx="1.33" cy="8" r="1.33"/><path class="cls-5" d="M7.91 10h0a2.65 2.65.0 01-.23-3.74A1.75 1.75.0 017.91 6h0A2.66 2.66.0 014.4 6h0a1.81 1.81.0 01.24.24A2.65 2.65.0 014.4 10h0a2.62 2.62.0 00-.89 2 2.65 2.65.0 104.4-2z"/><path class="cls-6" d="M12.19 5.49a2.78 2.78.0 01-.5.11A2.64 2.64.0 018.76 3.5h0a2.65 2.65.0 10-2.6 3.17A2.6 2.6.0 007 6.53H7a2.65 2.65.0 013.44 2 2.94 2.94.0 010-.51 2.65 2.65.0 011.75-2.53z"/><path class="cls-7" d="M13 5.35a2.64 2.64.0 00-2.59 2.12h0a3 3 0 01-.08.32A2.65 2.65.0 017.54 9.58a2.86 2.86.0 00.37.41h0a2.63 2.63.0 01.9 2 2.84 2.84.0 01-.05.51 2.64 2.64.0 013.12-2.06l.32.08h0a2.6 2.6.0 00.84.14 2.65 2.65.0 100-5.3z"/></svg></span><span class=font-weight-bold>HugeGraph</span></a><div class="td-navbar-nav-scroll ml-md-auto" id=main_navbar><ul class="navbar-nav mt-2 mt-lg-0"><li class="nav-item mr-4 mb-2 mb-lg-0"><a class=nav-link href=/cn/docs/><i class='fas fa-book pr-2'></i><span>Documentation</span></a></li><li class="nav-item mr-4 mb-2 mb-lg-0"><a class=nav-link href=https://github.com/apache/incubator-hugegraph target=_blank><i class='fab fa-github pr-2'></i><span>GitHub</span></a></li><li class="nav-item mr-4 mb-2 mb-lg-0"><a class=nav-link href=/cn/docs/download/download/><i class='fas fa-download pr-2'></i><span>Download</span></a></li><li class="nav-item mr-4 mb-2 mb-lg-0"><a class=nav-link href=/cn/community/><span>Community</span></a></li><li class="nav-item dropdown mr-4 d-none d-lg-block"><a class="nav-link dropdown-toggle" href=# id=navbarDropdown role=button data-toggle=dropdown aria-haspopup=true aria-expanded=false>中文</a><div class=dropdown-menu aria-labelledby=navbarDropdownMenuLink><a class=dropdown-item href=/docs/quickstart/>English</a></div></li></ul></div><div class="navbar-nav d-none d-lg-block"></div></nav></header><div class="container-fluid td-outer"><div class=td-main><div class="row flex-xl-nowrap"><main class="col-12 col-md-9 col-xl-8 pl-md-5" role=main><div class=td-content><div class="pageinfo pageinfo-primary d-print-none"><p>This is the multi-page printable view of this section.
<a href=# onclick="return print(),!1">Click here to print</a>.</p><p><a href=/cn/docs/quickstart/>Return to the regular view of this page</a>.</p></div><h1 class=title>Quick Start</h1><ul><li>1: <a href=#pg-8ec2ee5fd8ff8e48255d55eab65d92b6>HugeGraph-Server Quick Start</a></li><li>2: <a href=#pg-685a02f8811d86f1ce195d7c73d9ea44>HugeGraph-Loader Quick Start</a></li><li>3: <a href=#pg-751ed124ec6dbb96d5e65c62dc9d4e85>HugeGraph-Hubble Quick Start</a></li><li>4: <a href=#pg-405910066a042ce44a1c5798042ab119>HugeGraph-AI Quick Start</a></li><li>5: <a href=#pg-9cbf1b01e876dc8cdc2da1c17759eed3>HugeGraph-Client Quick Start</a></li><li>6: <a href=#pg-06d4cae527789fcda01ebf4e48c6559f>HugeGraph-Tools Quick Start</a></li><li>7: <a href=#pg-e68a801476ae8ef5e45c79949a3a5e44>HugeGraph-Computer Quick Start</a></li></ul><div class=content></div></div><div class=td-content><h1 id=pg-8ec2ee5fd8ff8e48255d55eab65d92b6>1 - HugeGraph-Server Quick Start</h1><h3 id=1-hugegraph-server-概述>1 HugeGraph-Server 概述</h3><p>HugeGraph-Server 是 HugeGraph 项目的核心部分,包含 Core、Backend、API 等子模块。</p><p>Core 模块是 Tinkerpop 接口的实现,Backend 模块用于管理数据存储,目前支持的后端包括:Memory、Cassandra、ScyllaDB 以及 RocksDB,API 模块提供 HTTP Server,将 Client 的 HTTP 请求转化为对 Core 的调用。</p><blockquote><p>文档中会出现 <code>HugeGraph-Server</code><code>HugeGraphServer</code> 这两种写法,其他组件也类似。
这两种写法含义上并明显差异,可以这么区分:<code>HugeGraph-Server</code> 表示服务端相关组件代码,<code>HugeGraphServer</code> 表示服务进程。</p></blockquote><h3 id=2-依赖>2 依赖</h3><h4 id=21-安装-java-11-jdk-11>2.1 安装 Java 11 (JDK 11)</h4><p>请优先考虑在 Java 11 的环境上启动 <code>HugeGraph-Server</code>(在 1.5.0 版前,会保留对 Java 8 的基本兼容)</p><p><strong>在往下阅读之前先执行 <code>java -version</code> 命令确认 jdk 版本</strong></p><blockquote><p>注:使用 Java 8 启动 HugeGraph-Server 会失去一些<strong>安全性</strong>的保障,也会降低性能相关指标</p><p>我们推荐生产或对外网暴露访问的环境使用 Java 11 并考虑开启 <a href=/cn/docs/config/config-authentication/>Auth 权限认证</a></p></blockquote><h3 id=3-部署>3 部署</h3><p>有四种方式可以部署 HugeGraph-Server 组件:</p><ul><li>方式 1:使用 Docker 容器 (便于<strong>测试</strong>)</li><li>方式 2:下载 tar 包</li><li>方式 3:源码编译</li><li>方式 4:使用 tools 工具部署 (Outdated)</li></ul><h4 id=31-使用-docker-容器-便于测试>3.1 使用 Docker 容器 (便于<strong>测试</strong>)</h4><p>可参考 <a href=https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-dist/docker/README.md>Docker 部署方式</a></p><p>我们可以使用 <code>docker run -itd --name=server -p 8080:8080 hugegraph/hugegraph</code> 去快速启动一个内置了 <code>RocksDB</code><code>Hugegraph server</code>.</p><p>可选项:</p><ol><li>可以使用 <code>docker exec -it server bash</code> 进入容器完成一些操作</li><li>可以使用 <code>docker run -itd --name=server -p 8080:8080 -e PRELOAD="true" hugegraph/hugegraph</code> 在启动的时候预加载一个<strong>内置的</strong>样例图。可以通过 <code>RESTful API</code> 进行验证。具体步骤可以参考 <a href=/cn/docs/quickstart/hugegraph-server/#511-%E5%90%AF%E5%8A%A8-server-%E7%9A%84%E6%97%B6%E5%80%99%E5%88%9B%E5%BB%BA%E7%A4%BA%E4%BE%8B%E5%9B%BE>5.1.1</a></li><li>可以使用 <code>-e PASSWORD=123456</code> 设置是否开启鉴权模式以及 admin 的密码,具体步骤可以参考 <a href=/cn/docs/config/config-authentication#%E4%BD%BF%E7%94%A8-docker-%E6%97%B6%E5%BC%80%E5%90%AF%E9%89%B4%E6%9D%83%E6%A8%A1%E5%BC%8F>Config Authentication</a></li></ol><p>如果使用 docker desktop,则可以按照如下的方式设置可选项:</p><div style=text-align:center><img src=/docs/images/images-server/31docker-option.jpg alt=image style=width:33%></div><p>另外,如果我们希望能够在一个文件中管理除了 <code>server</code> 之外的其他 Hugegraph 相关的实例,我们也可以使用 <code>docker-compose</code>完成部署,使用命令 <code>docker-compose up -d</code>,(当然只配置 <code>server</code> 也是可以的)以下是一个样例的 <code>docker-compose.yml</code>:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-yaml data-lang=yaml><span style=display:flex><span><span style=color:#204a87;font-weight:700>version</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#39;3&#39;</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#204a87;font-weight:700>services</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>server</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>image</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph/hugegraph</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>container_name</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>server</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic># environment:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic># - PRELOAD=true 为可选参数,为 True 时可以在启动的时候预加载一个内置的样例图</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic># - PASSWORD=123456 为可选参数,设置的时候可以开启鉴权模式,并设置密码</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>ports</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#0000cf;font-weight:700>8080</span><span style=color:#000;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>8080</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span></code></pre></div><blockquote><p>注意:</p><ol><li><p>hugegraph 的 docker 镜像是一个便捷版本,用于快速启动 hugegraph,并不是<strong>官方发布物料包方式</strong>。你可以从 <a href=https://infra.apache.org/release-distribution.html#dockerhub>ASF Release Distribution Policy</a> 中得到更多细节。</p></li><li><p>推荐使用 <code>release tag</code>(如 <code>1.3.0</code>) 以获取稳定版。使用 <code>latest</code> tag 可以使用开发中的最新功能。</p></li></ol></blockquote><h4 id=32-下载-tar-包>3.2 下载 tar 包</h4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#8f5902;font-style:italic># use the latest version, here is 1.3.0 for example</span>
</span></span><span style=display:flex><span>wget https://downloads.apache.org/incubator/hugegraph/<span style=color:#ce5c00;font-weight:700>{</span>version<span style=color:#ce5c00;font-weight:700>}</span>/apache-hugegraph-incubating-<span style=color:#ce5c00;font-weight:700>{</span>version<span style=color:#ce5c00;font-weight:700>}</span>.tar.gz
</span></span><span style=display:flex><span>tar zxf *hugegraph*.tar.gz
</span></span></code></pre></div><h4 id=33-源码编译>3.3 源码编译</h4><p>源码编译前请确保本机有安装 <code>wget/curl</code> 命令</p><p>下载 HugeGraph 源代码</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>git clone https://github.com/apache/hugegraph.git
</span></span></code></pre></div><p>编译打包生成 tar 包</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#204a87>cd</span> hugegraph
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># (Optional) use &#34;-P stage&#34; param if you build failed with the latest code(during pre-release period)</span>
</span></span><span style=display:flex><span>mvn package -DskipTests
</span></span></code></pre></div><p>执行日志如下:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>......
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> Reactor Summary <span style=color:#204a87;font-weight:700>for</span> hugegraph 1.3.0:
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph .......................................... SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 2.405 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-core ..................................... SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 13.405 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-api ...................................... SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 25.943 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-cassandra ................................ SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 54.270 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-scylladb ................................. SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 1.032 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-rocksdb .................................. SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 34.752 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-mysql .................................... SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 1.778 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-palo ..................................... SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 1.070 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-hbase .................................... SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 32.124 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-postgresql ............................... SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 1.823 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-dist ..................................... SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 17.426 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-example .................................. SUCCESS <span style=color:#ce5c00;font-weight:700>[</span> 1.941 s<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> hugegraph-test ..................................... SUCCESS <span style=color:#ce5c00;font-weight:700>[</span>01:01 min<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> ------------------------------------------------------------------------
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> BUILD SUCCESS
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>[</span>INFO<span style=color:#ce5c00;font-weight:700>]</span> ------------------------------------------------------------------------
</span></span><span style=display:flex><span>......
</span></span></code></pre></div><p>执行成功后,在 hugegraph 目录下生成 <code>*hugegraph-*.tar.gz</code> 文件,就是编译生成的 tar 包。</p><h4 id=34-使用-tools-工具部署-outdated>3.4 使用 tools 工具部署 (Outdated)</h4><p>HugeGraph-Tools 提供了一键部署的命令行工具,用户可以使用该工具快速地一键下载、解压、配置并启动 HugeGraph-Server 和 HugeGraph-Hubble,最新的 HugeGraph-Toolchain 中已经包含所有的这些工具,直接下载它解压就有工具包集合了</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#8f5902;font-style:italic># download toolchain package, it includes loader + tool + hubble, please check the latest version (here is 1.3.0)</span>
</span></span><span style=display:flex><span>wget https://downloads.apache.org/incubator/hugegraph/1.3.0/apache-hugegraph-toolchain-incubating-1.3.0.tar.gz
</span></span><span style=display:flex><span>tar zxf *hugegraph-*.tar.gz
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># enter the tool&#39;s package</span>
</span></span><span style=display:flex><span><span style=color:#204a87>cd</span> *hugegraph*/*tool*
</span></span></code></pre></div><blockquote><p>注:<code>${version}</code> 为版本号,最新版本号可参考 <a href=/docs/download/download>Download 页面</a>,或直接从 Download 页面点击链接下载</p></blockquote><p>HugeGraph-Tools 的总入口脚本是 <code>bin/hugegraph</code>,用户可以使用 <code>help</code> 子命令查看其用法,这里只介绍一键部署的命令。</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/hugegraph deploy -v <span style=color:#ce5c00;font-weight:700>{</span>hugegraph-version<span style=color:#ce5c00;font-weight:700>}</span> -p <span style=color:#ce5c00;font-weight:700>{</span>install-path<span style=color:#ce5c00;font-weight:700>}</span> <span style=color:#ce5c00;font-weight:700>[</span>-u <span style=color:#ce5c00;font-weight:700>{</span>download-path-prefix<span style=color:#ce5c00;font-weight:700>}]</span>
</span></span></code></pre></div><p><code>{hugegraph-version}</code> 表示要部署的 HugeGraphServer 及 HugeGraphStudio 的版本,用户可查看 <code>conf/version-mapping.yaml</code> 文件获取版本信息,<code>{install-path}</code> 指定 HugeGraphServer 及 HugeGraphStudio 的安装目录,<code>{download-path-prefix}</code> 可选,指定 HugeGraphServer 及 HugeGraphStudio tar 包的下载地址,不提供时使用默认下载地址,比如要启动 0.6 版本的 HugeGraph-Server 及 HugeGraphStudio 将上述命令写为 <code>bin/hugegraph deploy -v 0.6 -p services</code> 即可。</p><h3 id=4-配置>4 配置</h3><p>如果需要快速启动 HugeGraph 仅用于测试,那么只需要进行少数几个配置项的修改即可(见下一节)。</p><p>详细的配置介绍请参考<a href=/docs/config/config-guide>配置文档</a><a href=/docs/config/config-option>配置项介绍</a></p><h3 id=5-启动>5 启动</h3><h4 id=51-使用启动脚本启动>5.1 使用启动脚本启动</h4><p>启动分为"首次启动"和"非首次启动",这么区分是因为在第一次启动前需要初始化后端数据库,然后启动服务。</p><p>而在人为停掉服务后,或者其他原因需要再次启动服务时,因为后端数据库是持久化存在的,直接启动服务即可。</p><p>HugeGraphServer 启动时会连接后端存储并尝试检查后端存储版本号,如果未初始化后端或者后端已初始化但版本不匹配时(旧版本数据),HugeGraphServer 会启动失败,并给出错误信息。</p><p>如果需要外部访问 HugeGraphServer,请修改 <code>rest-server.properties</code><code>restserver.url</code> 配置项(默认为 <code>http://127.0.0.1:8080</code>),修改成机器名或 IP 地址。</p><p>由于各种后端所需的配置(hugegraph.properties)及启动步骤略有不同,下面逐一对各后端的配置及启动做介绍。</p><p>如果想要使用 HugeGraph 鉴权模式,在后面正式启动 Server 之前应按照 <a href=https://hugegraph.apache.org/cn/docs/config/config-authentication/>Server 鉴权配置</a> 进行配置。</p><h5 id=511-rocksdb>5.1.1 RocksDB</h5><details><summary>点击展开/折叠 RocksDB 配置及启动方法</summary><blockquote><p>RocksDB 是一个嵌入式的数据库,不需要手动安装部署,要求 GCC 版本 >= 4.3.0(GLIBCXX_3.4.10),如不满足,需要提前升级 GCC</p></blockquote><p>修改 <code>hugegraph.properties</code></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>backend=rocksdb
</span></span><span style=display:flex><span>serializer=binary
</span></span><span style=display:flex><span>rocksdb.data_path=.
</span></span><span style=display:flex><span>rocksdb.wal_path=.
</span></span></code></pre></div><p>初始化数据库(第一次启动时或在 <code>conf/graphs/</code> 下手动添加了新配置时需要进行初始化)</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#204a87>cd</span> *hugegraph-<span style=color:#4e9a06>${</span><span style=color:#000>version</span><span style=color:#4e9a06>}</span>
</span></span><span style=display:flex><span>bin/init-store.sh
</span></span></code></pre></div><p>启动 server</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/start-hugegraph.sh
</span></span><span style=display:flex><span>Starting HugeGraphServer...
</span></span><span style=display:flex><span>Connecting to HugeGraphServer <span style=color:#ce5c00;font-weight:700>(</span>http://127.0.0.1:8080/graphs<span style=color:#ce5c00;font-weight:700>)</span>....OK
</span></span></code></pre></div><p>提示的 url 与 <code>rest-server.properties</code> 中配置的 <code>restserver.url</code> 一致</p></details><h5 id=512-hbase>5.1.2 HBase</h5><details><summary>点击展开/折叠 HBase 配置及启动方法</summary><blockquote><p>用户需自行安装 HBase,要求版本 2.0 以上,<a href=https://hbase.apache.org/downloads.html>下载地址</a></p></blockquote><p>修改 hugegraph.properties</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>backend=hbase
</span></span><span style=display:flex><span>serializer=hbase
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span># hbase backend config
</span></span><span style=display:flex><span>hbase.hosts=localhost
</span></span><span style=display:flex><span>hbase.port=2181
</span></span><span style=display:flex><span># Note: recommend to modify the HBase partition number by the actual/env data amount &amp; RS amount before init store
</span></span><span style=display:flex><span># it may influence the loading speed a lot
</span></span><span style=display:flex><span>#hbase.enable_partition=true
</span></span><span style=display:flex><span>#hbase.vertex_partitions=10
</span></span><span style=display:flex><span>#hbase.edge_partitions=30
</span></span></code></pre></div><p>初始化数据库(第一次启动时或在 <code>conf/graphs/</code> 下手动添加了新配置时需要进行初始化)</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#204a87>cd</span> *hugegraph-<span style=color:#4e9a06>${</span><span style=color:#000>version</span><span style=color:#4e9a06>}</span>
</span></span><span style=display:flex><span>bin/init-store.sh
</span></span></code></pre></div><p>启动 server</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/start-hugegraph.sh
</span></span><span style=display:flex><span>Starting HugeGraphServer...
</span></span><span style=display:flex><span>Connecting to HugeGraphServer <span style=color:#ce5c00;font-weight:700>(</span>http://127.0.0.1:8080/graphs<span style=color:#ce5c00;font-weight:700>)</span>....OK
</span></span></code></pre></div><blockquote><p>更多其它后端配置可参考<a href=/docs/config/config-option>配置项介绍</a></p></blockquote></details><h5 id=513-mysql>5.1.3 MySQL</h5><details><summary>点击展开/折叠 MySQL 配置及启动方法</summary><blockquote><p>由于 MySQL 是在 GPL 协议下,与 Apache 协议不兼容,用户需自行安装 MySQL,<a href=https://dev.mysql.com/downloads/mysql/>下载地址</a></p></blockquote><p>下载 MySQL 的<a href=https://repo1.maven.org/maven2/mysql/mysql-connector-java/>驱动包</a>,比如 <code>mysql-connector-java-8.0.30.jar</code>,并放入 HugeGraph-Server 的 <code>lib</code> 目录下。</p><p>修改 <code>hugegraph.properties</code>,配置数据库 URL,用户名和密码,<code>store</code> 是数据库名,如果没有会被自动创建。</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>backend=mysql
</span></span><span style=display:flex><span>serializer=mysql
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>store=hugegraph
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span># mysql backend config
</span></span><span style=display:flex><span>jdbc.driver=com.mysql.cj.jdbc.Driver
</span></span><span style=display:flex><span>jdbc.url=jdbc:mysql://127.0.0.1:3306
</span></span><span style=display:flex><span>jdbc.username=
</span></span><span style=display:flex><span>jdbc.password=
</span></span><span style=display:flex><span>jdbc.reconnect_max_times=3
</span></span><span style=display:flex><span>jdbc.reconnect_interval=3
</span></span><span style=display:flex><span>jdbc.ssl_mode=false
</span></span></code></pre></div><p>初始化数据库(第一次启动时或在 <code>conf/graphs/</code> 下手动添加了新配置时需要进行初始化)</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#204a87>cd</span> *hugegraph-<span style=color:#4e9a06>${</span><span style=color:#000>version</span><span style=color:#4e9a06>}</span>
</span></span><span style=display:flex><span>bin/init-store.sh
</span></span></code></pre></div><p>启动 server</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/start-hugegraph.sh
</span></span><span style=display:flex><span>Starting HugeGraphServer...
</span></span><span style=display:flex><span>Connecting to HugeGraphServer <span style=color:#ce5c00;font-weight:700>(</span>http://127.0.0.1:8080/graphs<span style=color:#ce5c00;font-weight:700>)</span>....OK
</span></span></code></pre></div></details><h5 id=514-cassandra>5.1.4 Cassandra</h5><details><summary>点击展开/折叠 Cassandra 配置及启动方法</summary><blockquote><p>用户需自行安装 Cassandra,要求版本 3.0 以上,<a href=http://cassandra.apache.org/download/>下载地址</a></p></blockquote><p>修改 hugegraph.properties</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>backend=cassandra
</span></span><span style=display:flex><span>serializer=cassandra
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span># cassandra backend config
</span></span><span style=display:flex><span>cassandra.host=localhost
</span></span><span style=display:flex><span>cassandra.port=9042
</span></span><span style=display:flex><span>cassandra.username=
</span></span><span style=display:flex><span>cassandra.password=
</span></span><span style=display:flex><span>#cassandra.connect_timeout=5
</span></span><span style=display:flex><span>#cassandra.read_timeout=20
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>#cassandra.keyspace.strategy=SimpleStrategy
</span></span><span style=display:flex><span>#cassandra.keyspace.replication=3
</span></span></code></pre></div><p>初始化数据库(第一次启动时或在 <code>conf/graphs/</code> 下手动添加了新配置时需要进行初始化)</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#204a87>cd</span> *hugegraph-<span style=color:#4e9a06>${</span><span style=color:#000>version</span><span style=color:#4e9a06>}</span>
</span></span><span style=display:flex><span>bin/init-store.sh
</span></span><span style=display:flex><span>Initing HugeGraph Store...
</span></span><span style=display:flex><span>2017-12-01 11:26:51 <span style=color:#0000cf;font-weight:700>1424</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.HugeGraph <span style=color:#ce5c00;font-weight:700>[]</span> - Opening backend store: <span style=color:#4e9a06>&#39;cassandra&#39;</span>
</span></span><span style=display:flex><span>2017-12-01 11:26:52 <span style=color:#0000cf;font-weight:700>2389</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Failed to connect keyspace: hugegraph, try init keyspace later
</span></span><span style=display:flex><span>2017-12-01 11:26:52 <span style=color:#0000cf;font-weight:700>2472</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Failed to connect keyspace: hugegraph, try init keyspace later
</span></span><span style=display:flex><span>2017-12-01 11:26:52 <span style=color:#0000cf;font-weight:700>2557</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Failed to connect keyspace: hugegraph, try init keyspace later
</span></span><span style=display:flex><span>2017-12-01 11:26:53 <span style=color:#0000cf;font-weight:700>2797</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Store initialized: huge_graph
</span></span><span style=display:flex><span>2017-12-01 11:26:53 <span style=color:#0000cf;font-weight:700>2945</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Store initialized: huge_schema
</span></span><span style=display:flex><span>2017-12-01 11:26:53 <span style=color:#0000cf;font-weight:700>3044</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Store initialized: huge_index
</span></span><span style=display:flex><span>2017-12-01 11:26:53 <span style=color:#0000cf;font-weight:700>3046</span> <span style=color:#ce5c00;font-weight:700>[</span>pool-3-thread-1<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.Transaction <span style=color:#ce5c00;font-weight:700>[]</span> - Clear cache on event <span style=color:#4e9a06>&#39;store.init&#39;</span>
</span></span><span style=display:flex><span>2017-12-01 11:26:59 <span style=color:#0000cf;font-weight:700>9720</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.HugeGraph <span style=color:#ce5c00;font-weight:700>[]</span> - Opening backend store: <span style=color:#4e9a06>&#39;cassandra&#39;</span>
</span></span><span style=display:flex><span>2017-12-01 11:27:00 <span style=color:#0000cf;font-weight:700>9805</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Failed to connect keyspace: hugegraph1, try init keyspace later
</span></span><span style=display:flex><span>2017-12-01 11:27:00 <span style=color:#0000cf;font-weight:700>9886</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Failed to connect keyspace: hugegraph1, try init keyspace later
</span></span><span style=display:flex><span>2017-12-01 11:27:00 <span style=color:#0000cf;font-weight:700>9955</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Failed to connect keyspace: hugegraph1, try init keyspace later
</span></span><span style=display:flex><span>2017-12-01 11:27:00 <span style=color:#0000cf;font-weight:700>10175</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Store initialized: huge_graph
</span></span><span style=display:flex><span>2017-12-01 11:27:00 <span style=color:#0000cf;font-weight:700>10321</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Store initialized: huge_schema
</span></span><span style=display:flex><span>2017-12-01 11:27:00 <span style=color:#0000cf;font-weight:700>10413</span> <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.store.cassandra.CassandraStore <span style=color:#ce5c00;font-weight:700>[]</span> - Store initialized: huge_index
</span></span><span style=display:flex><span>2017-12-01 11:27:00 <span style=color:#0000cf;font-weight:700>10413</span> <span style=color:#ce5c00;font-weight:700>[</span>pool-3-thread-1<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> org.apache.hugegraph.backend.Transaction <span style=color:#ce5c00;font-weight:700>[]</span> - Clear cache on event <span style=color:#4e9a06>&#39;store.init&#39;</span>
</span></span></code></pre></div><p>启动 server</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/start-hugegraph.sh
</span></span><span style=display:flex><span>Starting HugeGraphServer...
</span></span><span style=display:flex><span>Connecting to HugeGraphServer <span style=color:#ce5c00;font-weight:700>(</span>http://127.0.0.1:8080/graphs<span style=color:#ce5c00;font-weight:700>)</span>....OK
</span></span></code></pre></div></details><h5 id=515-memory>5.1.5 Memory</h5><details><summary>点击展开/折叠 Memory 配置及启动方法</summary><p>修改 hugegraph.properties</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>backend=memory
</span></span><span style=display:flex><span>serializer=text
</span></span></code></pre></div><blockquote><p>Memory 后端的数据是保存在内存中无法持久化的,不需要初始化后端,这也是唯一一个不需要初始化的后端。</p></blockquote><p>启动 server</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/start-hugegraph.sh
</span></span><span style=display:flex><span>Starting HugeGraphServer...
</span></span><span style=display:flex><span>Connecting to HugeGraphServer <span style=color:#ce5c00;font-weight:700>(</span>http://127.0.0.1:8080/graphs<span style=color:#ce5c00;font-weight:700>)</span>....OK
</span></span></code></pre></div><p>提示的 url 与 rest-server.properties 中配置的 restserver.url 一致</p></details><h5 id=516-scylladb>5.1.6 ScyllaDB</h5><details><summary>点击展开/折叠 ScyllaDB 配置及启动方法</summary><blockquote><p>用户需自行安装 ScyllaDB,推荐版本 2.1 以上,<a href=https://docs.scylladb.com/getting-started/>下载地址</a></p></blockquote><p>修改 hugegraph.properties</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>backend=scylladb
</span></span><span style=display:flex><span>serializer=scylladb
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span># cassandra backend config
</span></span><span style=display:flex><span>cassandra.host=localhost
</span></span><span style=display:flex><span>cassandra.port=9042
</span></span><span style=display:flex><span>cassandra.username=
</span></span><span style=display:flex><span>cassandra.password=
</span></span><span style=display:flex><span>#cassandra.connect_timeout=5
</span></span><span style=display:flex><span>#cassandra.read_timeout=20
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>#cassandra.keyspace.strategy=SimpleStrategy
</span></span><span style=display:flex><span>#cassandra.keyspace.replication=3
</span></span></code></pre></div><p>由于 scylladb 数据库本身就是基于 cassandra 的"优化版",如果用户未安装 scylladb,也可以直接使用 cassandra 作为后端存储,只需要把 backend 和 serializer 修改为 scylladb,host 和 post 指向 cassandra 集群的 seeds 和 port 即可,但是并不建议这样做,这样发挥不出 scylladb 本身的优势了。</p><p>初始化数据库(第一次启动时或在 <code>conf/graphs/</code> 下手动添加了新配置时需要进行初始化)</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#204a87>cd</span> *hugegraph-<span style=color:#4e9a06>${</span><span style=color:#000>version</span><span style=color:#4e9a06>}</span>
</span></span><span style=display:flex><span>bin/init-store.sh
</span></span></code></pre></div><p>启动 server</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/start-hugegraph.sh
</span></span><span style=display:flex><span>Starting HugeGraphServer...
</span></span><span style=display:flex><span>Connecting to HugeGraphServer <span style=color:#ce5c00;font-weight:700>(</span>http://127.0.0.1:8080/graphs<span style=color:#ce5c00;font-weight:700>)</span>....OK
</span></span></code></pre></div></details><h5 id=517-启动-server-的时候创建示例图>5.1.7 启动 server 的时候创建示例图</h5><p>在脚本启动时候携带 <code>-p true</code>参数,表示 preload, 即创建示例图图</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>bin/start-hugegraph.sh -p true
</span></span><span style=display:flex><span>Starting HugeGraphServer in daemon mode...
</span></span><span style=display:flex><span>Connecting to HugeGraphServer (http://127.0.0.1:8080/graphs)......OK
</span></span></code></pre></div><p>并且使用 RESTful API 请求 <code>HugeGraphServer</code> 得到如下结果:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-javascript data-lang=javascript><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>&gt;</span> <span style=color:#000>curl</span> <span style=color:#4e9a06>&#34;http://localhost:8080/graphs/hugegraph/graph/vertices&#34;</span> <span style=color:#ce5c00;font-weight:700>|</span> <span style=color:#000>gunzip</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;vertices&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>[{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;2:lop&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;lop&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;java&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>328</span><span style=color:#000;font-weight:700>}},{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;1:josh&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;josh&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>32</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;Beijing&#34;</span><span style=color:#000;font-weight:700>}},{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;1:marko&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;marko&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>29</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;Beijing&#34;</span><span style=color:#000;font-weight:700>}},{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;1:peter&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;peter&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>35</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;Shanghai&#34;</span><span style=color:#000;font-weight:700>}},{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;1:vadas&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vadas&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>27</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;Hongkong&#34;</span><span style=color:#000;font-weight:700>}},{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;2:ripple&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;ripple&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;java&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>199</span><span style=color:#000;font-weight:700>}}]}</span>
</span></span></code></pre></div><p>代表创建示例图成功。</p><h4 id=52-使用-docker>5.2 使用 Docker</h4><p><a href=#33-%E4%BD%BF%E7%94%A8-docker-%E5%AE%B9%E5%99%A8>3.3 使用 Docker 容器</a>中,我们已经介绍了如何使用 <code>docker</code> 部署 <code>hugegraph-server</code>, 我们还可以使用其他的后端存储或者设置参数在 sever 启动的时候加载样例图</p><h5 id=521-使用-cassandra-作为后端>5.2.1 使用 Cassandra 作为后端</h5><details><summary>点击展开/折叠 Cassandra 配置及启动方法</summary><p>在使用 Docker 的时候,我们可以使用 Cassandra 作为后端存储。我们更加推荐直接使用 docker-compose 来对于 server 以及 Cassandra 进行统一管理</p><p>样例的 <code>docker-compose.yml</code> 可以在 <a href=https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-dist/docker/example/docker-compose-cassandra.yml>github</a> 中获取,使用 <code>docker-compose up -d</code> 启动。(如果使用 cassandra 4.0 版本作为后端存储,则需要大约两个分钟初始化,请耐心等待)</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-yaml data-lang=yaml><span style=display:flex><span><span style=color:#204a87;font-weight:700>version</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#34;3&#34;</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#204a87;font-weight:700>services</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>server</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>image</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph/hugegraph</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>container_name</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>cas-server</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>ports</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#0000cf;font-weight:700>8080</span><span style=color:#000;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>8080</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>environment</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>hugegraph.backend</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>cassandra</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>hugegraph.serializer</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>cassandra</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>hugegraph.cassandra.host</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>cas-cassandra</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>hugegraph.cassandra.port</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#0000cf;font-weight:700>9042</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>networks</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#000>ca-network</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>depends_on</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#000>cassandra</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>healthcheck</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>test</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;CMD&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#34;bin/gremlin-console.sh&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#34;--&#34;</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;-e&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#34;scripts/remote-connect.groovy&#34;</span><span style=color:#000;font-weight:700>]</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>interval</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>10s</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>timeout</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>30s</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>retries</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#0000cf;font-weight:700>3</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>cassandra</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>image</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>cassandra:4</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>container_name</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>cas-cassandra</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>ports</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#0000cf;font-weight:700>7000</span><span style=color:#000;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>7000</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#0000cf;font-weight:700>9042</span><span style=color:#000;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>9042</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>security_opt</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#000>seccomp:unconfined</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>networks</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#000>ca-network</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>healthcheck</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>test</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;CMD&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#34;cqlsh&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#34;--execute&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#34;describe keyspaces;&#34;</span><span style=color:#000;font-weight:700>]</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>interval</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>10s</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>timeout</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>30s</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>retries</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#0000cf;font-weight:700>5</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#204a87;font-weight:700>networks</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>ca-network</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#204a87;font-weight:700>volumes</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>hugegraph-data</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span></code></pre></div><p>在这个 yaml 中,需要在环境变量中以 <code>hugegraph.&lt;parameter_name></code>的形式进行参数传递,配置 Cassandra 相关的参数。</p><p>具体来说,在 <code>hugegraph.properties</code> 配置文件中,提供了 <code>backend=xxx</code>, <code>cassandra.host=xxx</code> 等配置项,为了配置这些配置项,在传递环境变量的过程之中,我们需要在这些配置项前加上 <code>hugegrpah.</code>,即 <code>hugegraph.backend</code><code>hugegraph.cassandra.host</code></p><p>其他配置可以参照 <a href=#4-%E9%85%8D%E7%BD%AE>4 配置</a></p></details><h5 id=522-启动-server-的时候创建示例图>5.2.2 启动 server 的时候创建示例图</h5><p>在 docker 启动的时候设置环境变量 <code>PRELOAD=true</code>, 从而实现启动脚本的时候加载数据。</p><ol><li><p>使用<code>docker run</code></p><p>使用 <code>docker run -itd --name=server -p 8080:8080 -e PRELOAD=true hugegraph/hugegraph:latest</code></p></li><li><p>使用<code>docker-compose</code></p><p>创建<code>docker-compose.yml</code>,具体文件如下,在环境变量中设置 PRELOAD=true。其中,<a href=https://github.com/apache/incubator-hugegraph/blob/master/hugegraph-server/hugegraph-dist/src/assembly/static/scripts/example.groovy><code>example.groovy</code></a> 是一个预定义的脚本,用于预加载样例数据。如果有需要,可以通过挂载新的 <code>example.groovy</code> 脚本改变预加载的数据。</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-yaml data-lang=yaml><span style=display:flex><span><span style=color:#204a87;font-weight:700>version</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#39;3&#39;</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>services</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>server</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>image</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph/hugegraph:latest</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>container_name</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>server</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>environment</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#000>PRELOAD=true</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>volumes</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#000>/path/to/yourscript:/hugegraph/scripts/example.groovy</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>ports</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#0000cf;font-weight:700>8080</span><span style=color:#000;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>8080</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span></code></pre></div><p>使用命令 <code>docker-compose up -d</code> 启动容器</p></li></ol><p>使用 RESTful API 请求 <code>HugeGraphServer</code> 得到如下结果:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-javascript data-lang=javascript><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>&gt;</span> <span style=color:#000>curl</span> <span style=color:#4e9a06>&#34;http://localhost:8080/graphs/hugegraph/graph/vertices&#34;</span> <span style=color:#ce5c00;font-weight:700>|</span> <span style=color:#000>gunzip</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;vertices&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>[{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;2:lop&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;lop&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;java&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>328</span><span style=color:#000;font-weight:700>}},{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;1:josh&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;josh&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>32</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;Beijing&#34;</span><span style=color:#000;font-weight:700>}},{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;1:marko&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;marko&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>29</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;Beijing&#34;</span><span style=color:#000;font-weight:700>}},{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;1:peter&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;peter&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>35</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;Shanghai&#34;</span><span style=color:#000;font-weight:700>}},{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;1:vadas&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vadas&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>27</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;Hongkong&#34;</span><span style=color:#000;font-weight:700>}},{</span><span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;2:ripple&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;label&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;type&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;properties&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;ripple&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#4e9a06>&#34;java&#34;</span><span style=color:#000;font-weight:700>,</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>199</span><span style=color:#000;font-weight:700>}}]}</span>
</span></span></code></pre></div><p>代表创建示例图成功。</p><h3 id=6-访问-server>6 访问 Server</h3><h4 id=61-服务启动状态校验>6.1 服务启动状态校验</h4><p><code>jps</code> 查看服务进程</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>jps
</span></span><span style=display:flex><span><span style=color:#0000cf;font-weight:700>6475</span> HugeGraphServer
</span></span></code></pre></div><p><code>curl</code> 请求 RESTful API</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#204a87>echo</span> <span style=color:#4e9a06>`</span>curl -o /dev/null -s -w %<span style=color:#ce5c00;font-weight:700>{</span>http_code<span style=color:#ce5c00;font-weight:700>}</span> <span style=color:#4e9a06>&#34;http://localhost:8080/graphs/hugegraph/graph/vertices&#34;</span><span style=color:#4e9a06>`</span>
</span></span></code></pre></div><p>返回结果 200,代表 server 启动正常</p><h4 id=62-请求-server>6.2 请求 Server</h4><p>HugeGraphServer 的 RESTful API 包括多种类型的资源,典型的包括 graph、schema、gremlin、traverser 和 task</p><ul><li><code>graph</code> 包含 <code>vertices</code><code>edges</code></li><li><code>schema</code> 包含 <code>vertexlabels</code><code>propertykeys</code><code>edgelabels</code><code>indexlabels</code></li><li><code>gremlin</code> 包含各种 <code>Gremlin</code> 语句,如 <code>g.v()</code>,可以同步或者异步执行</li><li><code>traverser</code> 包含各种高级查询,包括最短路径、交叉点、N 步可达邻居等</li><li><code>task</code> 包含异步任务的查询和删除</li></ul><h5 id=621-获取-hugegraph-的顶点及相关属性>6.2.1 获取 <code>hugegraph</code> 的顶点及相关属性</h5><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>curl http://localhost:8080/graphs/hugegraph/graph/vertices
</span></span></code></pre></div><p><em>说明</em></p><ol><li><p>由于图的点和边很多,对于 list 型的请求,比如获取所有顶点,获取所有边等,Server 会将数据压缩再返回,所以使用 curl 时得到一堆乱码,可以重定向至 <code>gunzip</code> 进行解压。推荐使用 Chrome 浏览器 + Restlet 插件发送 HTTP 请求进行测试。</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>curl &#34;http://localhost:8080/graphs/hugegraph/graph/vertices&#34; | gunzip
</span></span></code></pre></div></li><li><p>当前 HugeGraphServer 的默认配置只能是本机访问,可以修改配置,使其能在其他机器访问。</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>vim conf/rest-server.properties
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>restserver.url=http://0.0.0.0:8080
</span></span></code></pre></div></li></ol><p>响应体如下:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;vertices&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;2lop&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;properties&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;price&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;value&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>328</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;value&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;lop&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;lang&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;value&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;java&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;1josh&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;vertex&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;properties&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;value&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;josh&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;age&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;value&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>32</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#a40000>...</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span>
</span></span></code></pre></div><p id=swaggerui-example></p><p>详细的 API 请参考 <a href=/docs/clients/restful-api>RESTful-API</a> 文档。</p><p>另外也可以通过访问 <code>localhost:8080/swagger-ui/index.html</code> 查看 API。</p><div style=text-align:center><img src=/docs/images/images-server/swagger-ui.png alt=image></div><p>在使用 Swagger UI 调试 HugeGraph 提供的 API 时,如果 HugeGraph Server 开启了鉴权模式,可以在 Swagger 页面输入鉴权信息。</p><div style=text-align:center><img src=/docs/images/images-server/swagger-ui-where-set-auth-example.png alt=image></div><p>当前 HugeGraph 支持基于 Basic 和 Bearer 两种形式设置鉴权信息。</p><div style=text-align:center><img src=/docs/images/images-server/swagger-ui-set-auth-example.png alt=image></div><h3 id=7-停止-server>7 停止 Server</h3><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#000>$cd</span> *hugegraph-<span style=color:#4e9a06>${</span><span style=color:#000>version</span><span style=color:#4e9a06>}</span>
</span></span><span style=display:flex><span><span style=color:#000>$bin</span>/stop-hugegraph.sh
</span></span></code></pre></div><h3 id=8-使用-intellij-idea-调试-server>8 使用 IntelliJ IDEA 调试 Server</h3><p>请参考<a href=/docs/contribution-guidelines/hugegraph-server-idea-setup>在 IDEA 中配置 Server 开发环境</a></p></div><div class=td-content style=page-break-before:always><h1 id=pg-685a02f8811d86f1ce195d7c73d9ea44>2 - HugeGraph-Loader Quick Start</h1><h3 id=1-hugegraph-loader-概述>1 HugeGraph-Loader 概述</h3><p>HugeGraph-Loader 是 HugeGraph 的数据导入组件,能够将多种数据源的数据转化为图的顶点和边并批量导入到图数据库中。</p><p>目前支持的数据源包括:</p><ul><li>本地磁盘文件或目录,支持 TEXT、CSV 和 JSON 格式的文件,支持压缩文件</li><li>HDFS 文件或目录,支持压缩文件</li><li>主流关系型数据库,如 MySQL、PostgreSQL、Oracle、SQL Server</li></ul><p>本地磁盘文件和 HDFS 文件支持断点续传。</p><p>后面会具体说明。</p><blockquote><p>注意:使用 HugeGraph-Loader 需要依赖 HugeGraph Server 服务,下载和启动 Server 请参考 <a href=/docs/quickstart/hugegraph-server>HugeGraph-Server Quick Start</a></p></blockquote><h3 id=2-获取-hugegraph-loader>2 获取 HugeGraph-Loader</h3><p>有两种方式可以获取 HugeGraph-Loader:</p><ul><li>使用 Docker 镜像 (便于<strong>测试</strong>)</li><li>下载已编译的压缩包</li><li>克隆源码编译安装</li></ul><h4 id=21-使用-docker-镜像-便于测试>2.1 使用 Docker 镜像 (便于<strong>测试</strong>)</h4><p>我们可以使用 <code>docker run -itd --name loader hugegraph/loader</code>部署 loader 服务。对于需要加载的数据,则可以通过挂载 <code>-v /path/to/data/file:/loader/file</code> 或者<code>docker cp</code>的方式将文件复制到 loader 容器内部。</p><p>或者使用 docker-compose 启动 loader, 启动命令为 <code>docker-compose up -d</code>, 样例的 docker-compose.yml 如下所示:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-yaml data-lang=yaml><span style=display:flex><span><span style=color:#204a87;font-weight:700>version</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#39;3&#39;</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#204a87;font-weight:700>services</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>server</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>image</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph/hugegraph</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>container_name</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>server</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>ports</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#0000cf;font-weight:700>8080</span><span style=color:#000;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>8080</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>hubble</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>image</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph/hubble</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>container_name</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hubble</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>ports</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#0000cf;font-weight:700>8088</span><span style=color:#000;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>8088</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>loader</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>image</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph/loader</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>container_name</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>loader</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic># mount your own data here</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic># volumes:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic># - /path/to/data/file:/loader/file</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span></code></pre></div><p>具体的数据导入流程可以参考 <a href=#45-%E4%BD%BF%E7%94%A8-docker-%E5%AF%BC%E5%85%A5>4.5 使用 docker 导入</a></p><blockquote><p>注意:</p><ol><li><p>hugegraph-loader 的 docker 镜像是一个便捷版本,用于快速启动 loader,并不是<strong>官方发布物料包方式</strong>。你可以从 <a href=https://infra.apache.org/release-distribution.html#dockerhub>ASF Release Distribution Policy</a> 中得到更多细节。</p></li><li><p>推荐使用 <code>release tag</code>(如 <code>1.2.0</code>) 以获取稳定版。使用 <code>latest</code> tag 可以使用开发中的最新功能。</p></li></ol></blockquote><h4 id=22-下载已编译的压缩包>2.2 下载已编译的压缩包</h4><p>下载最新版本的 <code>HugeGraph-Toolchain</code> Release 包,里面包含了 <code>loader + tool + hubble</code> 全套工具,如果你已经下载,可跳过重复步骤</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>wget https://downloads.apache.org/incubator/hugegraph/<span style=color:#ce5c00;font-weight:700>{</span>version<span style=color:#ce5c00;font-weight:700>}</span>/apache-hugegraph-toolchain-incubating-<span style=color:#ce5c00;font-weight:700>{</span>version<span style=color:#ce5c00;font-weight:700>}</span>.tar.gz
</span></span><span style=display:flex><span>tar zxf *hugegraph*.tar.gz
</span></span></code></pre></div><h4 id=23-克隆源码编译安装>2.3 克隆源码编译安装</h4><p>克隆最新版本的 HugeGraph-Loader 源码包:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#8f5902;font-style:italic># 1. get from github</span>
</span></span><span style=display:flex><span>git clone https://github.com/apache/hugegraph-toolchain.git
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># 2. get from direct url (please choose the **latest release** version)</span>
</span></span><span style=display:flex><span>wget https://downloads.apache.org/incubator/hugegraph/<span style=color:#ce5c00;font-weight:700>{</span>version<span style=color:#ce5c00;font-weight:700>}</span>/apache-hugegraph-toolchain-incubating-<span style=color:#ce5c00;font-weight:700>{</span>version<span style=color:#ce5c00;font-weight:700>}</span>-src.tar.gz
</span></span></code></pre></div><details><summary>点击展开/折叠 手动安装 ojdbc 方法</summary><p>由于 Oracle ojdbc license 的限制,需要手动安装 ojdbc 到本地 maven 仓库。
访问 <a href=https://www.oracle.com/database/technologies/appdev/jdbc-drivers-archive.html>Oracle jdbc 下载</a> 页面。选择 Oracle Database 12c Release 2 (12.2.0.1) drivers,如下图所示。</p><p>打开链接后,选择“ojdbc8.jar”</p><p>把 ojdbc8 安装到本地 maven 仓库,进入<code>ojdbc8.jar</code>所在目录,执行以下命令。</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>mvn install:install-file -Dfile=./ojdbc8.jar -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar
</span></span></code></pre></div></details><p>编译生成 tar 包:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#204a87>cd</span> hugegraph-loader
</span></span><span style=display:flex><span>mvn clean package -DskipTests
</span></span></code></pre></div><h3 id=3-使用流程>3 使用流程</h3><p>使用 HugeGraph-Loader 的基本流程分为以下几步:</p><ul><li>编写图模型</li><li>准备数据文件</li><li>编写输入源映射文件</li><li>执行命令导入</li></ul><h4 id=31-编写图模型>3.1 编写图模型</h4><p>这一步是建模的过程,用户需要对自己已有的数据和想要创建的图模型有一个清晰的构想,然后编写 schema 建立图模型。</p><p>比如想创建一个拥有两类顶点及两类边的图,顶点是"人"和"软件",边是"人认识人"和"人创造软件",并且这些顶点和边都带有一些属性,比如顶点"人"有:&ldquo;姓名&rdquo;、&ldquo;年龄"等属性,
&ldquo;软件"有:&ldquo;名字&rdquo;、&ldquo;售卖价格"等属性;边"认识"有:&ldquo;日期"属性等。</p><div style=text-align:center><img src=/docs/images/demo-graph-model.png alt=image><p>示例图模型</p></div><p>在设计好了图模型之后,我们可以用<code>groovy</code>编写出<code>schema</code>的定义,并保存至文件中,这里命名为<code>schema.groovy</code></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-groovy data-lang=groovy><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// 创建一些属性
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asInt</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asDouble</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// 创建 person 顶点类型,其拥有三个属性:name, age, city,主键是 name
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>vertexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>primaryKeys</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// 创建 software 顶点类型,其拥有两个属性:name, price,主键是 name
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>vertexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>primaryKeys</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// 创建 knows 边类型,这类边是从 person 指向 person 的
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>edgeLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>sourceLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>targetLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// 创建 created 边类型,这类边是从 person 指向 software 的
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>edgeLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>sourceLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>targetLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span></code></pre></div><blockquote><p>关于 schema 的详细说明请参考 <a href=/docs/clients/hugegraph-client>hugegraph-client</a> 中对应部分。</p></blockquote><h4 id=32-准备数据>3.2 准备数据</h4><p>目前 HugeGraph-Loader 支持的数据源包括:</p><ul><li>本地磁盘文件或目录</li><li>HDFS 文件或目录</li><li>部分关系型数据库</li><li>Kafka topic</li></ul><h5 id=321-数据源结构>3.2.1 数据源结构</h5><h6 id=3211-本地磁盘文件或目录>3.2.1.1 本地磁盘文件或目录</h6><p>用户可以指定本地磁盘文件作为数据源,如果数据分散在多个文件中,也支持以某个目录作为数据源,但暂时不支持以多个目录作为数据源。</p><p>比如:我的数据分散在多个文件中,part-0、part-1 &mldr; part-n,要想执行导入,必须保证它们是放在一个目录下的。然后在 loader 的映射文件中,将<code>path</code>指定为该目录即可。</p><p>支持的文件格式包括:</p><ul><li>TEXT</li><li>CSV</li><li>JSON</li></ul><p>TEXT 是自定义分隔符的文本文件,第一行通常是标题,记录了每一列的名称,也允许没有标题行(在映射文件中指定)。其余的每行代表一条记录,会被转化为一个顶点/边;行的每一列对应一个字段,会被转化为顶点/边的 id、label 或属性;</p><p>示例如下:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>id|name|lang|price|ISBN
</span></span><span style=display:flex><span>1|lop|java|328|ISBN978-7-107-18618-5
</span></span><span style=display:flex><span>2|ripple|java|199|ISBN978-7-100-13678-5
</span></span></code></pre></div><p>CSV 是分隔符为逗号<code>,</code>的 TEXT 文件,当列值本身包含逗号时,该列值需要用双引号包起来,如:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>marko,29,Beijing
</span></span><span style=display:flex><span>&#34;li,nary&#34;,26,&#34;Wu,han&#34;
</span></span></code></pre></div><p>JSON 文件要求每一行都是一个 JSON 串,且每行的格式需保持一致。</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;marko&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;vadas&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;date&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;20160110&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;weight&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>0.5</span><span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;marko&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;josh&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;date&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;20130220&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;weight&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>1.0</span><span style=color:#000;font-weight:700>}</span>
</span></span></code></pre></div><h6 id=3212-hdfs-文件或目录>3.2.1.2 HDFS 文件或目录</h6><p>用户也可以指定 HDFS 文件或目录作为数据源,上面关于<code>本地磁盘文件或目录</code>的要求全部适用于这里。除此之外,鉴于 HDFS 上通常存储的都是压缩文件,loader 也提供了对压缩文件的支持,并且<code>本地磁盘文件或目录</code>同样支持压缩文件。</p><p>目前支持的压缩文件类型包括:GZIP、BZ2、XZ、LZMA、SNAPPY_RAW、SNAPPY_FRAMED、Z、DEFLATE、LZ4_BLOCK、LZ4_FRAMED、ORC 和 PARQUET。</p><h6 id=3213-主流关系型数据库>3.2.1.3 主流关系型数据库</h6><p>loader 还支持以部分关系型数据库作为数据源,目前支持 MySQL、PostgreSQL、Oracle 和 SQL Server。</p><p>但目前对表结构要求较为严格,如果导入过程中需要做<strong>关联查询</strong>,这样的表结构是不允许的。关联查询的意思是:在读到表的某行后,发现某列的值不能直接使用(比如外键),需要再去做一次查询才能确定该列的真实值。</p><p>举个例子:假设有三张表,person、software 和 created</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>// person 表结构
</span></span><span style=display:flex><span>id | name | age | city
</span></span></code></pre></div><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>// software 表结构
</span></span><span style=display:flex><span>id | name | lang | price
</span></span></code></pre></div><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>// created 表结构
</span></span><span style=display:flex><span>id | p_id | s_id | date
</span></span></code></pre></div><p>如果在建模(schema)时指定 person 或 software 的 id 策略是 PRIMARY_KEY,选择以 name 作为 primary keys(注意:这是 hugegraph 中 vertexlabel 的概念),在导入边数据时,由于需要拼接出源顶点和目标顶点的 id,必须拿着 p_id/s_id 去 person/software 表中查到对应的 name,这种需要做额外查询的表结构的情况,loader 暂时是不支持的。这时可以采用以下两种方式替代:</p><ol><li>仍然指定 person 和 software 的 id 策略为 PRIMARY_KEY,但是以 person 表和 software 表的 id 列作为顶点的主键属性,这样导入边时直接使用 p_id 和 s_id 和顶点的 label 拼接就能生成 id 了;</li><li>指定 person 和 software 的 id 策略为 CUSTOMIZE,然后直接以 person 表和 software 表的 id 列作为顶点 id,这样导入边时直接使用 p_id 和 s_id 即可;</li></ol><p>关键点就是要让边能直接使用 p_id 和 s_id,不要再去查一次。</p><h5 id=322-准备顶点和边数据>3.2.2 准备顶点和边数据</h5><h6 id=3221-顶点数据>3.2.2.1 顶点数据</h6><p>顶点数据文件由一行一行的数据组成,一般每一行作为一个顶点,每一列会作为顶点属性。下面以 CSV 格式作为示例进行说明。</p><ul><li>person 顶点数据(数据本身不包含 header)</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>Tom,48,Beijing
</span></span><span style=display:flex><span>Jerry,36,Shanghai
</span></span></code></pre></div><ul><li>software 顶点数据(数据本身包含 header)</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>name,price
</span></span><span style=display:flex><span>Photoshop,999
</span></span><span style=display:flex><span>Office,388
</span></span></code></pre></div><h6 id=3222-边数据>3.2.2.2 边数据</h6><p>边数据文件由一行一行的数据组成,一般每一行作为一条边,其中有部分列会作为源顶点和目标顶点的 id,其他列作为边属性。下面以 JSON 格式作为示例进行说明。</p><ul><li>knows 边数据</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;Tom&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;Jerry&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;date&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;2008-12-12&#34;</span><span style=color:#000;font-weight:700>}</span>
</span></span></code></pre></div><ul><li>created 边数据</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;Tom&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;Photoshop&#34;</span><span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;Tom&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;Office&#34;</span><span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;Jerry&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;Office&#34;</span><span style=color:#000;font-weight:700>}</span>
</span></span></code></pre></div><h4 id=33-编写数据源映射文件>3.3 编写数据源映射文件</h4><h5 id=331-映射文件概述>3.3.1 映射文件概述</h5><p>输入源的映射文件用于描述如何将输入源数据与图的顶点类型/边类型建立映射关系,以<code>JSON</code>格式组织,由多个映射块组成,其中每一个映射块都负责将一个输入源映射为顶点和边。</p><p>具体而言,每个映射块包含<strong>一个输入源</strong>和多个<strong>顶点映射</strong><strong>边映射</strong>块,输入源块对应上面介绍的<code>本地磁盘文件或目录</code><code>HDFS 文件或目录</code><code>关系型数据库</code>,负责描述数据源的基本信息,比如数据在哪,是什么格式的,分隔符是什么等。顶点映射/边映射与该输入源绑定,可以选择输入源的哪些列,哪些列作为 id、哪些列作为属性,以及每一列映射成什么属性,列的值映射成属性的什么值等等。</p><p>以最通俗的话讲,每一个映射块描述了:要导入的文件在哪,文件的每一行要作为哪一类顶点/边,文件的哪些列是需要导入的,以及这些列对应顶点/边的什么属性等。</p><blockquote><p>注意:0.11.0 版本以前的映射文件与 0.11.0 以后的格式变化较大,为表述方便,下面称 0.11.0 以前的映射文件(格式)为 1.0 版本,0.11.0 以后的为 2.0 版本。并且若无特殊说明,“映射文件”表示的是 2.0 版本的。</p></blockquote><details><summary>点击展开/折叠 2.0 版本的映射文件的框架</summary><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;version&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;2.0&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;structs&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;1&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;vertices&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{},</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;edges&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{},</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span>
</span></span></code></pre></div></details><br><p>这里直接给出两个版本的映射文件(描述了上面图模型和数据文件)</p><details><summary>点击展开/折叠 2.0 版本的映射文件</summary><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;version&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;2.0&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;structs&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;1&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skip&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;FILE&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;vertex_person.csv&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;file_filter&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;extensions&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;*&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;CSV&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;delimiter&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;,&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;date_format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;yyyy-MM-dd HH:mm:ss&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;time_zone&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;GMT+8&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skipped_line&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;regex&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;(^#|^//).*|&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;compression&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;NONE&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;header&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;city&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;charset&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;UTF-8&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;list_format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;start_symbol&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;[&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;elem_delimiter&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;|&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;end_symbol&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;]&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;vertices&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skip&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>null</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;unfold&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;field_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;value_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;selected&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;ignored&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;null_values&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;update_strategies&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;edges&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;2&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skip&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;FILE&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;vertex_software.csv&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;file_filter&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;extensions&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;*&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;CSV&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;delimiter&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;,&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;date_format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;yyyy-MM-dd HH:mm:ss&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;time_zone&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;GMT+8&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skipped_line&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;regex&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;(^#|^//).*|&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;compression&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;NONE&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;header&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>null</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;charset&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;UTF-8&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;list_format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;start_symbol&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;elem_delimiter&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;,&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;end_symbol&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;vertices&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skip&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>null</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;unfold&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;field_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;value_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;selected&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;ignored&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;null_values&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;update_strategies&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;edges&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;3&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skip&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;FILE&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;edge_knows.json&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;file_filter&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;extensions&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;*&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;JSON&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;delimiter&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>null</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;date_format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;yyyy-MM-dd HH:mm:ss&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;time_zone&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;GMT+8&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skipped_line&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;regex&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;(^#|^//).*|&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;compression&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;NONE&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;header&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>null</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;charset&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;UTF-8&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;list_format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>null</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;vertices&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;edges&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skip&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;source_name&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;unfold_source&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;target&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;target_name&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;unfold_target&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;field_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;value_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;selected&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;ignored&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;null_values&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;update_strategies&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;4&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skip&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;FILE&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;edge_created.json&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;file_filter&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;extensions&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;*&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;JSON&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;delimiter&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>null</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;date_format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;yyyy-MM-dd HH:mm:ss&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;time_zone&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;GMT+8&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skipped_line&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;regex&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;(^#|^//).*|&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;compression&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;NONE&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;header&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>null</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;charset&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;UTF-8&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;list_format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>null</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;vertices&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;edges&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skip&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;source_name&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;unfold_source&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;target&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;target_name&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;unfold_target&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;field_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;value_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;selected&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;ignored&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;null_values&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;update_strategies&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span>
</span></span></code></pre></div></details><br><details><summary>点击展开/折叠 1.0 版本的映射文件</summary><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;vertices&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;file&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;vertex_person.csv&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;CSV&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;header&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;charset&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;UTF-8&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;file&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;vertex_software.csv&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;CSV&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;edges&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;target&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;file&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;edge_knows.json&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;JSON&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;field_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;target&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;file&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;edge_created.json&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;JSON&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;field_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span>
</span></span></code></pre></div></details><br><p>映射文件 1.0 版本是以顶点和边为中心,设置输入源;而 2.0 版本是以输入源为中心,设置顶点和边映射。有些输入源(比如一个文件)既能生成顶点,也能生成边,如果用 1.0 版的格式写,就需要在 vertex 和 edge 映射块中各写一次 input 块,这两次的 input 块是完全一样的;而 2.0 版本只需要写一次 input。所以 2.0 版相比于 1.0 版,能省掉一些 input 的重复书写。</p><p>在 hugegraph-loader-{version} 的 bin 目录下,有一个脚本工具 <code>mapping-convert.sh</code> 能直接将 1.0 版本的映射文件转换为 2.0 版本的,使用方式如下:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/mapping-convert.sh struct.json
</span></span></code></pre></div><p>会在 struct.json 的同级目录下生成一个 struct-v2.json。</p><h5 id=332-输入源>3.3.2 输入源</h5><p>输入源目前分为四类:FILE、HDFS、JDBC、KAFKA,由<code>type</code>节点区分,我们称为本地文件输入源、HDFS 输入源、JDBC 输入源和 KAFKA 输入源,下面分别介绍。</p><h6 id=3321-本地文件输入源>3.3.2.1 本地文件输入源</h6><ul><li>id: 输入源的 id,该字段用于支持一些内部功能,非必填(未填时会自动生成),强烈建议写上,对于调试大有裨益;</li><li>skip: 是否跳过该输入源,由于 JSON 文件无法添加注释,如果某次导入时不想导入某个输入源,但又不想删除该输入源的配置,则可以设置为 true 将其跳过,默认为 false,非必填;</li><li>input: 输入源映射块,复合结构<ul><li>type: 输入源类型,必须填 file 或 FILE;</li><li>path: 本地文件或目录的路径,绝对路径或相对于映射文件的相对路径,建议使用绝对路径,必填;</li><li>file_filter: 从<code>path</code>中筛选复合条件的文件,复合结构,目前只支持配置扩展名,用子节点<code>extensions</code>表示,默认为&rdquo;*",表示保留所有文件;</li><li>format: 本地文件的格式,可选值为 CSV、TEXT 及 JSON,必须大写,必填;</li><li>header: 文件各列的列名,如不指定则会以数据文件第一行作为 header;当文件本身有标题且又指定了 header,文件的第一行会被当作普通的数据行;JSON 文件不需要指定 header,选填;</li><li>delimiter: 文件行的列分隔符,默认以逗号<code>","</code>作为分隔符,<code>JSON</code>文件不需要指定,选填;</li><li>charset: 文件的编码字符集,默认<code>UTF-8</code>,选填;</li><li>date_format: 自定义的日期格式,默认值为 yyyy-MM-dd HH:mm:ss,选填;如果日期是以时间戳的形式呈现的,此项须写为<code>timestamp</code>(固定写法);</li><li>time_zone: 设置日期数据是处于哪个时区的,默认值为<code>GMT+8</code>,选填;</li><li>skipped_line: 想跳过的行,复合结构,目前只能配置要跳过的行的正则表达式,用子节点<code>regex</code>描述,默认不跳过任何行,选填;</li><li>compression: 文件的压缩格式,可选值为 NONE、GZIP、BZ2、XZ、LZMA、SNAPPY_RAW、SNAPPY_FRAMED、Z、DEFLATE、LZ4_BLOCK、LZ4_FRAMED、ORC 和 PARQUET,默认为 NONE,表示非压缩文件,选填;</li><li>list_format: 当文件 (非 JSON ) 的某列是集合结构时(对应图中的 PropertyKey 的 Cardinality 为 Set 或 List),可以用此项设置该列的起始符、分隔符、结束符,复合结构:<ul><li>start_symbol: 集合结构列的起始符 (默认值是 <code>[</code>, JSON 格式目前不支持指定)</li><li>elem_delimiter: 集合结构列的分隔符 (默认值是 <code>|</code>, JSON 格式目前只支持原生<code>,</code>分隔)</li><li>end_symbol: 集合结构列的结束符 (默认值是 <code>]</code>, JSON 格式目前不支持指定)</li></ul></li></ul></li></ul><h6 id=3322-hdfs-输入源>3.3.2.2 HDFS 输入源</h6><p>上述<code>本地文件输入源</code>的节点及含义这里基本都适用,下面仅列出 HDFS 输入源不一样的和特有的节点。</p><ul><li>type: 输入源类型,必须填 hdfs 或 HDFS,必填;</li><li>path: HDFS 文件或目录的路径,必须是 HDFS 的绝对路径,必填;</li><li>core_site_path: HDFS 集群的 core-site.xml 文件路径,重点要指明 NameNode 的地址(<code>fs.default.name</code>),以及文件系统的实现(<code>fs.hdfs.impl</code>);</li></ul><h6 id=3323-jdbc-输入源>3.3.2.3 JDBC 输入源</h6><p>前面说到过支持多种关系型数据库,但由于它们的映射结构非常相似,故统称为 JDBC 输入源,然后用<code>vendor</code>节点区分不同的数据库。</p><ul><li>type: 输入源类型,必须填 jdbc 或 JDBC,必填;</li><li>vendor: 数据库类型,可选项为 [MySQL、PostgreSQL、Oracle、SQLServer],不区分大小写,必填;</li><li>driver: jdbc 使用的 driver 类型,必填;</li><li>url: jdbc 要连接的数据库的 url,必填;</li><li>database: 要连接的数据库名,必填;</li><li>schema: 要连接的 schema 名,不同的数据库要求不一样,下面详细说明;</li><li>table: 要连接的表名,<code>custom_sql</code><code>table</code> 参数必须填其中一个;</li><li>custom_sql: 自定义 SQL 语句,<code>custom_sql</code><code>table</code> 参数必须填其中一个;</li><li>username: 连接数据库的用户名,必填;</li><li>password: 连接数据库的密码,必填;</li><li>batch_size: 按页获取表数据时的一页的大小,默认为 500,选填;</li></ul><p><strong>MYSQL</strong></p><table><thead><tr><th>节点</th><th>固定值或常见值</th></tr></thead><tbody><tr><td>vendor</td><td>MYSQL</td></tr><tr><td>driver</td><td>com.mysql.cj.jdbc.Driver</td></tr><tr><td>url</td><td>jdbc:mysql://127.0.0.1:3306</td></tr></tbody></table><p>schema: 可空,若填写必须与 database 的值一样</p><p><strong>POSTGRESQL</strong></p><table><thead><tr><th>节点</th><th>固定值或常见值</th></tr></thead><tbody><tr><td>vendor</td><td>POSTGRESQL</td></tr><tr><td>driver</td><td>org.postgresql.Driver</td></tr><tr><td>url</td><td>jdbc:postgresql://127.0.0.1:5432</td></tr></tbody></table><p>schema: 可空,默认值为“public”</p><p><strong>ORACLE</strong></p><table><thead><tr><th>节点</th><th>固定值或常见值</th></tr></thead><tbody><tr><td>vendor</td><td>ORACLE</td></tr><tr><td>driver</td><td>oracle.jdbc.driver.OracleDriver</td></tr><tr><td>url</td><td>jdbc:oracle:thin:@127.0.0.1:1521</td></tr></tbody></table><p>schema: 可空,默认值与用户名相同</p><p><strong>SQLSERVER</strong></p><table><thead><tr><th>节点</th><th>固定值或常见值</th></tr></thead><tbody><tr><td>vendor</td><td>SQLSERVER</td></tr><tr><td>driver</td><td>com.microsoft.sqlserver.jdbc.SQLServerDriver</td></tr><tr><td>url</td><td>jdbc:sqlserver://127.0.0.1:1433</td></tr></tbody></table><p>schema: 必填</p><h6 id=3324-kafka-输入源>3.3.2.4 Kafka 输入源</h6><ul><li>type:输入源类型,必须填 <code>kafka</code><code>KAFKA</code>,必填;</li><li>bootstrap_server:设置 kafka bootstrap server 列表;</li><li>topic:订阅的 topic;</li><li>group:Kafka 消费者组;</li><li>from_beginning:设置是否从头开始读取;</li><li>format:本地文件的格式,可选值为 CSV、TEXT 及 JSON,必须大写,必填;</li><li>header:文件各列的列名,如不指定则会以数据文件第一行作为 header;当文件本身有标题且又指定了 header,文件的第一行会被当作普通的数据行;JSON 文件不需要指定 header,选填;</li><li>delimiter:文件行的列分隔符,默认以逗号&rdquo;,&ldquo;作为分隔符,JSON 文件不需要指定,选填;</li><li>charset:文件的编码字符集,默认 UTF-8,选填;</li><li>date_format:自定义的日期格式,默认值为 yyyy-MM-dd HH:mm:ss,选填;如果日期是以时间戳的形式呈现的,此项须写为 timestamp(固定写法);</li><li>extra_date_formats:自定义的其他日期格式列表,默认为空,选填;列表中每一项都是一个 date_format 指定日期格式的备用日期格式;</li><li>time_zone:置日期数据是处于哪个时区的,默认值为 GMT+8,选填;</li><li>skipped_line:想跳过的行,复合结构,目前只能配置要跳过的行的正则表达式,用子节点 regex 描述,默认不跳过任何行,选填;</li><li>early_stop:某次从 Kafka broker 拉取的记录为空,停止任务,默认为 false,仅用于调试,选填;</li></ul><h5 id=333-顶点和边映射>3.3.3 顶点和边映射</h5><p>顶点和边映射的节点(JSON 文件中的一个 key)有很多相同的部分,下面先介绍相同部分,再分别介绍<code>顶点映射</code><code>边映射</code>的特有节点。</p><p><strong>相同部分的节点</strong></p><ul><li>label: 待导入的顶点/边数据所属的<code>label</code>,必填;</li><li>field_mapping: 将输入源列的列名映射为顶点/边的属性名,选填;</li><li>value_mapping: 将输入源的数据值映射为顶点/边的属性值,选填;</li><li>selected: 选择某些列插入,其他未选中的不插入,不能与<code>ignored</code>同时存在,选填;</li><li>ignored: 忽略某些列,使其不参与插入,不能与<code>selected</code>同时存在,选填;</li><li>null_values: 可以指定一些字符串代表空值,比如"NULL&rdquo;,如果该列对应的顶点/边属性又是一个可空属性,那在构造顶点/边时不会设置该属性的值,选填;</li><li>update_strategies: 如果数据需要按特定方式批量<strong>更新</strong>时可以对每个属性指定具体的更新策略 (具体见下),选填;</li><li>unfold: 是否将列展开,展开的每一列都会与其他列一起组成一行,相当于是展开成了多行;比如文件的某一列(id 列)的值是<code>[1,2,3]</code>,其他列的值是<code>18,Beijing</code>,当设置了 unfold 之后,这一行就会变成 3 行,分别是:<code>1,18,Beijing</code><code>2,18,Beijing</code><code>3,18,Beijing</code>。需要注意的是此项只会展开被选作为 id 的列。默认 false,选填;</li></ul><p><strong>更新策略</strong>支持 8 种 : (需要全大写)</p><ol><li>数值累加 : <code>SUM</code></li><li>两个数字/日期取更大的: <code>BIGGER</code></li><li>两个数字/日期取更小: <code>SMALLER</code></li><li><strong>Set</strong>属性取并集:<code>UNION</code></li><li><strong>Set</strong>属性取交集:<code>INTERSECTION</code></li><li><strong>List</strong>属性追加元素:<code>APPEND</code></li><li><strong>List/Set</strong>属性删除元素:<code>ELIMINATE</code></li><li>覆盖已有属性:<code>OVERRIDE</code></li></ol><p><strong>注意:</strong> 如果新导入的属性值为空,会采用已有的旧数据而不会采用空值,效果可以参考如下示例</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// JSON 文件中以如下方式指定更新策略
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;vertices&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;update_strategies&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;age&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;SMALLER&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;set&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;UNION&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;file&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;vertex_person.txt&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;TEXT&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;header&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>&#34;set&#34;</span><span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// 1.写入一行带 OVERRIDE 更新策略的数据 (这里 null 代表空)
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#a40000>&#39;a</span> <span style=color:#a40000>b</span> <span style=color:#204a87;font-weight:700>null</span> <span style=color:#204a87;font-weight:700>null</span><span style=color:#a40000>&#39;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// 2.再写一行
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#a40000>&#39;</span><span style=color:#204a87;font-weight:700>null</span> <span style=color:#204a87;font-weight:700>null</span> <span style=color:#a40000>c</span> <span style=color:#a40000>d&#39;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// 3.最后可以得到
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#a40000>&#39;a</span> <span style=color:#a40000>b</span> <span style=color:#a40000>c</span> <span style=color:#a40000>d&#39;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>// 如果没有更新策略,则会得到
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span><span style=color:#a40000>&#39;</span><span style=color:#204a87;font-weight:700>null</span> <span style=color:#204a87;font-weight:700>null</span> <span style=color:#a40000>c</span> <span style=color:#a40000>d&#39;</span>
</span></span></code></pre></div><blockquote><p><strong>注意</strong> : 采用了批量更新的策略后, 磁盘读请求数会大幅上升, 导入速度相比纯写覆盖会慢数倍 (此时HDD磁盘<a href=https://en.wikipedia.org/wiki/IOPS>IOPS</a>会成为瓶颈, 建议采用SSD以保证速度)</p></blockquote><p><strong>顶点映射的特有节点</strong></p><ul><li>id: 指定某一列作为顶点的 id 列,当顶点 id 策略为<code>CUSTOMIZE</code>时,必填;当 id 策略为<code>PRIMARY_KEY</code>时,必须为空;</li></ul><p><strong>边映射的特有节点</strong></p><ul><li>source: 选择输入源某几列作为<strong>源顶点</strong>的 id 列,当源顶点的 id 策略为 <code>CUSTOMIZE</code>时,必须指定某一列作为顶点的 id 列;当源顶点的 id 策略为 <code>PRIMARY_KEY</code>时,必须指定一列或多列用于拼接生成顶点的 id,也就是说,不管是哪种 id 策略,此项必填;</li><li>target: 指定某几列作为<strong>目标顶点</strong>的 id 列,与 source 类似,不再赘述;</li><li>unfold_source: 是否展开文件的 source 列,效果与顶点映射中的类似,不再赘述;</li><li>unfold_target: 是否展开文件的 target 列,效果与顶点映射中的类似,不再赘述;</li></ul><h4 id=34-执行命令导入>3.4 执行命令导入</h4><p>准备好图模型、数据文件以及输入源映射关系文件后,接下来就可以将数据文件导入到图数据库中。</p><p>导入过程由用户提交的命令控制,用户可以通过不同的参数控制执行的具体流程。</p><h5 id=341-参数说明>3.4.1 参数说明</h5><table><thead><tr><th>参数</th><th>默认值</th><th>是否必传</th><th>描述信息</th></tr></thead><tbody><tr><td><code>-f</code><code>--file</code></td><td></td><td>Y</td><td>配置脚本的路径</td></tr><tr><td><code>-g</code><code>--graph</code></td><td></td><td>Y</td><td>图数据库空间</td></tr><tr><td><code>-s</code><code>--schema</code></td><td></td><td>Y</td><td>schema 文件路径</td></tr><tr><td><code>-h</code><code>--host</code></td><td>localhost</td><td></td><td>HugeGraphServer 的地址</td></tr><tr><td><code>-p</code><code>--port</code></td><td>8080</td><td></td><td>HugeGraphServer 的端口号</td></tr><tr><td><code>--username</code></td><td>null</td><td></td><td>当 HugeGraphServer 开启了权限认证时,当前图的 username</td></tr><tr><td><code>--token</code></td><td>null</td><td></td><td>当 HugeGraphServer 开启了权限认证时,当前图的 token</td></tr><tr><td><code>--protocol</code></td><td>http</td><td></td><td>向服务端发请求的协议,可选 http 或 https</td></tr><tr><td><code>--trust-store-file</code></td><td></td><td></td><td>请求协议为 https 时,客户端的证书文件路径</td></tr><tr><td><code>--trust-store-password</code></td><td></td><td></td><td>请求协议为 https 时,客户端证书密码</td></tr><tr><td><code>--clear-all-data</code></td><td>false</td><td></td><td>导入数据前是否清除服务端的原有数据</td></tr><tr><td><code>--clear-timeout</code></td><td>240</td><td></td><td>导入数据前清除服务端的原有数据的超时时间</td></tr><tr><td><code>--incremental-mode</code></td><td>false</td><td></td><td>是否使用断点续导模式,仅输入源为 FILE 和 HDFS 支持该模式,启用该模式能从上一次导入停止的地方开始导</td></tr><tr><td><code>--failure-mode</code></td><td>false</td><td></td><td>失败模式为 true 时,会导入之前失败了的数据,一般来说失败数据文件需要在人工更正编辑好后,再次进行导入</td></tr><tr><td><code>--batch-insert-threads</code></td><td>CPUs</td><td></td><td>批量插入线程池大小 (CPUs 是当前 OS 可用可用<strong>逻辑核</strong>个数)</td></tr><tr><td><code>--single-insert-threads</code></td><td>8</td><td></td><td>单条插入线程池的大小</td></tr><tr><td><code>--max-conn</code></td><td>4 * CPUs</td><td></td><td>HugeClient 与 HugeGraphServer 的最大 HTTP 连接数,<strong>调整线程</strong>的时候建议同时调整此项</td></tr><tr><td><code>--max-conn-per-route</code></td><td>2 * CPUs</td><td></td><td>HugeClient 与 HugeGraphServer 每个路由的最大 HTTP 连接数,<strong>调整线程</strong>的时候建议同时调整此项</td></tr><tr><td><code>--batch-size</code></td><td>500</td><td></td><td>导入数据时每个批次包含的数据条数</td></tr><tr><td><code>--max-parse-errors</code></td><td>1</td><td></td><td>最多允许多少行数据解析错误,达到该值则程序退出</td></tr><tr><td><code>--max-insert-errors</code></td><td>500</td><td></td><td>最多允许多少行数据插入错误,达到该值则程序退出</td></tr><tr><td><code>--timeout</code></td><td>60</td><td></td><td>插入结果返回的超时时间(秒)</td></tr><tr><td><code>--shutdown-timeout</code></td><td>10</td><td></td><td>多线程停止的等待时间(秒)</td></tr><tr><td><code>--retry-times</code></td><td>0</td><td></td><td>发生特定异常时的重试次数</td></tr><tr><td><code>--retry-interval</code></td><td>10</td><td></td><td>重试之前的间隔时间(秒)</td></tr><tr><td><code>--check-vertex</code></td><td>false</td><td></td><td>插入边时是否检查边所连接的顶点是否存在</td></tr><tr><td><code>--print-progress</code></td><td>true</td><td></td><td>是否在控制台实时打印导入条数</td></tr><tr><td><code>--dry-run</code></td><td>false</td><td></td><td>打开该模式,只解析不导入,通常用于测试</td></tr><tr><td><code>--help</code></td><td>false</td><td></td><td>打印帮助信息</td></tr></tbody></table><h5 id=342-断点续导模式>3.4.2 断点续导模式</h5><p>通常情况下,Loader 任务都需要较长时间执行,如果因为某些原因导致导入中断进程退出,而下次希望能从中断的点继续导,这就是使用断点续导的场景。</p><p>用户设置命令行参数 &ndash;incremental-mode 为 true 即打开了断点续导模式。断点续导的关键在于进度文件,导入进程退出的时候,会把退出时刻的导入进度
记录到进度文件中,进度文件位于 <code>${struct}</code> 目录下,文件名形如 <code>load-progress ${date}</code> ,${struct} 为映射文件的前缀,${date} 为导入开始
的时刻。比如:在 <code>2019-10-10 12:30:30</code> 开始的一次导入任务,使用的映射文件为 <code>struct-example.json</code>,则进度文件的路径为与 struct-example.json
同级的 <code>struct-example/load-progress 2019-10-10 12:30:30</code></p><blockquote><p>注意:进度文件的生成与 &ndash;incremental-mode 是否打开无关,每次导入结束都会生成一个进度文件。</p></blockquote><p>如果数据文件格式都是合法的,是用户自己停止(CTRL + C 或 kill,kill -9 不支持)的导入任务,也就是说没有错误记录的情况下,下一次导入只需要设置
为断点续导即可。</p><p>但如果是因为太多数据不合法或者网络异常,达到了 &ndash;max-parse-errors 或 &ndash;max-insert-errors 的限制,Loader 会把这些插入失败的原始行记录到
失败文件中,用户对失败文件中的数据行修改后,设置 &ndash;reload-failure 为 true 即可把这些"失败文件"也当作输入源进行导入(不影响正常的文件的导入),
当然如果修改后的数据行仍然有问题,则会被再次记录到失败文件中(不用担心会有重复行)。</p><p>每个顶点映射或边映射有数据插入失败时都会产生自己的失败文件,失败文件又分为解析失败文件(后缀 .parse-error)和插入失败文件(后缀 .insert-error),
它们被保存在 <code>${struct}/current</code> 目录下。比如映射文件中有一个顶点映射 person 和边映射 knows,它们各有一些错误行,当 Loader 退出后,在
<code>${struct}/current</code> 目录下会看到如下文件:</p><ul><li>person-b4cd32ab.parse-error: 顶点映射 person 解析错误的数据</li><li>person-b4cd32ab.insert-error: 顶点映射 person 插入错误的数据</li><li>knows-eb6b2bac.parse-error: 边映射 knows 解析错误的数据</li><li>knows-eb6b2bac.insert-error: 边映射 knows 插入错误的数据</li></ul><blockquote><p>.parse-error 和 .insert-error 并不总是一起存在的,只有存在解析出错的行才会有 .parse-error 文件,只有存在插入出错的行才会有 .insert-error 文件。</p></blockquote><h5 id=343-logs-目录文件说明>3.4.3 logs 目录文件说明</h5><p>程序执行过程中各日志及错误数据会写入 hugegraph-loader.log 文件中。</p><h5 id=344-执行命令>3.4.4 执行命令</h5><p>运行 bin/hugegraph-loader 并传入参数</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/hugegraph-loader -g <span style=color:#ce5c00;font-weight:700>{</span>GRAPH_NAME<span style=color:#ce5c00;font-weight:700>}</span> -f <span style=color:#4e9a06>${</span><span style=color:#000>INPUT_DESC_FILE</span><span style=color:#4e9a06>}</span> -s <span style=color:#4e9a06>${</span><span style=color:#000>SCHEMA_FILE</span><span style=color:#4e9a06>}</span> -h <span style=color:#ce5c00;font-weight:700>{</span>HOST<span style=color:#ce5c00;font-weight:700>}</span> -p <span style=color:#ce5c00;font-weight:700>{</span>PORT<span style=color:#ce5c00;font-weight:700>}</span>
</span></span></code></pre></div><h3 id=4-完整示例>4 完整示例</h3><p>下面给出的是 hugegraph-loader 包中 example 目录下的例子。(<a href=https://github.com/apache/incubator-hugegraph-toolchain/tree/master/hugegraph-loader/assembly/static/example/file>GitHub 地址</a>)</p><h4 id=41-准备数据>4.1 准备数据</h4><p>顶点文件:<code>example/file/vertex_person.csv</code></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-fallback data-lang=fallback><span style=display:flex><span>marko,29,Beijing
</span></span><span style=display:flex><span>vadas,27,Hongkong
</span></span><span style=display:flex><span>josh,32,Beijing
</span></span><span style=display:flex><span>peter,35,Shanghai
</span></span><span style=display:flex><span>&#34;li,nary&#34;,26,&#34;Wu,han&#34;
</span></span><span style=display:flex><span>tom,null,NULL
</span></span></code></pre></div><p>顶点文件:<code>example/file/vertex_software.txt</code></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-text data-lang=text><span style=display:flex><span>id|name|lang|price|ISBN
</span></span><span style=display:flex><span>1|lop|java|328|ISBN978-7-107-18618-5
</span></span><span style=display:flex><span>2|ripple|java|199|ISBN978-7-100-13678-5
</span></span></code></pre></div><p>边文件:<code>example/file/edge_knows.json</code></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;marko&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;vadas&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;date&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;20160110&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;weight&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>0.5</span><span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;marko&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;josh&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;date&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;20130220&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;weight&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>1.0</span><span style=color:#000;font-weight:700>}</span>
</span></span></code></pre></div><p>边文件:<code>example/file/edge_created.json</code></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;aname&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;marko&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;bname&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;lop&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;date&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;20171210&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;weight&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>0.4</span><span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;aname&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;josh&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;bname&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;lop&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;date&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;20091111&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;weight&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>0.4</span><span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;aname&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;josh&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;bname&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;ripple&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;date&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;20171210&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;weight&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>1.0</span><span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>{</span><span style=color:#204a87;font-weight:700>&#34;aname&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;peter&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;bname&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;lop&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;date&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;20170324&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>&#34;weight&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#0000cf;font-weight:700>0.2</span><span style=color:#000;font-weight:700>}</span>
</span></span></code></pre></div><h4 id=42-编写-schema>4.2 编写 schema</h4><details><summary>点击展开/折叠 schema 文件:example/file/schema.groovy</summary><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-groovy data-lang=groovy><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asInt</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asDouble</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asDouble</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>vertexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>primaryKeys</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>vertexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>primaryKeys</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;personByAge&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>onV</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>range</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;personByCity&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>onV</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>secondary</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;personByAgeAndCity&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>onV</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>secondary</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;softwareByPrice&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>onV</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>range</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>edgeLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>sourceLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>targetLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>edgeLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>sourceLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>targetLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;createdByDate&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>onE</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>secondary</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;createdByWeight&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>onE</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>range</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knowsByWeight&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>onE</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>range</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span></code></pre></div></details><h4 id=43-编写输入源映射文件examplefilestructjson>4.3 编写输入源映射文件<code>example/file/struct.json</code></h4><details><summary>点击展开/折叠 源映射文件 example/file/struct.json</summary><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span><span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;vertices&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;file&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;example/file/vertex_person.csv&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;CSV&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;header&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;charset&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;UTF-8&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;skipped_line&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;regex&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;(^#|^//).*&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;null_values&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;NULL&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>&#34;null&#34;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>&#34;&#34;</span><span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;file&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;example/file/vertex_software.txt&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;TEXT&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;delimiter&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;|&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;charset&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;GBK&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;id&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;id&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;ignored&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;ISBN&#34;</span><span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;edges&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;target&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;file&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;example/file/edge_knows.json&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;JSON&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;date_format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;yyyyMMdd&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;field_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;target_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;label&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;target&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;target_id&#34;</span><span style=color:#000;font-weight:700>],</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;input&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;type&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;file&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;path&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;example/file/edge_created.json&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;JSON&#34;</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;date_format&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;yyyy-MM-dd&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>},</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;field_mapping&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&#34;source_name&#34;</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#34;name&#34;</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>]</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>}</span>
</span></span></code></pre></div></details><h4 id=44-执行命令导入>4.4 执行命令导入</h4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>sh bin/hugegraph-loader.sh -g hugegraph -f example/file/struct.json -s example/file/schema.groovy
</span></span></code></pre></div><p>导入结束后,会出现类似如下统计信息:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>vertices/edges has been loaded this <span style=color:#204a87>time</span> : 8/6
</span></span><span style=display:flex><span>--------------------------------------------------
</span></span><span style=display:flex><span>count metrics
</span></span><span style=display:flex><span> input <span style=color:#204a87>read</span> success : <span style=color:#0000cf;font-weight:700>14</span>
</span></span><span style=display:flex><span> input <span style=color:#204a87>read</span> failure : <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span> vertex parse success : <span style=color:#0000cf;font-weight:700>8</span>
</span></span><span style=display:flex><span> vertex parse failure : <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span> vertex insert success : <span style=color:#0000cf;font-weight:700>8</span>
</span></span><span style=display:flex><span> vertex insert failure : <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span> edge parse success : <span style=color:#0000cf;font-weight:700>6</span>
</span></span><span style=display:flex><span> edge parse failure : <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span> edge insert success : <span style=color:#0000cf;font-weight:700>6</span>
</span></span><span style=display:flex><span> edge insert failure : <span style=color:#0000cf;font-weight:700>0</span>
</span></span></code></pre></div><h4 id=45-使用-docker-导入>4.5 使用 docker 导入</h4><h5 id=451-使用-docker-exec-直接导入数据>4.5.1 使用 docker exec 直接导入数据</h5><h6 id=4511-数据准备>4.5.1.1 数据准备</h6><p>如果仅仅尝试使用 loader, 我们可以使用内置的 example 数据集进行导入,无需自己额外准备数据</p><p>如果使用自定义的数据,则在使用 loader 导入数据之前,我们需要将数据复制到容器内部。</p><p>首先我们可以根据 <a href=#41-%E5%87%86%E5%A4%87%E6%95%B0%E6%8D%AE>4.1-4.3</a> 的步骤准备数据,将准备好的数据通过 <code>docker cp</code> 复制到 loader 容器内部。</p><p>假设我们已经按照上述的步骤准备好了对应的数据集,存放在 <code>hugegraph-dataset</code> 文件夹下,文件结构如下:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>tree -f hugegraph-dataset/
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>hugegraph-dataset
</span></span><span style=display:flex><span>├── hugegraph-dataset/edge_created.json
</span></span><span style=display:flex><span>├── hugegraph-dataset/edge_knows.json
</span></span><span style=display:flex><span>├── hugegraph-dataset/schema.groovy
</span></span><span style=display:flex><span>├── hugegraph-dataset/struct.json
</span></span><span style=display:flex><span>├── hugegraph-dataset/vertex_person.csv
</span></span><span style=display:flex><span>└── hugegraph-dataset/vertex_software.txt
</span></span></code></pre></div><p>将文件复制到容器内部</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>docker cp hugegraph-dataset loader:/loader/dataset
</span></span><span style=display:flex><span>docker <span style=color:#204a87>exec</span> -it loader ls /loader/dataset
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>edge_created.json edge_knows.json schema.groovy struct.json vertex_person.csv vertex_software.txt
</span></span></code></pre></div><h6 id=4512-数据导入>4.5.1.2 数据导入</h6><p>以内置的 example 数据集为例,我们可以使用以下的命令对数据进行导入。</p><p>如果需要导入自己准备的数据集,则只需要修改 <code>-f</code> 配置脚本的路径 以及 <code>-s</code> schema 文件路径即可。</p><p>其他的参数可以参照 <a href=#341-%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E>3.4.1 参数说明</a></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>docker <span style=color:#204a87>exec</span> -it loader bin/hugegraph-loader.sh -g hugegraph -f example/file/struct.json -s example/file/schema.groovy -h server -p <span style=color:#0000cf;font-weight:700>8080</span>
</span></span></code></pre></div><p>如果导入用户自定义的数据集,按照刚才的例子,则使用:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>docker <span style=color:#204a87>exec</span> -it loader bin/hugegraph-loader.sh -g hugegraph -f /loader/dataset/struct.json -s /loader/dataset/schema.groovy -h server -p <span style=color:#0000cf;font-weight:700>8080</span>
</span></span></code></pre></div><blockquote><p>如果 <code>loader</code><code>server</code>位于同一 docker 网络,则可以指定 <code>-h {server_container_name}</code>, 否则需要指定 <code>server</code>的宿主机的 ip (在我们的例子中, <code>server_container_name</code><code>server</code>).</p></blockquote><p>然后我们可以观察到结果:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>HugeGraphLoader worked in NORMAL MODE
</span></span><span style=display:flex><span>vertices/edges loaded this <span style=color:#204a87>time</span> : 8/6
</span></span><span style=display:flex><span>--------------------------------------------------
</span></span><span style=display:flex><span>count metrics
</span></span><span style=display:flex><span> input <span style=color:#204a87>read</span> success : <span style=color:#0000cf;font-weight:700>14</span>
</span></span><span style=display:flex><span> input <span style=color:#204a87>read</span> failure : <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span> vertex parse success : <span style=color:#0000cf;font-weight:700>8</span>
</span></span><span style=display:flex><span> vertex parse failure : <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span> vertex insert success : <span style=color:#0000cf;font-weight:700>8</span>
</span></span><span style=display:flex><span> vertex insert failure : <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span> edge parse success : <span style=color:#0000cf;font-weight:700>6</span>
</span></span><span style=display:flex><span> edge parse failure : <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span> edge insert success : <span style=color:#0000cf;font-weight:700>6</span>
</span></span><span style=display:flex><span> edge insert failure : <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span>--------------------------------------------------
</span></span><span style=display:flex><span>meter metrics
</span></span><span style=display:flex><span> total <span style=color:#204a87>time</span> : 0.199s
</span></span><span style=display:flex><span> <span style=color:#204a87>read</span> <span style=color:#204a87>time</span> : 0.046s
</span></span><span style=display:flex><span> load <span style=color:#204a87>time</span> : 0.153s
</span></span><span style=display:flex><span> vertex load <span style=color:#204a87>time</span> : 0.077s
</span></span><span style=display:flex><span> vertex load rate<span style=color:#ce5c00;font-weight:700>(</span>vertices/s<span style=color:#ce5c00;font-weight:700>)</span> : <span style=color:#0000cf;font-weight:700>103</span>
</span></span><span style=display:flex><span> edge load <span style=color:#204a87>time</span> : 0.112s
</span></span><span style=display:flex><span> edge load rate<span style=color:#ce5c00;font-weight:700>(</span>edges/s<span style=color:#ce5c00;font-weight:700>)</span> : <span style=color:#0000cf;font-weight:700>53</span>
</span></span></code></pre></div><p>也可以使用 <code>curl</code> 或者 <code>hubble</code>观察导入结果,此处以 <code>curl</code> 为例:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>&gt; curl <span style=color:#4e9a06>&#34;http://localhost:8080/graphs/hugegraph/graph/vertices&#34;</span> <span style=color:#000;font-weight:700>|</span> gunzip
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;vertices&#34;</span>:<span style=color:#ce5c00;font-weight:700>[{</span><span style=color:#4e9a06>&#34;id&#34;</span>:1,<span style=color:#4e9a06>&#34;label&#34;</span>:<span style=color:#4e9a06>&#34;software&#34;</span>,<span style=color:#4e9a06>&#34;type&#34;</span>:<span style=color:#4e9a06>&#34;vertex&#34;</span>,<span style=color:#4e9a06>&#34;properties&#34;</span>:<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span>:<span style=color:#4e9a06>&#34;lop&#34;</span>,<span style=color:#4e9a06>&#34;lang&#34;</span>:<span style=color:#4e9a06>&#34;java&#34;</span>,<span style=color:#4e9a06>&#34;price&#34;</span>:328.0<span style=color:#ce5c00;font-weight:700>}}</span>,<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;id&#34;</span>:2,<span style=color:#4e9a06>&#34;label&#34;</span>:<span style=color:#4e9a06>&#34;software&#34;</span>,<span style=color:#4e9a06>&#34;type&#34;</span>:<span style=color:#4e9a06>&#34;vertex&#34;</span>,<span style=color:#4e9a06>&#34;properties&#34;</span>:<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span>:<span style=color:#4e9a06>&#34;ripple&#34;</span>,<span style=color:#4e9a06>&#34;lang&#34;</span>:<span style=color:#4e9a06>&#34;java&#34;</span>,<span style=color:#4e9a06>&#34;price&#34;</span>:199.0<span style=color:#ce5c00;font-weight:700>}}</span>,<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;id&#34;</span>:<span style=color:#4e9a06>&#34;1:tom&#34;</span>,<span style=color:#4e9a06>&#34;label&#34;</span>:<span style=color:#4e9a06>&#34;person&#34;</span>,<span style=color:#4e9a06>&#34;type&#34;</span>:<span style=color:#4e9a06>&#34;vertex&#34;</span>,<span style=color:#4e9a06>&#34;properties&#34;</span>:<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span>:<span style=color:#4e9a06>&#34;tom&#34;</span><span style=color:#ce5c00;font-weight:700>}}</span>,<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;id&#34;</span>:<span style=color:#4e9a06>&#34;1:josh&#34;</span>,<span style=color:#4e9a06>&#34;label&#34;</span>:<span style=color:#4e9a06>&#34;person&#34;</span>,<span style=color:#4e9a06>&#34;type&#34;</span>:<span style=color:#4e9a06>&#34;vertex&#34;</span>,<span style=color:#4e9a06>&#34;properties&#34;</span>:<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span>:<span style=color:#4e9a06>&#34;josh&#34;</span>,<span style=color:#4e9a06>&#34;age&#34;</span>:32,<span style=color:#4e9a06>&#34;city&#34;</span>:<span style=color:#4e9a06>&#34;Beijing&#34;</span><span style=color:#ce5c00;font-weight:700>}}</span>,<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;id&#34;</span>:<span style=color:#4e9a06>&#34;1:marko&#34;</span>,<span style=color:#4e9a06>&#34;label&#34;</span>:<span style=color:#4e9a06>&#34;person&#34;</span>,<span style=color:#4e9a06>&#34;type&#34;</span>:<span style=color:#4e9a06>&#34;vertex&#34;</span>,<span style=color:#4e9a06>&#34;properties&#34;</span>:<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span>:<span style=color:#4e9a06>&#34;marko&#34;</span>,<span style=color:#4e9a06>&#34;age&#34;</span>:29,<span style=color:#4e9a06>&#34;city&#34;</span>:<span style=color:#4e9a06>&#34;Beijing&#34;</span><span style=color:#ce5c00;font-weight:700>}}</span>,<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;id&#34;</span>:<span style=color:#4e9a06>&#34;1:peter&#34;</span>,<span style=color:#4e9a06>&#34;label&#34;</span>:<span style=color:#4e9a06>&#34;person&#34;</span>,<span style=color:#4e9a06>&#34;type&#34;</span>:<span style=color:#4e9a06>&#34;vertex&#34;</span>,<span style=color:#4e9a06>&#34;properties&#34;</span>:<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span>:<span style=color:#4e9a06>&#34;peter&#34;</span>,<span style=color:#4e9a06>&#34;age&#34;</span>:35,<span style=color:#4e9a06>&#34;city&#34;</span>:<span style=color:#4e9a06>&#34;Shanghai&#34;</span><span style=color:#ce5c00;font-weight:700>}}</span>,<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;id&#34;</span>:<span style=color:#4e9a06>&#34;1:vadas&#34;</span>,<span style=color:#4e9a06>&#34;label&#34;</span>:<span style=color:#4e9a06>&#34;person&#34;</span>,<span style=color:#4e9a06>&#34;type&#34;</span>:<span style=color:#4e9a06>&#34;vertex&#34;</span>,<span style=color:#4e9a06>&#34;properties&#34;</span>:<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span>:<span style=color:#4e9a06>&#34;vadas&#34;</span>,<span style=color:#4e9a06>&#34;age&#34;</span>:27,<span style=color:#4e9a06>&#34;city&#34;</span>:<span style=color:#4e9a06>&#34;Hongkong&#34;</span><span style=color:#ce5c00;font-weight:700>}}</span>,<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;id&#34;</span>:<span style=color:#4e9a06>&#34;1:li,nary&#34;</span>,<span style=color:#4e9a06>&#34;label&#34;</span>:<span style=color:#4e9a06>&#34;person&#34;</span>,<span style=color:#4e9a06>&#34;type&#34;</span>:<span style=color:#4e9a06>&#34;vertex&#34;</span>,<span style=color:#4e9a06>&#34;properties&#34;</span>:<span style=color:#ce5c00;font-weight:700>{</span><span style=color:#4e9a06>&#34;name&#34;</span>:<span style=color:#4e9a06>&#34;li,nary&#34;</span>,<span style=color:#4e9a06>&#34;age&#34;</span>:26,<span style=color:#4e9a06>&#34;city&#34;</span>:<span style=color:#4e9a06>&#34;Wu,han&#34;</span><span style=color:#ce5c00;font-weight:700>}}]}</span>
</span></span></code></pre></div><p>如果想检查边的导入结果,可以使用 <code>curl "http://localhost:8080/graphs/hugegraph/graph/edges" | gunzip</code></p><h5 id=452-进入-docker-容器进行导入>4.5.2 进入 docker 容器进行导入</h5><p>除了直接使用 <code>docker exec</code> 导入数据,我们也可以进入容器进行数据导入,基本流程与 <a href=#451-%E4%BD%BF%E7%94%A8-docker-exec-%E7%9B%B4%E6%8E%A5%E5%AF%BC%E5%85%A5%E6%95%B0%E6%8D%AE>4.5.1</a> 相同</p><p>使用 <code>docker exec -it loader bash</code>进入容器内部,并执行命令</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>sh bin/hugegraph-loader.sh -g hugegraph -f example/file/struct.json -s example/file/schema.groovy -h server -p <span style=color:#0000cf;font-weight:700>8080</span>
</span></span></code></pre></div><p>执行的结果如 <a href=#451-%E4%BD%BF%E7%94%A8-docker-exec-%E7%9B%B4%E6%8E%A5%E5%AF%BC%E5%85%A5%E6%95%B0%E6%8D%AE>4.5.1</a> 所示</p><h4 id=46-使用-spark-loader-导入>4.6 使用 spark-loader 导入</h4><blockquote><p>Spark 版本:Spark 3+,其他版本未测试。
HugeGraph Toolchain 版本:toolchain-1.0.0</p></blockquote><p><code>spark-loader</code> 的参数分为两部分,注意:因二者参数名缩写存在重合部分,请使用参数全称。两种参数之间无需保证先后顺序。</p><ul><li>hugegraph 参数(参考:<a href=https://hugegraph.apache.org/cn/docs/quickstart/hugegraph-loader/#341-%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E>hugegraph-loader 参数说明</a></li><li>Spark 任务提交参数(参考:<a href=https://spark.apache.org/docs/3.3.0/submitting-applications.html#content>Submitting Applications</a></li></ul><p>示例:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>sh bin/hugegraph-spark-loader.sh --master yarn <span style=color:#4e9a06>\
</span></span></span><span style=display:flex><span><span style=color:#4e9a06></span>--deploy-mode cluster --name spark-hugegraph-loader --file ./hugegraph.json <span style=color:#4e9a06>\
</span></span></span><span style=display:flex><span><span style=color:#4e9a06></span>--username admin --token admin --host xx.xx.xx.xx --port <span style=color:#0000cf;font-weight:700>8093</span> <span style=color:#4e9a06>\
</span></span></span><span style=display:flex><span><span style=color:#4e9a06></span>--graph graph-test --num-executors <span style=color:#0000cf;font-weight:700>6</span> --executor-cores <span style=color:#0000cf;font-weight:700>16</span> --executor-memory 15g
</span></span></code></pre></div></div><div class=td-content style=page-break-before:always><h1 id=pg-751ed124ec6dbb96d5e65c62dc9d4e85>3 - HugeGraph-Hubble Quick Start</h1><h3 id=1-hugegraph-hubble-概述>1 HugeGraph-Hubble 概述</h3><blockquote><p><strong>注:</strong> 当前版本的 Hubble 还没有添加 Auth/Login 相关界面和接口和单独防护, 在下一个 Release 版 (≥ 1.5) 会加入,
请留意避免把它暴露在公网环境或不受信任的网络中,以免引起相关 SEC 问题 (另外也可以使用 IP & 端口白名单 + HTTPS)</p></blockquote><p><strong>HugeGraph-Hubble</strong> 是 HugeGraph 的一站式可视化分析平台,平台涵盖了从数据建模,到数据快速导入,
再到数据的在线、离线分析、以及图的统一管理的全过程,实现了图应用的全流程向导式操作,旨在提升用户的使用流畅度,
降低用户的使用门槛,提供更为高效易用的使用体验。</p><p>平台主要包括以下模块:</p><h5 id=图管理>图管理</h5><p>图管理模块通过图的创建,连接平台与图数据,实现多图的统一管理,并实现图的访问、编辑、删除、查询操作。</p><h5 id=元数据建模>元数据建模</h5><p>元数据建模模块通过创建属性库,顶点类型,边类型,索引类型,实现图模型的构建与管理,平台提供两种模式,列表模式和图模式,可实时展示元数据模型,更加直观。同时还提供了跨图的元数据复用功能,省去相同元数据繁琐的重复创建过程,极大地提升建模效率,增强易用性。</p><h5 id=图分析>图分析</h5><p>通过输入图遍历语言 Gremlin 可实现图数据的高性能通用分析,并提供顶点的定制化多维路径查询等功能,提供 3 种图结果展示方式,包括:图形式、表格形式、Json 形式,多维度展示数据形态,满足用户使用的多种场景需求。提供运行记录及常用语句收藏等功能,实现图操作的可追溯,以及查询输入的复用共享,快捷高效。支持图数据的导出,导出格式为 Json 格式。</p><h5 id=任务管理>任务管理</h5><p>对于需要遍历全图的 Gremlin 任务,索引的创建与重建等耗时较长的异步任务,平台提供相应的任务管理功能,实现异步任务的统一的管理与结果查看。</p><h5 id=数据导入-beta>数据导入 (BETA)</h5><blockquote><p>注: 数据导入功能目前适合初步试用,正式数据导入请使用 <a href=/cn/docs/quickstart/hugegraph-loader>hugegraph-loader</a>, 性能/稳定性/功能全面许多</p></blockquote><p>数据导入是将用户的业务数据转化为图的顶点和边并插入图数据库中,平台提供了向导式的可视化导入模块,通过创建导入任务,
实现导入任务的管理及多个导入任务的并行运行,提高导入效能。进入导入任务后,只需跟随平台步骤提示,按需上传文件,填写内容,
就可轻松实现图数据的导入过程,同时支持断点续传,错误重试机制等,降低导入成本,提升效率。</p><h3 id=2-部署>2 部署</h3><p>有三种方式可以部署<code>hugegraph-hubble</code></p><ul><li>使用 docker (便于<strong>测试</strong>)</li><li>下载 toolchain 二进制包</li><li>源码编译</li></ul><h4 id=21-使用-docker-便于测试>2.1 使用 Docker (便于<strong>测试</strong>)</h4><blockquote><p><strong>特别注意</strong>: docker 模式下,若 hubble 和 server 在同一宿主机,hubble 页面中设置 server 的 <code>hostname</code> <strong>不能设置</strong><code>localhost/127.0.0.1</code>,因这会指向 hubble <strong>容器内部</strong>而非宿主机,导致无法连接到 server.</p><p>若 hubble 和 server 在同一 docker 网络下,<strong>推荐</strong>直接使用<code>container_name</code> (如下例的 <code>server</code>) 作为主机名。或者也可以使用 <strong>宿主机 IP</strong> 作为主机名,此时端口号为宿主机给 server 配置的端口</p></blockquote><p>我们可以使用 <code>docker run -itd --name=hubble -p 8088:8088 hugegraph/hubble</code> 快速启动 <a href=https://hub.docker.com/r/hugegraph/hubble>hubble</a>.</p><p>或者使用 docker-compose 启动 hubble,另外如果 hubble 和 server 在同一个 docker 网络下,可以使用 server 的 contain_name 进行访问,而不需要宿主机的 ip</p><p>使用<code>docker-compose up -d</code><code>docker-compose.yml</code>如下:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-yaml data-lang=yaml><span style=display:flex><span><span style=color:#204a87;font-weight:700>version</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#39;3&#39;</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#204a87;font-weight:700>services</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>server</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>image</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph/hugegraph</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>container_name</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>server</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>ports</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#0000cf;font-weight:700>8080</span><span style=color:#000;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>8080</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>hubble</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>image</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph/hubble</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>container_name</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hubble</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>ports</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span>- <span style=color:#0000cf;font-weight:700>8088</span><span style=color:#000;font-weight:700>:</span><span style=color:#0000cf;font-weight:700>8088</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span></code></pre></div><blockquote><p>注意:</p><ol><li><p><code>hugegraph-hubble</code> 的 docker 镜像是一个便捷发布版本,用于快速测试试用 hubble,并非<strong>ASF 官方发布物料包的方式</strong>。你可以从 <a href=https://infra.apache.org/release-distribution.html#dockerhub>ASF Release Distribution Policy</a> 中得到更多细节。</p></li><li><p><strong>生产环境</strong>推荐使用 <code>release tag</code>(如 <code>1.2.0</code>) 稳定版。使用 <code>latest</code> tag 默认对应 master 最新代码。</p></li></ol></blockquote><h4 id=22-下载-toolchain-二进制包>2.2 下载 toolchain 二进制包</h4><p><code>hubble</code>项目在<code>toolchain</code>项目中,首先下载<code>toolchain</code>的 tar 包</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>wget https://downloads.apache.org/incubator/hugegraph/<span style=color:#ce5c00;font-weight:700>{</span>version<span style=color:#ce5c00;font-weight:700>}</span>/apache-hugegraph-toolchain-incubating-<span style=color:#ce5c00;font-weight:700>{</span>version<span style=color:#ce5c00;font-weight:700>}</span>.tar.gz
</span></span><span style=display:flex><span>tar -xvf apache-hugegraph-toolchain-incubating-<span style=color:#ce5c00;font-weight:700>{</span>version<span style=color:#ce5c00;font-weight:700>}</span>.tar.gz
</span></span><span style=display:flex><span><span style=color:#204a87>cd</span> apache-hugegraph-toolchain-incubating-<span style=color:#ce5c00;font-weight:700>{</span>version<span style=color:#ce5c00;font-weight:700>}</span>.tar.gz/apache-hugegraph-hubble-incubating-<span style=color:#ce5c00;font-weight:700>{</span>version<span style=color:#ce5c00;font-weight:700>}</span>
</span></span></code></pre></div><p>运行<code>hubble</code></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/start-hubble.sh
</span></span></code></pre></div><p>随后我们可以看到</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell><span style=display:flex><span>starting HugeGraphHubble ..............timed out with http status <span style=color:#0000cf;font-weight:700>502</span>
</span></span><span style=display:flex><span>2023-08-30 20:38:34 <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> o.a.h.HugeGraphHubble <span style=color:#ce5c00;font-weight:700>[]</span> - Starting HugeGraphHubble v1.0.0 on cpu05 with PID xxx <span style=color:#ce5c00;font-weight:700>(</span>~/apache-hugegraph-toolchain-incubating-1.0.0/apache-hugegraph-hubble-incubating-1.0.0/lib/hubble-be-1.0.0.jar started by <span style=color:#000>$USER</span> in ~/apache-hugegraph-toolchain-incubating-1.0.0/apache-hugegraph-hubble-incubating-1.0.0<span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span>...
</span></span><span style=display:flex><span>2023-08-30 20:38:38 <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> c.z.h.HikariDataSource <span style=color:#ce5c00;font-weight:700>[]</span> - hugegraph-hubble-HikariCP - Start completed.
</span></span><span style=display:flex><span>2023-08-30 20:38:41 <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> o.a.c.h.Http11NioProtocol <span style=color:#ce5c00;font-weight:700>[]</span> - Starting ProtocolHandler <span style=color:#ce5c00;font-weight:700>[</span><span style=color:#4e9a06>&#34;http-nio-0.0.0.0-8088&#34;</span><span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span>2023-08-30 20:38:41 <span style=color:#ce5c00;font-weight:700>[</span>main<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>INFO <span style=color:#ce5c00;font-weight:700>]</span> o.a.h.HugeGraphHubble <span style=color:#ce5c00;font-weight:700>[]</span> - Started HugeGraphHubble in 7.379 seconds <span style=color:#ce5c00;font-weight:700>(</span>JVM running <span style=color:#204a87;font-weight:700>for</span> 8.499<span style=color:#ce5c00;font-weight:700>)</span>
</span></span></code></pre></div><p>然后使用浏览器访问 <code>ip:8088</code> 可看到<code>hubble</code>页面,通过<code>bin/stop-hubble.sh</code>则可以停止服务</p><h4 id=23-源码编译>2.3 源码编译</h4><p><strong>注意:</strong> 编译 hubble 需要用户本地环境有安装 <code>Nodejs V16.x</code><code>yarn</code> 环境</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>apt install curl build-essential
</span></span><span style=display:flex><span>curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh <span style=color:#000;font-weight:700>|</span> bash
</span></span><span style=display:flex><span><span style=color:#204a87>source</span> ~/.bashrc
</span></span><span style=display:flex><span>nvm install <span style=color:#0000cf;font-weight:700>16</span>
</span></span></code></pre></div><p>然后确认安装版本是否为 <code>16.x</code> (请注意过高的 Node 版本会产生冲突)</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>node -v
</span></span></code></pre></div><p>使用下列命令安装 <code>yarn</code></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>npm install -g yarn
</span></span></code></pre></div><p>下载 toolchain 源码包</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell><span style=display:flex><span>git clone https://github.com/apache/hugegraph-toolchain.git
</span></span></code></pre></div><p>编译<code>hubble</code>, 它依赖 loader 和 client, 编译时需提前构建这些依赖 (后续可跳)</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell><span style=display:flex><span><span style=color:#204a87>cd</span> incubator-hugegraph-toolchain
</span></span><span style=display:flex><span>sudo pip install -r hugegraph-hubble/hubble-dist/assembly/travis/requirements.txt
</span></span><span style=display:flex><span>mvn install -pl hugegraph-client,hugegraph-loader -am -Dmaven.javadoc.skip<span style=color:#ce5c00;font-weight:700>=</span><span style=color:#204a87>true</span> -DskipTests -ntp
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#204a87>cd</span> hugegraph-hubble
</span></span><span style=display:flex><span>mvn -e package -Dmaven.javadoc.skip<span style=color:#ce5c00;font-weight:700>=</span><span style=color:#204a87>true</span> -Dmaven.test.skip<span style=color:#ce5c00;font-weight:700>=</span><span style=color:#204a87>true</span> -ntp
</span></span><span style=display:flex><span><span style=color:#204a87>cd</span> apache-hugegraph-hubble-incubating*
</span></span></code></pre></div><p>启动<code>hubble</code></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/start-hubble.sh -d
</span></span></code></pre></div><h3 id=3平台使用流程>3 平台使用流程</h3><p>平台的模块使用流程如下:</p><div style=text-align:center><img src=/docs/images/images-hubble/2平台使用流程.png alt=image></div><h3 id=4平台使用说明>4 平台使用说明</h3><h4 id=41图管理>4.1 图管理</h4><h5 id=411图创建>4.1.1 图创建</h5><p>图管理模块下,点击【创建图】,通过填写图 ID、图名称、主机名、端口号、用户名、密码的信息,实现多图的连接。</p><div style=text-align:center><img src=/docs/images/images-hubble/311图创建.png alt=image></div><p>创建图填写内容如下:</p><div style=text-align:center><img src=/docs/images/images-hubble/311图创建2.png alt=image></div><blockquote><p><strong>注意</strong>:如果使用 docker 启动 <code>hubble</code>,且 <code>server</code><code>hubble</code> 位于同一宿主机,不能直接使用 <code>localhost/127.0.0.1</code> 作为主机名。如果 <code>hubble</code><code>server</code> 在同一 docker 网络下,则可以直接使用 container_name 作为主机名,端口则为 8080。或者也可以使用宿主机 ip 作为主机名,此时端口为宿主机为 server 配置的端口</p></blockquote><h5 id=412图访问>4.1.2 图访问</h5><p>实现图空间的信息访问,进入后,可进行图的多维查询分析、元数据管理、数据导入、算法分析等操作。</p><div style=text-align:center><img src=/docs/images/images-hubble/312图访问.png alt=image></div><h5 id=413图管理>4.1.3 图管理</h5><ol><li>用户通过对图的概览、搜索以及单图的信息编辑与删除,实现图的统一管理。</li><li>搜索范围:可对图名称和 ID 进行搜索。</li></ol><div style=text-align:center><img src=/docs/images/images-hubble/313图管理.png alt=image></div><h4 id=42元数据建模列表--图模式>4.2 元数据建模(列表 + 图模式)</h4><h5 id=421模块入口>4.2.1 模块入口</h5><p>左侧导航处:</p><div style=text-align:center><img src=/docs/images/images-hubble/321元数据入口.png alt=image></div><h5 id=422属性类型>4.2.2 属性类型</h5><h6 id=4221创建>4.2.2.1 创建</h6><ol><li>填写或选择属性名称、数据类型、基数,完成属性的创建。</li><li>创建的属性可作为顶点类型和边类型的属性。</li></ol><p>列表模式:</p><div style=text-align:center><img src=/docs/images/images-hubble/3221属性创建.png alt=image></div><p>图模式:</p><div style=text-align:center><img src=/docs/images/images-hubble/3221属性创建2.png alt=image></div><h6 id=4222复用>4.2.2.2 复用</h6><ol><li>平台提供【复用】功能,可直接复用其他图的元数据。</li><li>选择需要复用的图 ID,继续选择需要复用的属性,之后平台会进行是否冲突的校验,通过后,可实现元数据的复用。</li></ol><p>选择复用项:</p><div style=text-align:center><img src=/docs/images/images-hubble/3222属性复用.png alt=image></div><p>校验复用项:</p><div style=text-align:center><img src=/docs/images/images-hubble/3222属性复用2.png alt=image></div><h6 id=4223管理>4.2.2.3 管理</h6><ol><li>在属性列表中可进行单条删除或批量删除操作。</li></ol><h5 id=423顶点类型>4.2.3 顶点类型</h5><h6 id=4231创建>4.2.3.1 创建</h6><ol><li>填写或选择顶点类型名称、ID 策略、关联属性、主键属性,顶点样式、查询结果中顶点下方展示的内容,以及索引的信息:包括是否创建类型索引,及属性索引的具体内容,完成顶点类型的创建。</li></ol><p>列表模式:</p><center><img src=/docs/images/images-hubble/3231顶点创建.png alt=image></center><p>图模式:</p><center><img src=/docs/images/images-hubble/3231顶点创建2.png alt=image></center><h6 id=4232复用>4.2.3.2 复用</h6><ol><li>顶点类型的复用,会将此类型关联的属性和属性索引一并复用。</li><li>复用功能使用方法类似属性的复用,见 3.2.2.2。</li></ol><h6 id=4233管理>4.2.3.3 管理</h6><ol><li><p>可进行编辑操作,顶点样式、关联类型、顶点展示内容、属性索引可编辑,其余不可编辑。</p></li><li><p>可进行单条删除或批量删除操作。</p></li></ol><center><img src=/docs/images/images-hubble/3233顶点删除.png alt=image></center><h5 id=424边类型>4.2.4 边类型</h5><h6 id=4241创建>4.2.4.1 创建</h6><ol><li>填写或选择边类型名称、起点类型、终点类型、关联属性、是否允许多次连接、边样式、查询结果中边下方展示的内容,以及索引的信息:包括是否创建类型索引,及属性索引的具体内容,完成边类型的创建。</li></ol><p>列表模式:</p><center><img src=/docs/images/images-hubble/3241边创建.png alt=image></center><p>图模式:</p><center><img src=/docs/images/images-hubble/3241边创建2.png alt=image></center><h6 id=4242复用>4.2.4.2 复用</h6><ol><li>边类型的复用,会将此类型的起点类型、终点类型、关联的属性和属性索引一并复用。</li><li>复用功能使用方法类似属性的复用,见 3.2.2.2。</li></ol><h6 id=4243管理>4.2.4.3 管理</h6><ol><li>可进行编辑操作,边样式、关联属性、边展示内容、属性索引可编辑,其余不可编辑,同顶点类型。</li><li>可进行单条删除或批量删除操作。</li></ol><h5 id=425索引类型>4.2.5 索引类型</h5><p>展示顶点类型和边类型的顶点索引和边索引。</p><h4 id=43数据导入>4.3 数据导入</h4><blockquote><p><strong>注意</strong>:目前推荐使用 <a href=/cn/docs/quickstart/hugegraph-loader>hugegraph-loader</a> 进行正式数据导入,hubble 内置的导入用来做<strong>测试</strong><strong>简单上手</strong></p></blockquote><p>数据导入的使用流程如下:</p><center><img src=/docs/images/images-hubble/33导入流程.png alt=image></center><h5 id=431模块入口>4.3.1 模块入口</h5><p>左侧导航处:</p><center><img src=/docs/images/images-hubble/331导入入口.png alt=image></center><h5 id=432创建任务>4.3.2 创建任务</h5><ol><li>填写任务名称和备注(非必填),可以创建导入任务。</li><li>可创建多个导入任务,并行导入。</li></ol><center><img src=/docs/images/images-hubble/332创建任务.png alt=image></center><h5 id=433上传文件>4.3.3 上传文件</h5><ol><li>上传需要构图的文件,目前支持的格式为 CSV,后续会不断更新。</li><li>可同时上传多个文件。</li></ol><center><img src=/docs/images/images-hubble/333上传文件.png alt=image></center><h5 id=434设置数据映射>4.3.4 设置数据映射</h5><ol><li><p>对上传的文件分别设置数据映射,包括文件设置和类型设置</p></li><li><p>文件设置:勾选或填写是否包含表头、分隔符、编码格式等文件本身的设置内容,均设置默认值,无需手动填写</p></li><li><p>类型设置:</p><ol><li><p>顶点映射和边映射:</p><p>【顶点类型】 :选择顶点类型,并为其 ID 映射上传文件中列数据;</p><p>【边类型】:选择边类型,为其起点类型和终点类型的 ID 列映射上传文件的列数据;</p></li><li><p>映射设置:为选定的顶点类型的属性映射上传文件中的列数据,此处,若属性名称与文件的表头名称一致,可自动匹配映射属性,无需手动填选</p></li><li><p>完成设置后,显示设置列表,方可进行下一步操作,支持映射的新增、编辑、删除操作</p></li></ol></li></ol><p>设置映射的填写内容:</p><center><img src=/docs/images/images-hubble/334设置映射.png alt=image></center><p>映射列表:</p><center><img src=/docs/images/images-hubble/334设置映射2.png alt=image></center><h5 id=435导入数据>4.3.5 导入数据</h5><p>导入前需要填写导入设置参数,填写完成后,可开始向图库中导入数据</p><ol><li>导入设置</li></ol><ul><li>导入设置参数项如下图所示,均设置默认值,无需手动填写</li></ul><center><img src=/docs/images/images-hubble/335导入设置.png alt=image></center><ol start=2><li>导入详情</li></ol><ul><li>点击开始导入,开始文件的导入任务</li><li>导入详情中提供每个上传文件设置的映射类型、导入速度、导入的进度、耗时以及当前任务的具体状态,并可对每个任务进行暂停、继续、停止等操作</li><li>若导入失败,可查看具体原因</li></ul><center><img src=/docs/images/images-hubble/335导入详情.png alt=image></center><h4 id=44数据分析>4.4 数据分析</h4><h5 id=441模块入口>4.4.1 模块入口</h5><p>左侧导航处:</p><center><img src=/docs/images/images-hubble/341分析入口.png alt=image></center><h5 id=442多图切换>4.4.2 多图切换</h5><p>通过左侧切换入口,灵活切换多图的操作空间</p><center><img src=/docs/images/images-hubble/342多图切换.png alt=image></center><h5 id=443图分析与处理>4.4.3 图分析与处理</h5><p>HugeGraph 支持 Apache TinkerPop3 的图遍历查询语言 Gremlin,Gremlin 是一种通用的图数据库查询语言,通过输入 Gremlin 语句,点击执行,即可执行图数据的查询分析操作,并可实现顶点/边的创建及删除、顶点/边的属性修改等。</p><p>Gremlin 查询后,下方为图结果展示区域,提供 3 种图结果展示方式,分别为:【图模式】、【表格模式】、【Json 模式】。</p><p>支持缩放、居中、全屏、导出等操作。</p><p>【图模式】</p><center><img src=/docs/images/images-hubble/343图分析-图.png alt=image></center><p>【表格模式】</p><center><img src=/docs/images/images-hubble/343图分析-表格.png alt=image></center><p>【Json 模式】</p><center><img src=/docs/images/images-hubble/343图分析-json.png alt=image></center><h5 id=444数据详情>4.4.4 数据详情</h5><p>点击顶点/边实体,可查看顶点/边的数据详情,包括:顶点/边类型,顶点 ID,属性及对应值,拓展图的信息展示维度,提高易用性。</p><h5 id=445图结果的多维路径查询>4.4.5 图结果的多维路径查询</h5><p>除了全局的查询外,可针对查询结果中的顶点进行深度定制化查询以及隐藏操作,实现图结果的定制化挖掘。</p><p>右击顶点,出现顶点的菜单入口,可进行展示、查询、隐藏等操作。</p><ul><li>展开:点击后,展示与选中点关联的顶点。</li><li>查询:通过选择与选中点关联的边类型及边方向,在此条件下,再选择其属性及相应筛选规则,可实现定制化的路径展示。</li><li>隐藏:点击后,隐藏选中点及与之关联的边。</li></ul><p>双击顶点,也可展示与选中点关联的顶点。</p><center><img src=/docs/images/images-hubble/345定制路径查询.png alt=image></center><h5 id=446新增顶点边>4.4.6 新增顶点/边</h5><h6 id=4461新增顶点>4.4.6.1 新增顶点</h6><p>在图区可通过两个入口,动态新增顶点,如下:</p><ol><li>点击图区面板,出现添加顶点入口</li><li>点击右上角的操作栏中的首个图标</li></ol><p>通过选择或填写顶点类型、ID 值、属性信息,完成顶点的增加。</p><p>入口如下:</p><center><img src=/docs/images/images-hubble/346新增顶点.png alt=image></center><p>添加顶点内容如下:</p><center><img src=/docs/images/images-hubble/346新增顶点2.png alt=image></center><h6 id=4462新增边>4.4.6.2 新增边</h6><p>右击图结果中的顶点,可增加该点的出边或者入边。</p><h5 id=447执行记录与收藏的查询>4.4.7 执行记录与收藏的查询</h5><ol><li>图区下方记载每次查询记录,包括:查询时间、执行类型、内容、状态、耗时、以及【收藏】和【加载】操作,实现图执行的全方位记录,有迹可循,并可对执行内容快速加载复用</li><li>提供语句的收藏功能,可对常用语句进行收藏操作,方便高频语句快速调用</li></ol><center><img src=/docs/images/images-hubble/347收藏.png alt=image></center><h4 id=45任务管理>4.5 任务管理</h4><h5 id=451模块入口>4.5.1 模块入口</h5><p>左侧导航处:</p><center><img src=/docs/images/images-hubble/351任务管理入口.png alt=image></center><h5 id=452任务管理>4.5.2 任务管理</h5><ol><li>提供异步任务的统一的管理与结果查看,异步任务包括 4 类,分别为:</li></ol><ul><li>gremlin:Gremlin 任务务</li><li>algorithm:OLAP 算法任务务</li><li>remove_schema:删除元数据</li><li>rebuild_index:重建索引</li></ul><ol start=2><li>列表显示当前图的异步任务信息,包括:任务 ID,任务名称,任务类型,创建时间,耗时,状态,操作,实现对异步任务的管理。</li><li>支持对任务类型和状态进行筛选</li><li>支持搜索任务 ID 和任务名称</li><li>可对异步任务进行删除或批量删除操作</li></ol><center><img src=/docs/images/images-hubble/352任务列表.png alt=image></center><h5 id=453gremlin-异步任务>4.5.3 Gremlin 异步任务</h5><p>1.创建任务</p><ul><li>数据分析模块,目前支持两种 Gremlin 操作,Gremlin 查询和 Gremlin 任务;若用户切换到 Gremlin 任务,点击执行后,在异步任务中心会建立一条异步任务;
2.任务提交</li><li>任务提交成功后,图区部分返回提交结果和任务 ID
3.任务详情</li><li>提供【查看】入口,可跳转到任务详情查看当前任务具体执行情况跳转到任务中心后,直接显示当前执行的任务行</li></ul><center><img src=/docs/images/images-hubble/353gremlin任务.png alt=image></center><p>点击查看入口,跳转到任务管理列表,如下:</p><center><img src=/docs/images/images-hubble/353gremlin任务2.png alt=image></center><p>4.查看结果</p><ul><li>结果通过 json 形式展示</li></ul><h5 id=454olap-算法任务>4.5.4 OLAP 算法任务</h5><p>Hubble 上暂未提供可视化的 OLAP 算法执行,可调用 RESTful API 进行 OLAP 类算法任务,在任务管理中通过 ID 找到相应任务,查看进度与结果等。</p><h5 id=455删除元数据重建索引>4.5.5 删除元数据、重建索引</h5><p>1.创建任务</p><ul><li>在元数据建模模块中,删除元数据时,可建立删除元数据的异步任务</li></ul><center><img src=/docs/images/images-hubble/355删除元数据.png alt=image></center><ul><li>在编辑已有的顶点/边类型操作中,新增索引时,可建立创建索引的异步任务</li></ul><center><img src=/docs/images/images-hubble/355构建索引.png alt=image></center><p>2.任务详情</p><ul><li>确认/保存后,可跳转到任务中心查看当前任务的详情</li></ul><center><img src=/docs/images/images-hubble/355任务详情.png alt=image></center></div><div class=td-content style=page-break-before:always><h1 id=pg-405910066a042ce44a1c5798042ab119>4 - HugeGraph-AI Quick Start</h1><h3 id=1-hugegraph-ai-概述>1 HugeGraph-AI 概述</h3><p>hugegraph-ai 旨在探索 HugeGraph 与人工智能(AI)的融合,包括与大模型结合的应用,与图机器学习组件的集成等,为开发者在项目中利用 HugeGraph
的 AI 能力提供全面支持。</p><h3 id=2-环境要求>2 环境要求</h3><ul><li>python 3.8+</li><li>hugegraph 1.0.0+</li></ul><h3 id=3-准备工作>3 准备工作</h3><ul><li>启动 HugeGraph 数据库,你可以通过 Docker 来实现。请参考这个<a href=https://hub.docker.com/r/hugegraph/hugegraph>链接</a>获取指引。</li><li>启动 gradio 交互式 demo,你可以通过以下命令启动,启动后打开 <a href=http://127.0.0.1:8001>http://127.0.0.1:8001</a></li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#8f5902;font-style:italic># ${PROJECT_ROOT_DIR} 为 hugegraph-ai 的根目录,需要自行配置</span>
</span></span><span style=display:flex><span><span style=color:#204a87>export</span> <span style=color:#000>PYTHONPATH</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#4e9a06>${</span><span style=color:#000>PROJECT_ROOT_DIR</span><span style=color:#4e9a06>}</span>/hugegraph-llm/src:<span style=color:#4e9a06>${</span><span style=color:#000>PROJECT_ROOT_DIR</span><span style=color:#4e9a06>}</span>/hugegraph-python-client/src
</span></span><span style=display:flex><span>python3 ./hugegraph-llm/src/hugegraph_llm/utils/gradio_demo.py
</span></span></code></pre></div><ul><li>配置 HugeGraph 数据库连接信息和 LLM 模型信息,可以通过两种方式配置:<ol><li>配置 <code>./hugegraph-llm/src/config/config.ini</code> 文件</li><li>在 gradio 中,分别完成 LLM 和 HugeGraph 的配置后,点击 <code>Initialize configs</code>,将返回初始化后的完整配置文件。如图所示:
<img src=/docs/images/gradio-config.png alt="gradio 配置"></li></ol></li><li>离线下载 NLTK stopwords</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>python3 ./hugegraph_llm/operators/common_op/nltk_helper.py
</span></span></code></pre></div><h3 id=4-使用说明>4 使用说明</h3><h4 id=41-通过-llm-在-hugegraph-中构建知识图谱>4.1 通过 LLM 在 HugeGraph 中构建知识图谱</h4><h5 id=411-通过-gradio-交互式界面构建知识图谱>4.1.1 通过 gradio 交互式界面构建知识图谱</h5><ul><li>参数说明:<ul><li>Text: 输入的文本。</li><li>Schema:接受以下两种类型的文本:<ul><li>用户定义的 JSON 格式模式。</li><li>指定 HugeGraph 图实例的名称,它将自动提取图的模式。</li></ul></li><li>Disambiguate word sense:是否进行词义消除歧义。</li><li>Commit to hugegraph:是否将构建的知识图谱提交到 HugeGraph 服务器</li></ul></li></ul><p><img src=/docs/images/gradio-kg.png alt="gradio 配置"></p><h5 id=412-通过代码构建知识图谱>4.1.2 通过代码构建知识图谱</h5><ul><li>完整代码</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#204a87;font-weight:700>from</span> <span style=color:#000>hugegraph_llm.llms.init_llm</span> <span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>LLMs</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>from</span> <span style=color:#000>hugegraph_llm.operators.kg_construction_task</span> <span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>KgBuilder</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#000>llm</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>LLMs</span><span style=color:#000;font-weight:700>()</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>get_llm</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span><span style=color:#000>builder</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>KgBuilder</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>llm</span><span style=color:#000;font-weight:700>)</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>(</span>
</span></span><span style=display:flex><span> <span style=color:#000>builder</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>import_schema</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>from_hugegraph</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#4e9a06>&#34;test_graph&#34;</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>extract_triples</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>TEXT</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>disambiguate_word_sense</span><span style=color:#000;font-weight:700>()</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>commit_to_hugegraph</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>run</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>)</span>
</span></span></code></pre></div><ul><li>时序图
<img src=/docs/images/kg-uml.png alt="gradio 配置"></li></ul><ol><li>初始化:初始化 LLMs 实例,获取 LLM,然后创建图谱构建的任务实例 <code>KgBuilder</code>,KgBuilder 中定义了多个 operator,用户可以根据需求自由组合达到目的。(tip: <code>print_result()</code> 可以在控制台打印每一步输出的结果,不影响整体执行逻辑)</li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#000>llm</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>LLMs</span><span style=color:#000;font-weight:700>()</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>get_llm</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span><span style=color:#000>builder</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>KgBuilder</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>llm</span><span style=color:#000;font-weight:700>)</span>
</span></span></code></pre></div><ol start=2><li>导入 Schema:使用 <code>import_schema</code> 方法导入,支持三种模式:<ul><li>从 HugeGraph 实例导入,指定 HugeGraph 图实例的名称,它将自动提取图的模式。</li><li>从用户定义的模式导入,接受用户定义的 JSON 格式模式。</li><li>从提取结果导入(即将发布)</li></ul></li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#8f5902;font-style:italic># Import schema from a HugeGraph instance</span>
</span></span><span style=display:flex><span><span style=color:#000>builder</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>import_schema</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>from_hugegraph</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#4e9a06>&#34;test_graph&#34;</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># Import schema from user-defined schema</span>
</span></span><span style=display:flex><span><span style=color:#000>builder</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>import_schema</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>from_user_defined</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#4e9a06>&#34;xxx&#34;</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># Import schema from an extraction result</span>
</span></span><span style=display:flex><span><span style=color:#000>builder</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>import_schema</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>from_extraction</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#4e9a06>&#34;xxx&#34;</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span></code></pre></div><ol start=3><li>提取三元组:使用 <code>extract_triples</code> 方法从文本中提取三元组。</li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#000>TEXT</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#4e9a06>&#34;Meet Sarah, a 30-year-old attorney, and her roommate, James, whom she&#39;s shared a home with since 2010.&#34;</span>
</span></span><span style=display:flex><span><span style=color:#000>builder</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>extract_triples</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>TEXT</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span></code></pre></div><ol start=4><li>消除词义歧义:使用 <code>disambiguate_word_sense</code> 方法消除词义歧义。</li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#000>builder</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>disambiguate_word_sense</span><span style=color:#000;font-weight:700>()</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span></code></pre></div><ol start=5><li>提交到 HugeGraph:使用 <code>commit_to_hugegraph</code> 方法提交构建的知识图谱到 HugeGraph 实例。</li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#000>builder</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>commit_to_hugegraph</span><span style=color:#000;font-weight:700>()</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span></code></pre></div><ol start=6><li>运行:使用 <code>run</code> 方法执行上述操作。</li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#000>builder</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>run</span><span style=color:#000;font-weight:700>()</span>
</span></span></code></pre></div><h4 id=42-基于-hugegraph-的检索增强生成rag>4.2 基于 HugeGraph 的检索增强生成(RAG)</h4><h5 id=411-通过-gradio-交互问答>4.1.1 通过 gradio 交互问答</h5><ol><li>首先点击 <code>Initialize HugeGraph test data</code> 按钮,初始化 HugeGraph 数据。
<img src=/docs/images/gradio-rag-1.png alt="gradio 配置"></li><li>然后点击 <code>Retrieval augmented generation</code> 按钮,生成问题的答案。
<img src=/docs/images/gradio-rag-2.png alt="gradio 配置"></li></ol><h5 id=412-通过代码构建-graph-rag>4.1.2 通过代码构建 Graph RAG</h5><ul><li>完整代码</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#000>graph_rag</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>GraphRAG</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span><span style=color:#000>result</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000;font-weight:700>(</span>
</span></span><span style=display:flex><span> <span style=color:#000>graph_rag</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>extract_keyword</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>text</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#4e9a06>&#34;Tell me about Al Pacino.&#34;</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>query_graph_for_rag</span><span style=color:#000;font-weight:700>(</span>
</span></span><span style=display:flex><span> <span style=color:#000>max_deep</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#0000cf;font-weight:700>2</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#000>max_items</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#0000cf;font-weight:700>30</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>synthesize_answer</span><span style=color:#000;font-weight:700>()</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>run</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>verbose</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#204a87;font-weight:700>True</span><span style=color:#000;font-weight:700>)</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>)</span>
</span></span></code></pre></div><ol><li>extract_keyword: 提取关键词, 并进行近义词扩展</li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#000>graph_rag</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>extract_keyword</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>text</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#4e9a06>&#34;Tell me about Al Pacino.&#34;</span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span></code></pre></div><ol start=2><li>query_graph_for_rag: 从 HugeGraph 中检索对应的关键词,及其多度的关联关系<ul><li>max_deep: hugegraph 检索的最大深度</li><li>max_items: hugegraph 最大返回结果数</li></ul></li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#000>graph_rag</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>query_graph_for_rag</span><span style=color:#000;font-weight:700>(</span>
</span></span><span style=display:flex><span> <span style=color:#000>max_deep</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#0000cf;font-weight:700>2</span><span style=color:#000;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#000>max_items</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#0000cf;font-weight:700>30</span>
</span></span><span style=display:flex><span><span style=color:#000;font-weight:700>)</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span></code></pre></div><ol start=3><li>synthesize_answer: 针对提问,汇总结果,组织语言回答问题。</li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#000>graph_rag</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>synthesize_answer</span><span style=color:#000;font-weight:700>()</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_result</span><span style=color:#000;font-weight:700>()</span>
</span></span></code></pre></div><ol start=4><li>run: 执行上述操作。</li></ol><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-python data-lang=python><span style=display:flex><span><span style=color:#000>graph_rag</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>run</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>verbose</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#204a87;font-weight:700>True</span><span style=color:#000;font-weight:700>)</span>
</span></span></code></pre></div></div><div class=td-content style=page-break-before:always><h1 id=pg-9cbf1b01e876dc8cdc2da1c17759eed3>5 - HugeGraph-Client Quick Start</h1><h3 id=1-hugegraph-client-概述>1 HugeGraph-Client 概述</h3><p><a href=https://github.com/apache/hugegraph-toolchain>HugeGraph-Client</a> 向 HugeGraph-Server 发出 HTTP 请求,获取并解析 Server 的执行结果。
提供了 Java/Go/<a href=https://github.com/apache/incubator-hugegraph-ai/tree/main/hugegraph-python-client>Python</a> 版,
用户可以使用 <a href=/cn/docs/clients/hugegraph-client>Client-API</a> 编写代码操作 HugeGraph,比如元数据和图数据的增删改查,或者执行 gremlin 语句等。
后文主要是 Java 使用示例 (其他语言 SDK 可参考对应 <code>READEME</code> 页面)</p><blockquote><p>现在已经支持基于 Go 语言的 HugeGraph <a href=https://github.com/apache/incubator-hugegraph-toolchain/blob/master/hugegraph-client-go/README.md>Client SDK</a> (version >=1.2.0)</p></blockquote><h3 id=2-环境要求>2 环境要求</h3><ul><li>java 11 (兼容 java 8)</li><li>maven 3.5+</li></ul><h3 id=3-使用流程>3 使用流程</h3><p>使用 HugeGraph-Client 的基本步骤如下:</p><ul><li>新建Eclipse/ IDEA Maven 项目;</li><li>在 pom 文件中添加 HugeGraph-Client 依赖;</li><li>创建类,调用 HugeGraph-Client 接口;</li></ul><p>详细使用过程见下节完整示例。</p><h3 id=4-完整示例>4 完整示例</h3><h4 id=41-新建-maven-工程>4.1 新建 Maven 工程</h4><p>可以选择 Eclipse 或者 Intellij Idea 创建工程:</p><ul><li><a href=http://www.vogella.com/tutorials/EclipseMaven/article.html>Eclipse 新建 Maven 工程</a></li><li><a href=https://vaadin.com/docs/-/part/framework/getting-started/getting-started-idea.html>Intellij Idea 创建 maven 工程</a></li></ul><h4 id=42-添加-hugegraph-client-依赖>4.2 添加 hugegraph-client 依赖</h4><p>添加 hugegraph-client 依赖</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-xml data-lang=xml><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>&lt;dependencies&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&lt;dependency&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&lt;groupId&gt;</span>org.apache.hugegraph<span style=color:#204a87;font-weight:700>&lt;/groupId&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&lt;artifactId&gt;</span>hugegraph-client<span style=color:#204a87;font-weight:700>&lt;/artifactId&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#8f5902;font-style:italic>&lt;!-- Update to the latest release version --&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&lt;version&gt;</span>1.3.0<span style=color:#204a87;font-weight:700>&lt;/version&gt;</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>&lt;/dependency&gt;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>&lt;/dependencies&gt;</span>
</span></span></code></pre></div><blockquote><p>注:Graph 所有组件版本号均保持一致</p></blockquote><h4 id=43-example>4.3 Example</h4><h5 id=431-singleexample>4.3.1 SingleExample</h5><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-java data-lang=java><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>java.io.IOException</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>java.util.Iterator</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>java.util.List</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.driver.GraphManager</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.driver.GremlinManager</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.driver.HugeClient</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.driver.SchemaManager</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.structure.constant.T</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.structure.graph.Edge</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.structure.graph.Path</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.structure.graph.Vertex</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.structure.gremlin.Result</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.structure.gremlin.ResultSet</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>public</span> <span style=color:#204a87;font-weight:700>class</span> <span style=color:#000>SingleExample</span> <span style=color:#ce5c00;font-weight:700>{</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>public</span> <span style=color:#204a87;font-weight:700>static</span> <span style=color:#204a87;font-weight:700>void</span> <span style=color:#000>main</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>String</span><span style=color:#ce5c00;font-weight:700>[]</span> <span style=color:#000>args</span><span style=color:#ce5c00;font-weight:700>)</span> <span style=color:#204a87;font-weight:700>throws</span> <span style=color:#000>IOException</span> <span style=color:#ce5c00;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#8f5902;font-style:italic>// If connect failed will throw a exception.
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span> <span style=color:#000>HugeClient</span> <span style=color:#000>hugeClient</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>HugeClient</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>builder</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;http://localhost:8080&#34;</span><span style=color:#ce5c00;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;hugegraph&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>build</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>SchemaManager</span> <span style=color:#000>schema</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>hugeClient</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>schema</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asInt</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asDouble</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asDate</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asInt</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>vertexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>primaryKeys</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>vertexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>primaryKeys</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;personByCity&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>onV</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>secondary</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;personByAgeAndCity&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>onV</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>secondary</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;softwareByPrice&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>onV</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>range</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>edgeLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>sourceLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>targetLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>edgeLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>sourceLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>targetLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;createdByDate&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>onE</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>secondary</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;createdByWeight&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>onE</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>range</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knowsByWeight&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>onE</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>range</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>GraphManager</span> <span style=color:#000>graph</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>hugeClient</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>graph</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>marko</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>graph</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addVertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>T</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>LABEL</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;marko&#34;</span><span style=color:#ce5c00;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>29</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;Beijing&#34;</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>vadas</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>graph</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addVertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>T</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>LABEL</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;vadas&#34;</span><span style=color:#ce5c00;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>27</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;Hongkong&#34;</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>lop</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>graph</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addVertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>T</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>LABEL</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;lop&#34;</span><span style=color:#ce5c00;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;java&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>328</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>josh</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>graph</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addVertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>T</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>LABEL</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;josh&#34;</span><span style=color:#ce5c00;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>32</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;Beijing&#34;</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>ripple</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>graph</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addVertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>T</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>LABEL</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;ripple&#34;</span><span style=color:#ce5c00;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;java&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>199</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>peter</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>graph</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addVertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>T</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>LABEL</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;peter&#34;</span><span style=color:#ce5c00;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>35</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;city&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;Shanghai&#34;</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>marko</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addEdge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>vadas</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;2016-01-10&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>0</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>5</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>marko</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addEdge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>josh</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;2013-02-20&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>1</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>0</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>marko</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addEdge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>lop</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;2017-12-10&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>0</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>4</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>josh</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addEdge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>lop</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;2009-11-11&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>0</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>4</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>josh</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addEdge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>ripple</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;2017-12-10&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>1</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>0</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>peter</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addEdge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>lop</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;2017-03-24&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;weight&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>0</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>2</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>GremlinManager</span> <span style=color:#000>gremlin</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>hugeClient</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>gremlin</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;==== Path ====&#34;</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>ResultSet</span> <span style=color:#000>resultSet</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>gremlin</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>gremlin</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;g.V().outE().path()&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>execute</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>Iterator</span><span style=color:#ce5c00;font-weight:700>&lt;</span><span style=color:#000>Result</span><span style=color:#ce5c00;font-weight:700>&gt;</span> <span style=color:#000>results</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>resultSet</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>iterator</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>results</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>forEachRemaining</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>result</span> <span style=color:#ce5c00;font-weight:700>-&gt;</span> <span style=color:#ce5c00;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>result</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>getObject</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>getClass</span><span style=color:#ce5c00;font-weight:700>());</span>
</span></span><span style=display:flex><span> <span style=color:#000>Object</span> <span style=color:#000>object</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>result</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>getObject</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>if</span> <span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>object</span> <span style=color:#204a87;font-weight:700>instanceof</span> <span style=color:#000>Vertex</span><span style=color:#ce5c00;font-weight:700>)</span> <span style=color:#ce5c00;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(((</span><span style=color:#000>Vertex</span><span style=color:#ce5c00;font-weight:700>)</span> <span style=color:#000>object</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>id</span><span style=color:#ce5c00;font-weight:700>());</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>}</span> <span style=color:#204a87;font-weight:700>else</span> <span style=color:#204a87;font-weight:700>if</span> <span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>object</span> <span style=color:#204a87;font-weight:700>instanceof</span> <span style=color:#000>Edge</span><span style=color:#ce5c00;font-weight:700>)</span> <span style=color:#ce5c00;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(((</span><span style=color:#000>Edge</span><span style=color:#ce5c00;font-weight:700>)</span> <span style=color:#000>object</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>id</span><span style=color:#ce5c00;font-weight:700>());</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>}</span> <span style=color:#204a87;font-weight:700>else</span> <span style=color:#204a87;font-weight:700>if</span> <span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>object</span> <span style=color:#204a87;font-weight:700>instanceof</span> <span style=color:#000>Path</span><span style=color:#ce5c00;font-weight:700>)</span> <span style=color:#ce5c00;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#000>List</span><span style=color:#ce5c00;font-weight:700>&lt;</span><span style=color:#000>Object</span><span style=color:#ce5c00;font-weight:700>&gt;</span> <span style=color:#000>elements</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#ce5c00;font-weight:700>((</span><span style=color:#000>Path</span><span style=color:#ce5c00;font-weight:700>)</span> <span style=color:#000>object</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>objects</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>elements</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>forEach</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>element</span> <span style=color:#ce5c00;font-weight:700>-&gt;</span> <span style=color:#ce5c00;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>element</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>getClass</span><span style=color:#ce5c00;font-weight:700>());</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>element</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>});</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>}</span> <span style=color:#204a87;font-weight:700>else</span> <span style=color:#ce5c00;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>object</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>}</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>});</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>hugeClient</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>close</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>}</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>}</span>
</span></span></code></pre></div><h5 id=432-batchexample>4.3.2 BatchExample</h5><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-java data-lang=java><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>java.util.ArrayList</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>java.util.List</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.driver.GraphManager</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.driver.HugeClient</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.driver.SchemaManager</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.structure.graph.Edge</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>import</span> <span style=color:#000>org.apache.hugegraph.structure.graph.Vertex</span><span style=color:#ce5c00;font-weight:700>;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#204a87;font-weight:700>public</span> <span style=color:#204a87;font-weight:700>class</span> <span style=color:#000>BatchExample</span> <span style=color:#ce5c00;font-weight:700>{</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>public</span> <span style=color:#204a87;font-weight:700>static</span> <span style=color:#204a87;font-weight:700>void</span> <span style=color:#000>main</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>String</span><span style=color:#ce5c00;font-weight:700>[]</span> <span style=color:#000>args</span><span style=color:#ce5c00;font-weight:700>)</span> <span style=color:#ce5c00;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#8f5902;font-style:italic>// If connect failed will throw a exception.
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span> <span style=color:#000>HugeClient</span> <span style=color:#000>hugeClient</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>HugeClient</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>builder</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;http://localhost:8080&#34;</span><span style=color:#ce5c00;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;hugegraph&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>build</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>SchemaManager</span> <span style=color:#000>schema</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>hugeClient</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>schema</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asInt</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asText</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asDate</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>propertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>asInt</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>().</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>vertexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>primaryKeys</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>vertexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>nullableKeys</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>append</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>vertexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>primaryKeys</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;softwareByPrice&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>onV</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>range</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>edgeLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>link</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>edgeLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>link</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>properties</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>indexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;createdByDate&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>onE</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>by</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>secondary</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>ifNotExist</span><span style=color:#ce5c00;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>create</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#8f5902;font-style:italic>// get schema object by name
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>getPropertyKey</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>));</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>getVertexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>));</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>getEdgeLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#ce5c00;font-weight:700>));</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>getIndexLabel</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;createdByDate&#34;</span><span style=color:#ce5c00;font-weight:700>));</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#8f5902;font-style:italic>// list all schema objects
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>getPropertyKeys</span><span style=color:#ce5c00;font-weight:700>());</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>getVertexLabels</span><span style=color:#ce5c00;font-weight:700>());</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>getEdgeLabels</span><span style=color:#ce5c00;font-weight:700>());</span>
</span></span><span style=display:flex><span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>schema</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>getIndexLabels</span><span style=color:#ce5c00;font-weight:700>());</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>GraphManager</span> <span style=color:#000>graph</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>hugeClient</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>graph</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>marko</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Vertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;marko&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>29</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>vadas</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Vertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;vadas&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>27</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>lop</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Vertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;lop&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;java&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>328</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>josh</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Vertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;josh&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>32</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>ripple</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Vertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;software&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;ripple&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;lang&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;java&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;price&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>199</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Vertex</span> <span style=color:#000>peter</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Vertex</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;person&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;name&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;peter&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;age&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#000>35</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>Edge</span> <span style=color:#000>markoKnowsVadas</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Edge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>source</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>marko</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>target</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>vadas</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;2016-01-10&#34;</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Edge</span> <span style=color:#000>markoKnowsJosh</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Edge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;knows&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>source</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>marko</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>target</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>josh</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;2013-02-20&#34;</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Edge</span> <span style=color:#000>markoCreateLop</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Edge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>source</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>marko</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>target</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>lop</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;2017-12-10&#34;</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Edge</span> <span style=color:#000>joshCreateRipple</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Edge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>source</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>josh</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>target</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>ripple</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;2017-12-10&#34;</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Edge</span> <span style=color:#000>joshCreateLop</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Edge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>source</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>josh</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>target</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>lop</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#4e9a06>&#34;2009-11-11&#34;</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>Edge</span> <span style=color:#000>peterCreateLop</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Edge</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;created&#34;</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>source</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>peter</span><span style=color:#ce5c00;font-weight:700>).</span><span style=color:#c4a000>target</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>lop</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>property</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#4e9a06>&#34;date&#34;</span><span style=color:#ce5c00;font-weight:700>,</span>
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#34;2017-03-24&#34;</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>List</span><span style=color:#ce5c00;font-weight:700>&lt;</span><span style=color:#000>Vertex</span><span style=color:#ce5c00;font-weight:700>&gt;</span> <span style=color:#000>vertices</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>ArrayList</span><span style=color:#ce5c00;font-weight:700>&lt;&gt;();</span>
</span></span><span style=display:flex><span> <span style=color:#000>vertices</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>marko</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>vertices</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>vadas</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>vertices</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>lop</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>vertices</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>josh</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>vertices</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>ripple</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>vertices</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>peter</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>List</span><span style=color:#ce5c00;font-weight:700>&lt;</span><span style=color:#000>Edge</span><span style=color:#ce5c00;font-weight:700>&gt;</span> <span style=color:#000>edges</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>ArrayList</span><span style=color:#ce5c00;font-weight:700>&lt;&gt;();</span>
</span></span><span style=display:flex><span> <span style=color:#000>edges</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>markoKnowsVadas</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>edges</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>markoKnowsJosh</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>edges</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>markoCreateLop</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>edges</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>joshCreateRipple</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>edges</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>joshCreateLop</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>edges</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>add</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>peterCreateLop</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>vertices</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>graph</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addVertices</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>vertices</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>vertices</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>forEach</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>vertex</span> <span style=color:#ce5c00;font-weight:700>-&gt;</span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>vertex</span><span style=color:#ce5c00;font-weight:700>));</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>edges</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>graph</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>addEdges</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>edges</span><span style=color:#ce5c00;font-weight:700>,</span> <span style=color:#204a87;font-weight:700>false</span><span style=color:#ce5c00;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000>edges</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>forEach</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>edge</span> <span style=color:#ce5c00;font-weight:700>-&gt;</span> <span style=color:#000>System</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>out</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>println</span><span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>edge</span><span style=color:#ce5c00;font-weight:700>));</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>hugeClient</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#c4a000>close</span><span style=color:#ce5c00;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>}</span>
</span></span><span style=display:flex><span><span style=color:#ce5c00;font-weight:700>}</span>
</span></span></code></pre></div><h3 id=44-运行-example>4.4 运行 Example</h3><p>运行 Example 之前需要启动 Server,
启动过程见<a href=/cn/docs/quickstart/hugegraph-server>HugeGraph-Server Quick Start</a></p><h3 id=45-详细-api-说明>4.5 详细 API 说明</h3><p>示例说明见<a href=/cn/docs/clients/hugegraph-client>HugeGraph-Client 基本 API 介绍</a></p></div><div class=td-content style=page-break-before:always><h1 id=pg-06d4cae527789fcda01ebf4e48c6559f>6 - HugeGraph-Tools Quick Start</h1><h3 id=1-hugegraph-tools概述>1 HugeGraph-Tools概述</h3><p>HugeGraph-Tools 是 HugeGraph 的自动化部署、管理和备份/还原组件。</p><h3 id=2-获取-hugegraph-tools>2 获取 HugeGraph-Tools</h3><p>有两种方式可以获取 HugeGraph-Tools:(它被包含子 Toolchain 中)</p><ul><li>下载二进制tar包</li><li>下载源码编译安装</li></ul><h4 id=21-下载二进制tar包>2.1 下载二进制tar包</h4><p>下载最新版本的 HugeGraph-Toolchain 包, 然后进入 tools 子目录</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>wget https://downloads.apache.org/incubator/hugegraph/1.0.0/apache-hugegraph-toolchain-incubating-1.0.0.tar.gz
</span></span><span style=display:flex><span>tar zxf *hugegraph*.tar.gz
</span></span></code></pre></div><h4 id=22-下载源码编译安装>2.2 下载源码编译安装</h4><p>源码编译前请确保安装了wget命令</p><p>下载最新版本的 HugeGraph-Toolchain 源码包, 然后根目录编译或者单独编译 tool 子模块:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#8f5902;font-style:italic># 1. get from github</span>
</span></span><span style=display:flex><span>git clone https://github.com/apache/hugegraph-toolchain.git
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># 2. get from direct (e.g. here is 1.0.0, please choose the latest version)</span>
</span></span><span style=display:flex><span>wget https://downloads.apache.org/incubator/hugegraph/1.0.0/apache-hugegraph-toolchain-incubating-1.0.0-src.tar.gz
</span></span></code></pre></div><p>编译生成 tar 包:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#204a87>cd</span> hugegraph-tools
</span></span><span style=display:flex><span>mvn package -DskipTests
</span></span></code></pre></div><p>生成 tar 包 hugegraph-tools-${version}.tar.gz</p><h3 id=3-使用>3 使用</h3><h4 id=31-功能概览>3.1 功能概览</h4><p>解压后,进入 hugegraph-tools 目录,可以使用<code>bin/hugegraph</code>或者<code>bin/hugegraph help</code>来查看 usage 信息。主要分为:</p><ul><li>图管理类,graph-mode-set、graph-mode-get、graph-list、graph-get 和 graph-clear</li><li>异步任务管理类,task-list、task-get、task-delete、task-cancel 和 task-clear</li><li>Gremlin类,gremlin-execute 和 gremlin-schedule</li><li>备份/恢复类,backup、restore、migrate、schedule-backup 和 dump</li><li>安装部署类,deploy、clear、start-all 和 stop-all</li></ul><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>Usage: hugegraph <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>command<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span><span style=color:#204a87>command</span> options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span></code></pre></div><h5 id=32-options-全局变量>3.2 [options]-全局变量</h5><p><code>options</code>是 HugeGraph-Tools 的全局变量,可以在 hugegraph-tools/bin/hugegraph 中配置,包括:</p><ul><li>&ndash;graph,HugeGraph-Tools 操作的图的名字,默认值是 hugegraph</li><li>&ndash;url,HugeGraph-Server 的服务地址,默认是 http://127.0.0.1:8080</li><li>&ndash;user,当 HugeGraph-Server 开启认证时,传递用户名</li><li>&ndash;password,当 HugeGraph-Server 开启认证时,传递用户的密码</li><li>&ndash;timeout,连接 HugeGraph-Server 时的超时时间,默认是 30s</li><li>&ndash;trust-store-file,证书文件的路径,当 &ndash;url 使用 https 时,HugeGraph-Client 使用的 truststore 文件,默认为空,代表使用 hugegraph-tools 内置的 truststore 文件 conf/hugegraph.truststore</li><li>&ndash;trust-store-password,证书文件的密码,当 &ndash;url 使用 https 时,HugeGraph-Client 使用的 truststore 的密码,默认为空,代表使用 hugegraph-tools 内置的 truststore 文件的密码</li></ul><p>上述全局变量,也可以通过环境变量来设置。一种方式是在命令行使用 export 设置临时环境变量,在该命令行关闭之前均有效</p><table><thead><tr><th>全局变量</th><th>环境变量</th><th>示例</th></tr></thead><tbody><tr><td>&ndash;url</td><td>HUGEGRAPH_URL</td><td>export HUGEGRAPH_URL=http://127.0.0.1:8080</td></tr><tr><td>&ndash;graph</td><td>HUGEGRAPH_GRAPH</td><td>export HUGEGRAPH_GRAPH=hugegraph</td></tr><tr><td>&ndash;user</td><td>HUGEGRAPH_USERNAME</td><td>export HUGEGRAPH_USERNAME=admin</td></tr><tr><td>&ndash;password</td><td>HUGEGRAPH_PASSWORD</td><td>export HUGEGRAPH_PASSWORD=test</td></tr><tr><td>&ndash;timeout</td><td>HUGEGRAPH_TIMEOUT</td><td>export HUGEGRAPH_TIMEOUT=30</td></tr><tr><td>&ndash;trust-store-file</td><td>HUGEGRAPH_TRUST_STORE_FILE</td><td>export HUGEGRAPH_TRUST_STORE_FILE=/tmp/trust-store</td></tr><tr><td>&ndash;trust-store-password</td><td>HUGEGRAPH_TRUST_STORE_PASSWORD</td><td>export HUGEGRAPH_TRUST_STORE_PASSWORD=xxxx</td></tr></tbody></table><p>另一种方式是在 bin/hugegraph 脚本中设置环境变量:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#8f5902;font-style:italic>#!/bin/bash
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># Set environment here if needed</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>#export HUGEGRAPH_URL=</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>#export HUGEGRAPH_GRAPH=</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>#export HUGEGRAPH_USERNAME=</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>#export HUGEGRAPH_PASSWORD=</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>#export HUGEGRAPH_TIMEOUT=</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>#export HUGEGRAPH_TRUST_STORE_FILE=</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic>#export HUGEGRAPH_TRUST_STORE_PASSWORD=</span>
</span></span></code></pre></div><h5 id=33-图管理类graph-mode-setgraph-mode-getgraph-listgraph-get和graph-clear>3.3 图管理类,graph-mode-set、graph-mode-get、graph-list、graph-get和graph-clear</h5><ul><li>graph-mode-set,设置图的 restore mode<ul><li>&ndash;graph-mode 或者 -m,必填项,指定将要设置的模式,合法值包括 [NONE, RESTORING, MERGING, LOADING]</li></ul></li><li>graph-mode-get,获取图的 restore mode</li><li>graph-list,列出某个 HugeGraph-Server 中全部的图</li><li>graph-get,获取某个图及其存储后端类型</li><li>graph-clear,清除某个图的全部 schema 和 data<ul><li>&ndash;confirm-message 或者 -c,必填项,删除确认信息,需要手动输入,二次确认防止误删,&ldquo;I&rsquo;m sure to delete all data&rdquo;,包括双引号</li></ul></li></ul><blockquote><p>当需要把备份的图原样恢复到一个新的图中的时候,需要先将图模式设置为 RESTORING 模式;当需要将备份的图合并到已存在的图中时,需要先将图模式设置为 MERGING 模式。</p></blockquote><h5 id=34-异步任务管理类task-listtask-get和task-delete>3.4 异步任务管理类,task-list、task-get和task-delete</h5><ul><li>task-list,列出某个图中的异步任务,可以根据任务的状态过滤<ul><li>&ndash;status,选填项,指定要查看的任务的状态,即按状态过滤任务</li><li>&ndash;limit,选填项,指定要获取的任务的数目,默认为 -1,意思为获取全部符合条件的任务</li></ul></li><li>task-get,获取某个异步任务的详细信息<ul><li>&ndash;task-id,必填项,指定异步任务的 ID</li></ul></li><li>task-delete,删除某个异步任务的信息<ul><li>&ndash;task-id,必填项,指定异步任务的 ID</li></ul></li><li>task-cancel,取消某个异步任务的执行<ul><li>&ndash;task-id,要取消的异步任务的 ID</li></ul></li><li>task-clear,清理完成的异步任务<ul><li>&ndash;force,选填项,设置时,表示清理全部异步任务,未执行完成的先取消,然后清除所有异步任务。默认只清理已完成的异步任务</li></ul></li></ul><h5 id=35-gremlin类gremlin-execute和gremlin-schedule>3.5 Gremlin类,gremlin-execute和gremlin-schedule</h5><ul><li>gremlin-execute,发送 Gremlin 语句到 HugeGraph-Server 来执行查询或修改操作,同步执行,结束后返回结果<ul><li>&ndash;file 或者 -f,指定要执行的脚本文件,UTF-8编码,与 &ndash;script 互斥</li><li>&ndash;script 或者 -s,指定要执行的脚本字符串,与 &ndash;file 互斥</li><li>&ndash;aliases 或者 -a,Gremlin 别名设置,格式为:key1=value1,key2=value2,&mldr;</li><li>&ndash;bindings 或者 -b,Gremlin 绑定设置,格式为:key1=value1,key2=value2,&mldr;</li><li>&ndash;language 或者 -l,Gremlin 脚本的语言,默认为 gremlin-groovy</li></ul><blockquote><p>&ndash;file 和 &ndash;script 二者互斥,必须设置其中之一</p></blockquote></li><li>gremlin-schedule,发送 Gremlin 语句到 HugeGraph-Server 来执行查询或修改操作,异步执行,任务提交后立刻返回异步任务id<ul><li>&ndash;file 或者 -f,指定要执行的脚本文件,UTF-8编码,与 &ndash;script 互斥</li><li>&ndash;script 或者 -s,指定要执行的脚本字符串,与 &ndash;file 互斥</li><li>&ndash;bindings 或者 -b,Gremlin 绑定设置,格式为:key1=value1,key2=value2,&mldr;</li><li>&ndash;language 或者 -l,Gremlin 脚本的语言,默认为 gremlin-groovy</li></ul><blockquote><p>&ndash;file 和 &ndash;script 二者互斥,必须设置其中之一</p></blockquote></li></ul><h5 id=36-备份恢复类>3.6 备份/恢复类</h5><ul><li>backup,将某张图中的 schema 或者 data 备份到 HugeGraph 系统之外,以 JSON 形式存在本地磁盘或者 HDFS<ul><li>&ndash;format,备份的格式,可选值包括 [json, text],默认为 json</li><li>&ndash;all-properties,是否备份顶点/边全部的属性,仅在 &ndash;format 为 text 是有效,默认 false</li><li>&ndash;label,要备份的顶点/边的类型,仅在 &ndash;format 为 text 是有效,只有备份顶点或者边的时候有效</li><li>&ndash;properties,要备份的顶点/边的属性,逗号分隔,仅在 &ndash;format 为 text 是有效,只有备份顶点或者边的时候有效</li><li>&ndash;compress,备份时是否压缩数据,默认为 true</li><li>&ndash;directory 或者 -d,存储 schema 或者 data 的目录,本地目录时,默认为&rsquo;./{graphName}&rsquo;,HDFS 时,默认为 &lsquo;{fs.default.name}/{graphName}&rsquo;</li><li>&ndash;huge-types 或者 -t,要备份的数据类型,逗号分隔,可选值为 &lsquo;all&rsquo; 或者 一个或多个 [vertex,edge,vertex_label,edge_label,property_key,index_label] 的组合,&lsquo;all&rsquo; 代表全部6种类型,即顶点、边和所有schema</li><li>&ndash;log 或者 -l,指定日志目录,默认为当前目录</li><li>&ndash;retry,指定失败重试次数,默认为 3</li><li>&ndash;split-size 或者 -s,指定在备份时对顶点或者边分块的大小,默认为 1048576</li><li>-D,用 -Dkey=value 的模式指定动态参数,用来备份数据到 HDFS 时,指定 HDFS 的配置项,例如:-Dfs.default.name=hdfs://localhost:9000</li></ul></li><li>restore,将 JSON 格式存储的 schema 或者 data 恢复到一个新图中(RESTORING 模式)或者合并到已存在的图中(MERGING 模式)<ul><li>&ndash;directory 或者 -d,存储 schema 或者 data 的目录,本地目录时,默认为&rsquo;./{graphName}&rsquo;,HDFS 时,默认为 &lsquo;{fs.default.name}/{graphName}&rsquo;</li><li>&ndash;clean,是否在恢复图完成后删除 &ndash;directory 指定的目录,默认为 false</li><li>&ndash;huge-types 或者 -t,要恢复的数据类型,逗号分隔,可选值为 &lsquo;all&rsquo; 或者 一个或多个 [vertex,edge,vertex_label,edge_label,property_key,index_label] 的组合,&lsquo;all&rsquo; 代表全部6种类型,即顶点、边和所有schema</li><li>&ndash;log 或者 -l,指定日志目录,默认为当前目录</li><li>&ndash;retry,指定失败重试次数,默认为 3</li><li>-D,用 -Dkey=value 的模式指定动态参数,用来从 HDFS 恢复图时,指定 HDFS 的配置项,例如:-Dfs.default.name=hdfs://localhost:9000</li></ul><blockquote><p>只有当 &ndash;format 为 json 执行 backup 时,才可以使用 restore 命令恢复</p></blockquote></li><li>migrate, 将当前连接的图迁移至另一个 HugeGraphServer 中<ul><li>&ndash;target-graph,目标图的名字,默认为 hugegraph</li><li>&ndash;target-url,目标图所在的 HugeGraphServer,默认为 http://127.0.0.1:8081</li><li>&ndash;target-username,访问目标图的用户名</li><li>&ndash;target-password,访问目标图的密码</li><li>&ndash;target-timeout,访问目标图的超时时间</li><li>&ndash;target-trust-store-file,访问目标图使用的 truststore 文件</li><li>&ndash;target-trust-store-password,访问目标图使用的 truststore 的密码</li><li>&ndash;directory 或者 -d,迁移过程中,存储源图的 schema 或者 data 的目录,本地目录时,默认为&rsquo;./{graphName}&rsquo;,HDFS 时,默认为 &lsquo;{fs.default.name}/{graphName}&rsquo;</li><li>&ndash;huge-types 或者 -t,要迁移的数据类型,逗号分隔,可选值为 &lsquo;all&rsquo; 或者 一个或多个 [vertex,edge,vertex_label,edge_label,property_key,index_label] 的组合,&lsquo;all&rsquo; 代表全部6种类型,即顶点、边和所有schema</li><li>&ndash;log 或者 -l,指定日志目录,默认为当前目录</li><li>&ndash;retry,指定失败重试次数,默认为 3</li><li>&ndash;split-size 或者 -s,指定迁移过程中对源图进行备份时顶点或者边分块的大小,默认为 1048576</li><li>-D,用 -Dkey=value 的模式指定动态参数,用来在迁移图过程中需要备份数据到 HDFS 时,指定 HDFS 的配置项,例如:-Dfs.default.name=hdfs://localhost:9000</li><li>&ndash;graph-mode 或者 -m,将源图恢复到目标图时将目标图设置的模式,合法值包括 [RESTORING, MERGING]</li><li>&ndash;keep-local-data,是否保留在迁移图的过程中产生的源图的备份,默认为 false,即默认迁移图结束后不保留产生的源图备份</li></ul></li><li>schedule-backup,周期性对图执行备份操作,并保留一定数目的最新备份(目前仅支持本地文件系统)<ul><li>&ndash;directory 或者 -d,必填项,指定备份数据的目录</li><li>&ndash;backup-num,选填项,指定保存的最新的备份的数目,默认为 3</li><li>&ndash;interval,选填项,指定进行备份的周期,格式同 Linux crontab 格式</li></ul></li><li>dump,把整张图的顶点和边全部导出,默认以<code>vertex vertex-edge1 vertex-edge2...</code>JSON格式存储。
用户也可以自定义存储格式,只需要在<code>hugegraph-tools/src/main/java/com/baidu/hugegraph/formatter</code>
目录下实现一个继承自<code>Formatter</code>的类,例如<code>CustomFormatter</code>,使用时指定该类为formatter即可,例如
<code>bin/hugegraph dump -f CustomFormatter</code><ul><li>&ndash;formatter 或者 -f,指定使用的 formatter,默认为 JsonFormatter</li><li>&ndash;directory 或者 -d,存储 schema 或者 data 的目录,默认为当前目录</li><li>&ndash;log 或者 -l,指定日志目录,默认为当前目录</li><li>&ndash;retry,指定失败重试次数,默认为 3</li><li>&ndash;split-size 或者 -s,指定在备份时对顶点或者边分块的大小,默认为 1048576</li><li>-D,用 -Dkey=value 的模式指定动态参数,用来备份数据到 HDFS 时,指定 HDFS 的配置项,例如:-Dfs.default.name=hdfs://localhost:9000</li></ul></li></ul><h5 id=37-安装部署类>3.7 安装部署类</h5><ul><li>deploy,一键下载、安装和启动 HugeGraph-Server 和 HugeGraph-Studio<ul><li>-v,必填项,指明安装的 HugeGraph-Server 和 HugeGraph-Studio 的版本号,最新的是 0.9</li><li>-p,必填项,指定安装的 HugeGraph-Server 和 HugeGraph-Studio 目录</li><li>-u,选填项,指定下载 HugeGraph-Server 和 HugeGraph-Studio 压缩包的链接</li></ul></li><li>clear,清理 HugeGraph-Server 和 HugeGraph-Studio 目录和tar包<ul><li>-p,必填项,指定要清理的 HugeGraph-Server 和 HugeGraph-Studio 的目录</li></ul></li><li>start-all,一键启动 HugeGraph-Server 和 HugeGraph-Studio,并启动监控,服务死掉时自动拉起服务<ul><li>-v,必填项,指明要启动的 HugeGraph-Server 和 HugeGraph-Studio 的版本号,最新的是 0.9</li><li>-p,必填项,指定安装了 HugeGraph-Server 和 HugeGraph-Studio 的目录</li></ul></li><li>stop-all,一键关闭 HugeGraph-Server 和 HugeGraph-Studio</li></ul><blockquote><p>deploy命令中有可选参数 -u,提供时会使用指定的下载地址替代默认下载地址下载 tar 包,并且将地址写入<code>~/hugegraph-download-url-prefix</code>文件中;之后如果不指定地址时,会优先从<code>~/hugegraph-download-url-prefix</code>指定的地址下载 tar 包;如果 -u 和<code>~/hugegraph-download-url-prefix</code>都没有时,会从默认下载地址进行下载</p></blockquote><h5 id=38-具体命令参数>3.8 具体命令参数</h5><p>各子命令的具体参数如下:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>Usage: hugegraph <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span>command<span style=color:#ce5c00;font-weight:700>]</span> <span style=color:#ce5c00;font-weight:700>[</span><span style=color:#204a87>command</span> options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> --graph
</span></span><span style=display:flex><span> Name of graph
</span></span><span style=display:flex><span> Default: hugegraph
</span></span><span style=display:flex><span> --password
</span></span><span style=display:flex><span> Password of user
</span></span><span style=display:flex><span> --timeout
</span></span><span style=display:flex><span> Connection timeout
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>30</span>
</span></span><span style=display:flex><span> --trust-store-file
</span></span><span style=display:flex><span> The path of client truststore file used when https protocol is enabled
</span></span><span style=display:flex><span> --trust-store-password
</span></span><span style=display:flex><span> The password of the client truststore file used when the https protocol
</span></span><span style=display:flex><span> is enabled
</span></span><span style=display:flex><span> --url
</span></span><span style=display:flex><span> The URL of HugeGraph-Server
</span></span><span style=display:flex><span> Default: http://127.0.0.1:8080
</span></span><span style=display:flex><span> --user
</span></span><span style=display:flex><span> Name of user
</span></span><span style=display:flex><span> Commands:
</span></span><span style=display:flex><span> graph-list List all graphs
</span></span><span style=display:flex><span> Usage: graph-list
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> graph-get Get graph info
</span></span><span style=display:flex><span> Usage: graph-get
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> graph-clear Clear graph schema and data
</span></span><span style=display:flex><span> Usage: graph-clear <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> * --confirm-message, -c
</span></span><span style=display:flex><span> Confirm message of graph clear is <span style=color:#4e9a06>&#34;I&#39;m sure to delete all data&#34;</span>.
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>(</span>Note: include <span style=color:#4e9a06>&#34;&#34;</span><span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> graph-mode-set Set graph mode
</span></span><span style=display:flex><span> Usage: graph-mode-set <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> * --graph-mode, -m
</span></span><span style=display:flex><span> Graph mode, include: <span style=color:#ce5c00;font-weight:700>[</span>NONE, RESTORING, MERGING<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Possible Values: <span style=color:#ce5c00;font-weight:700>[</span>NONE, RESTORING, MERGING, LOADING<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> graph-mode-get Get graph mode
</span></span><span style=display:flex><span> Usage: graph-mode-get
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> task-list List tasks
</span></span><span style=display:flex><span> Usage: task-list <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> --limit
</span></span><span style=display:flex><span> Limit number, no limit <span style=color:#204a87;font-weight:700>if</span> not provided
</span></span><span style=display:flex><span> Default: -1
</span></span><span style=display:flex><span> --status
</span></span><span style=display:flex><span> Status of task
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> task-get Get task info
</span></span><span style=display:flex><span> Usage: task-get <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> * --task-id
</span></span><span style=display:flex><span> Task id
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> task-delete Delete task
</span></span><span style=display:flex><span> Usage: task-delete <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> * --task-id
</span></span><span style=display:flex><span> Task id
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> task-cancel Cancel task
</span></span><span style=display:flex><span> Usage: task-cancel <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> * --task-id
</span></span><span style=display:flex><span> Task id
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> task-clear Clear completed tasks
</span></span><span style=display:flex><span> Usage: task-clear <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> --force
</span></span><span style=display:flex><span> Force to clear all tasks, cancel all uncompleted tasks firstly,
</span></span><span style=display:flex><span> and delete all completed tasks
</span></span><span style=display:flex><span> Default: <span style=color:#204a87>false</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> gremlin-execute Execute Gremlin statements
</span></span><span style=display:flex><span> Usage: gremlin-execute <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> --aliases, -a
</span></span><span style=display:flex><span> Gremlin aliases, valid format is: <span style=color:#4e9a06>&#39;key1=value1,key2=value2...&#39;</span>
</span></span><span style=display:flex><span> Default: <span style=color:#ce5c00;font-weight:700>{}</span>
</span></span><span style=display:flex><span> --bindings, -b
</span></span><span style=display:flex><span> Gremlin bindings, valid format is: <span style=color:#4e9a06>&#39;key1=value1,key2=value2...&#39;</span>
</span></span><span style=display:flex><span> Default: <span style=color:#ce5c00;font-weight:700>{}</span>
</span></span><span style=display:flex><span> --file, -f
</span></span><span style=display:flex><span> Gremlin Script file to be executed, UTF-8 encoded, exclusive to
</span></span><span style=display:flex><span> --script
</span></span><span style=display:flex><span> --language, -l
</span></span><span style=display:flex><span> Gremlin script language
</span></span><span style=display:flex><span> Default: gremlin-groovy
</span></span><span style=display:flex><span> --script, -s
</span></span><span style=display:flex><span> Gremlin script to be executed, exclusive to --file
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> gremlin-schedule Execute Gremlin statements as asynchronous job
</span></span><span style=display:flex><span> Usage: gremlin-schedule <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> --bindings, -b
</span></span><span style=display:flex><span> Gremlin bindings, valid format is: <span style=color:#4e9a06>&#39;key1=value1,key2=value2...&#39;</span>
</span></span><span style=display:flex><span> Default: <span style=color:#ce5c00;font-weight:700>{}</span>
</span></span><span style=display:flex><span> --file, -f
</span></span><span style=display:flex><span> Gremlin Script file to be executed, UTF-8 encoded, exclusive to
</span></span><span style=display:flex><span> --script
</span></span><span style=display:flex><span> --language, -l
</span></span><span style=display:flex><span> Gremlin script language
</span></span><span style=display:flex><span> Default: gremlin-groovy
</span></span><span style=display:flex><span> --script, -s
</span></span><span style=display:flex><span> Gremlin script to be executed, exclusive to --file
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> backup Backup graph schema/data. If directory is on HDFS, use -D to
</span></span><span style=display:flex><span> <span style=color:#204a87>set</span> HDFS params. For exmaple:
</span></span><span style=display:flex><span> -Dfs.default.name<span style=color:#ce5c00;font-weight:700>=</span>hdfs://localhost:9000
</span></span><span style=display:flex><span> Usage: backup <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> --all-properties
</span></span><span style=display:flex><span> All properties to be backup flag
</span></span><span style=display:flex><span> Default: <span style=color:#204a87>false</span>
</span></span><span style=display:flex><span> --compress
</span></span><span style=display:flex><span> compress flag
</span></span><span style=display:flex><span> Default: <span style=color:#204a87>true</span>
</span></span><span style=display:flex><span> --directory, -d
</span></span><span style=display:flex><span> Directory of graph schema/data, default is <span style=color:#4e9a06>&#39;./{graphname}&#39;</span> in
</span></span><span style=display:flex><span> <span style=color:#204a87>local</span> file system or <span style=color:#4e9a06>&#39;{fs.default.name}/{graphname}&#39;</span> in HDFS
</span></span><span style=display:flex><span> --format
</span></span><span style=display:flex><span> File format, valid is <span style=color:#ce5c00;font-weight:700>[</span>json, text<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Default: json
</span></span><span style=display:flex><span> --huge-types, -t
</span></span><span style=display:flex><span> Type of schema/data. Concat with <span style=color:#4e9a06>&#39;,&#39;</span> <span style=color:#204a87;font-weight:700>if</span> more than one. <span style=color:#4e9a06>&#39;all&#39;</span> means
</span></span><span style=display:flex><span> all vertices, edges and schema, in other words, <span style=color:#4e9a06>&#39;all&#39;</span> equals with
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#39;vertex,edge,vertex_label,edge_label,property_key,index_label&#39;</span>
</span></span><span style=display:flex><span> Default: <span style=color:#ce5c00;font-weight:700>[</span>PROPERTY_KEY, VERTEX_LABEL, EDGE_LABEL, INDEX_LABEL, VERTEX, EDGE<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> --label
</span></span><span style=display:flex><span> Vertex or edge label, only valid when <span style=color:#204a87>type</span> is vertex or edge
</span></span><span style=display:flex><span> --log, -l
</span></span><span style=display:flex><span> Directory of log
</span></span><span style=display:flex><span> Default: ./logs
</span></span><span style=display:flex><span> --properties
</span></span><span style=display:flex><span> Vertex or edge properties to backup, only valid when <span style=color:#204a87>type</span> is
</span></span><span style=display:flex><span> vertex or edge
</span></span><span style=display:flex><span> Default: <span style=color:#ce5c00;font-weight:700>[]</span>
</span></span><span style=display:flex><span> --retry
</span></span><span style=display:flex><span> Retry times, default is <span style=color:#0000cf;font-weight:700>3</span>
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>3</span>
</span></span><span style=display:flex><span> --split-size, -s
</span></span><span style=display:flex><span> Split size of shard
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>1048576</span>
</span></span><span style=display:flex><span> -D
</span></span><span style=display:flex><span> HDFS config parameters
</span></span><span style=display:flex><span> Syntax: -Dkey<span style=color:#ce5c00;font-weight:700>=</span>value
</span></span><span style=display:flex><span> Default: <span style=color:#ce5c00;font-weight:700>{}</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> schedule-backup Schedule backup task
</span></span><span style=display:flex><span> Usage: schedule-backup <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> --backup-num
</span></span><span style=display:flex><span> The number of latest backups to keep
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>3</span>
</span></span><span style=display:flex><span> * --directory, -d
</span></span><span style=display:flex><span> The directory of backups stored
</span></span><span style=display:flex><span> --interval
</span></span><span style=display:flex><span> The interval of backup, format is: <span style=color:#4e9a06>&#34;a b c d e&#34;</span>. <span style=color:#4e9a06>&#39;a&#39;</span> means minute
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>(</span><span style=color:#0000cf;font-weight:700>0</span> - 59<span style=color:#ce5c00;font-weight:700>)</span>, <span style=color:#4e9a06>&#39;b&#39;</span> means hour <span style=color:#ce5c00;font-weight:700>(</span><span style=color:#0000cf;font-weight:700>0</span> - 23<span style=color:#ce5c00;font-weight:700>)</span>, <span style=color:#4e9a06>&#39;c&#39;</span> means day of month <span style=color:#ce5c00;font-weight:700>(</span><span style=color:#0000cf;font-weight:700>1</span> -
</span></span><span style=display:flex><span> 31<span style=color:#ce5c00;font-weight:700>)</span>, <span style=color:#4e9a06>&#39;d&#39;</span> means month <span style=color:#ce5c00;font-weight:700>(</span><span style=color:#0000cf;font-weight:700>1</span> - 12<span style=color:#ce5c00;font-weight:700>)</span>, <span style=color:#4e9a06>&#39;e&#39;</span> means day of week <span style=color:#ce5c00;font-weight:700>(</span><span style=color:#0000cf;font-weight:700>0</span> - 6<span style=color:#ce5c00;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#ce5c00;font-weight:700>(</span><span style=color:#000>Sunday</span><span style=color:#ce5c00;font-weight:700>=</span>0<span style=color:#ce5c00;font-weight:700>)</span>, <span style=color:#4e9a06>&#34;*&#34;</span> means all
</span></span><span style=display:flex><span> Default: <span style=color:#4e9a06>&#34;0 0 * * *&#34;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> dump Dump graph to files
</span></span><span style=display:flex><span> Usage: dump <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> --directory, -d
</span></span><span style=display:flex><span> Directory of graph schema/data, default is <span style=color:#4e9a06>&#39;./{graphname}&#39;</span> in
</span></span><span style=display:flex><span> <span style=color:#204a87>local</span> file system or <span style=color:#4e9a06>&#39;{fs.default.name}/{graphname}&#39;</span> in HDFS
</span></span><span style=display:flex><span> --formatter, -f
</span></span><span style=display:flex><span> Formatter to customize format of vertex/edge
</span></span><span style=display:flex><span> Default: JsonFormatter
</span></span><span style=display:flex><span> --log, -l
</span></span><span style=display:flex><span> Directory of log
</span></span><span style=display:flex><span> Default: ./logs
</span></span><span style=display:flex><span> --retry
</span></span><span style=display:flex><span> Retry times, default is <span style=color:#0000cf;font-weight:700>3</span>
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>3</span>
</span></span><span style=display:flex><span> --split-size, -s
</span></span><span style=display:flex><span> Split size of shard
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>1048576</span>
</span></span><span style=display:flex><span> -D
</span></span><span style=display:flex><span> HDFS config parameters
</span></span><span style=display:flex><span> Syntax: -Dkey<span style=color:#ce5c00;font-weight:700>=</span>value
</span></span><span style=display:flex><span> Default: <span style=color:#ce5c00;font-weight:700>{}</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> restore Restore graph schema/data. If directory is on HDFS, use -D to
</span></span><span style=display:flex><span> <span style=color:#204a87>set</span> HDFS params <span style=color:#204a87;font-weight:700>if</span> needed. For
</span></span><span style=display:flex><span> exmaple:-Dfs.default.name<span style=color:#ce5c00;font-weight:700>=</span>hdfs://localhost:9000
</span></span><span style=display:flex><span> Usage: restore <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> --clean
</span></span><span style=display:flex><span> Whether to remove the directory of graph data after restored
</span></span><span style=display:flex><span> Default: <span style=color:#204a87>false</span>
</span></span><span style=display:flex><span> --directory, -d
</span></span><span style=display:flex><span> Directory of graph schema/data, default is <span style=color:#4e9a06>&#39;./{graphname}&#39;</span> in
</span></span><span style=display:flex><span> <span style=color:#204a87>local</span> file system or <span style=color:#4e9a06>&#39;{fs.default.name}/{graphname}&#39;</span> in HDFS
</span></span><span style=display:flex><span> --huge-types, -t
</span></span><span style=display:flex><span> Type of schema/data. Concat with <span style=color:#4e9a06>&#39;,&#39;</span> <span style=color:#204a87;font-weight:700>if</span> more than one. <span style=color:#4e9a06>&#39;all&#39;</span> means
</span></span><span style=display:flex><span> all vertices, edges and schema, in other words, <span style=color:#4e9a06>&#39;all&#39;</span> equals with
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#39;vertex,edge,vertex_label,edge_label,property_key,index_label&#39;</span>
</span></span><span style=display:flex><span> Default: <span style=color:#ce5c00;font-weight:700>[</span>PROPERTY_KEY, VERTEX_LABEL, EDGE_LABEL, INDEX_LABEL, VERTEX, EDGE<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> --log, -l
</span></span><span style=display:flex><span> Directory of log
</span></span><span style=display:flex><span> Default: ./logs
</span></span><span style=display:flex><span> --retry
</span></span><span style=display:flex><span> Retry times, default is <span style=color:#0000cf;font-weight:700>3</span>
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>3</span>
</span></span><span style=display:flex><span> -D
</span></span><span style=display:flex><span> HDFS config parameters
</span></span><span style=display:flex><span> Syntax: -Dkey<span style=color:#ce5c00;font-weight:700>=</span>value
</span></span><span style=display:flex><span> Default: <span style=color:#ce5c00;font-weight:700>{}</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> migrate Migrate graph
</span></span><span style=display:flex><span> Usage: migrate <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> --directory, -d
</span></span><span style=display:flex><span> Directory of graph schema/data, default is <span style=color:#4e9a06>&#39;./{graphname}&#39;</span> in
</span></span><span style=display:flex><span> <span style=color:#204a87>local</span> file system or <span style=color:#4e9a06>&#39;{fs.default.name}/{graphname}&#39;</span> in HDFS
</span></span><span style=display:flex><span> --graph-mode, -m
</span></span><span style=display:flex><span> Mode used when migrating to target graph, include: <span style=color:#ce5c00;font-weight:700>[</span>RESTORING,
</span></span><span style=display:flex><span> MERGING<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Default: RESTORING
</span></span><span style=display:flex><span> Possible Values: <span style=color:#ce5c00;font-weight:700>[</span>NONE, RESTORING, MERGING, LOADING<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> --huge-types, -t
</span></span><span style=display:flex><span> Type of schema/data. Concat with <span style=color:#4e9a06>&#39;,&#39;</span> <span style=color:#204a87;font-weight:700>if</span> more than one. <span style=color:#4e9a06>&#39;all&#39;</span> means
</span></span><span style=display:flex><span> all vertices, edges and schema, in other words, <span style=color:#4e9a06>&#39;all&#39;</span> equals with
</span></span><span style=display:flex><span> <span style=color:#4e9a06>&#39;vertex,edge,vertex_label,edge_label,property_key,index_label&#39;</span>
</span></span><span style=display:flex><span> Default: <span style=color:#ce5c00;font-weight:700>[</span>PROPERTY_KEY, VERTEX_LABEL, EDGE_LABEL, INDEX_LABEL, VERTEX, EDGE<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> --keep-local-data
</span></span><span style=display:flex><span> Whether to keep the <span style=color:#204a87>local</span> directory of graph data after restored
</span></span><span style=display:flex><span> Default: <span style=color:#204a87>false</span>
</span></span><span style=display:flex><span> --log, -l
</span></span><span style=display:flex><span> Directory of log
</span></span><span style=display:flex><span> Default: ./logs
</span></span><span style=display:flex><span> --retry
</span></span><span style=display:flex><span> Retry times, default is <span style=color:#0000cf;font-weight:700>3</span>
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>3</span>
</span></span><span style=display:flex><span> --split-size, -s
</span></span><span style=display:flex><span> Split size of shard
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>1048576</span>
</span></span><span style=display:flex><span> --target-graph
</span></span><span style=display:flex><span> The name of target graph to migrate
</span></span><span style=display:flex><span> Default: hugegraph
</span></span><span style=display:flex><span> --target-password
</span></span><span style=display:flex><span> The password of target graph to migrate
</span></span><span style=display:flex><span> --target-timeout
</span></span><span style=display:flex><span> The timeout to connect target graph to migrate
</span></span><span style=display:flex><span> Default: <span style=color:#0000cf;font-weight:700>0</span>
</span></span><span style=display:flex><span> --target-trust-store-file
</span></span><span style=display:flex><span> The trust store file of target graph to migrate
</span></span><span style=display:flex><span> --target-trust-store-password
</span></span><span style=display:flex><span> The trust store password of target graph to migrate
</span></span><span style=display:flex><span> --target-url
</span></span><span style=display:flex><span> The url of target graph to migrate
</span></span><span style=display:flex><span> Default: http://127.0.0.1:8081
</span></span><span style=display:flex><span> --target-user
</span></span><span style=display:flex><span> The username of target graph to migrate
</span></span><span style=display:flex><span> -D
</span></span><span style=display:flex><span> HDFS config parameters
</span></span><span style=display:flex><span> Syntax: -Dkey<span style=color:#ce5c00;font-weight:700>=</span>value
</span></span><span style=display:flex><span> Default: <span style=color:#ce5c00;font-weight:700>{}</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> deploy Install HugeGraph-Server and HugeGraph-Studio
</span></span><span style=display:flex><span> Usage: deploy <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> * -p
</span></span><span style=display:flex><span> Install path of HugeGraph-Server and HugeGraph-Studio
</span></span><span style=display:flex><span> -u
</span></span><span style=display:flex><span> Download url prefix path of HugeGraph-Server and HugeGraph-Studio
</span></span><span style=display:flex><span> * -v
</span></span><span style=display:flex><span> Version of HugeGraph-Server and HugeGraph-Studio
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> start-all Start HugeGraph-Server and HugeGraph-Studio
</span></span><span style=display:flex><span> Usage: start-all <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> * -p
</span></span><span style=display:flex><span> Install path of HugeGraph-Server and HugeGraph-Studio
</span></span><span style=display:flex><span> * -v
</span></span><span style=display:flex><span> Version of HugeGraph-Server and HugeGraph-Studio
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> clear Clear HugeGraph-Server and HugeGraph-Studio
</span></span><span style=display:flex><span> Usage: clear <span style=color:#ce5c00;font-weight:700>[</span>options<span style=color:#ce5c00;font-weight:700>]</span>
</span></span><span style=display:flex><span> Options:
</span></span><span style=display:flex><span> * -p
</span></span><span style=display:flex><span> Install path of HugeGraph-Server and HugeGraph-Studio
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> stop-all Stop HugeGraph-Server and HugeGraph-Studio
</span></span><span style=display:flex><span> Usage: stop-all
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#204a87>help</span> Print usage
</span></span><span style=display:flex><span> Usage: <span style=color:#204a87>help</span>
</span></span></code></pre></div><h5 id=39-具体命令示例>3.9 具体命令示例</h5><h6 id=1-gremlin语句>1. gremlin语句</h6><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#8f5902;font-style:italic># 同步执行gremlin</span>
</span></span><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph gremlin-execute --script <span style=color:#4e9a06>&#39;g.V().count()&#39;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># 异步执行gremlin</span>
</span></span><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph gremlin-schedule --script <span style=color:#4e9a06>&#39;g.V().count()&#39;</span>
</span></span></code></pre></div><h6 id=2-查看task情况>2. 查看task情况</h6><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph task-list
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph task-list --limit <span style=color:#0000cf;font-weight:700>5</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph task-list --status success
</span></span></code></pre></div><h6 id=3-图模式查看和设置>3. 图模式查看和设置</h6><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph graph-mode-set -m RESTORING MERGING NONE
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph graph-mode-set -m RESTORING
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph graph-mode-get
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph graph-list
</span></span></code></pre></div><h6 id=4-清理图>4. 清理图</h6><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph graph-clear -c <span style=color:#4e9a06>&#34;I&#39;m sure to delete all data&#34;</span>
</span></span></code></pre></div><h6 id=5-图备份>5. 图备份</h6><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph backup -t all --directory ./backup-test
</span></span></code></pre></div><h6 id=6-周期性的备份>6. 周期性的备份</h6><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph --interval */2 * * * * schedule-backup -d ./backup-0.10.2
</span></span></code></pre></div><h6 id=7-图恢复>7. 图恢复</h6><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#8f5902;font-style:italic># 设置图模式</span>
</span></span><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph graph-mode-set -m RESTORING
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># 恢复图</span>
</span></span><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph restore -t all --directory ./backup-test
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># 恢复图模式</span>
</span></span><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph graph-mode-set -m NONE
</span></span></code></pre></div><h6 id=8-图迁移>8. 图迁移</h6><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>./bin/hugegraph --url http://127.0.0.1:8080 --graph hugegraph migrate --target-url http://127.0.0.1:8090 --target-graph hugegraph
</span></span></code></pre></div></div><div class=td-content style=page-break-before:always><h1 id=pg-e68a801476ae8ef5e45c79949a3a5e44>7 - HugeGraph-Computer Quick Start</h1><h2 id=1-hugegraph-computer-概述>1 HugeGraph-Computer 概述</h2><p><a href=https://github.com/apache/incubator-hugegraph-computer><code>HugeGraph-Computer</code></a> 是分布式图处理系统 (OLAP). 它是 <a href=https://kowshik.github.io/JPregel/pregel_paper.pdf>Pregel</a> 的一个实现. 它可以运行在 Kubernetes 上。</p><h3 id=特性>特性</h3><ul><li>支持分布式MPP图计算,集成HugeGraph作为图输入输出存储。</li><li>算法基于BSP(Bulk Synchronous Parallel)模型,通过多次并行迭代进行计算,每一次迭代都是一次超步。</li><li>自动内存管理。该框架永远不会出现 OOM(内存不足),因为如果它没有足够的内存来容纳所有数据,它会将一些数据拆分到磁盘。</li><li>边的部分或超级节点的消息可以在内存中,所以你永远不会丢失它。</li><li>您可以从 HDFS 或 HugeGraph 或任何其他系统加载数据。</li><li>您可以将结果输出到 HDFS 或 HugeGraph,或任何其他系统。</li><li>易于开发新算法。您只需要像在单个服务器中一样专注于仅顶点处理,而不必担心消息传输和内存存储管理。</li></ul><h2 id=2-依赖>2 依赖</h2><h3 id=21-安装-java-11-jdk-11>2.1 安装 Java 11 (JDK 11)</h3><p><strong>必须</strong>在 ≥ <code>Java 11</code> 的环境上启动 <code>Computer</code>,然后自行配置。</p><p><strong>在往下阅读之前务必执行 <code>java -version</code> 命令查看 jdk 版本</strong></p><h2 id=3-开始>3 开始</h2><h3 id=31-在本地运行-pagerank-算法>3.1 在本地运行 PageRank 算法</h3><blockquote><p>要使用 HugeGraph-Computer 运行算法,必须装有 Java 11 或更高版本。</p><p>还需要首先部署 HugeGraph-Server 和 <a href=https://etcd.io/docs/v3.5/quickstart/>Etcd</a>.</p></blockquote><p>有两种方式可以获取 HugeGraph-Computer:</p><ul><li>下载已编译的压缩包</li><li>克隆源码编译打包</li></ul><h4 id=311-下载已编译的压缩包>3.1.1 下载已编译的压缩包</h4><p>下载最新版本的 HugeGraph-Computer release 包:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>wget https://downloads.apache.org/incubator/hugegraph/<span style=color:#4e9a06>${</span><span style=color:#000>version</span><span style=color:#4e9a06>}</span>/apache-hugegraph-computer-incubating-<span style=color:#4e9a06>${</span><span style=color:#000>version</span><span style=color:#4e9a06>}</span>.tar.gz
</span></span><span style=display:flex><span>tar zxvf apache-hugegraph-computer-incubating-<span style=color:#4e9a06>${</span><span style=color:#000>version</span><span style=color:#4e9a06>}</span>.tar.gz -C hugegraph-computer
</span></span></code></pre></div><h4 id=312-克隆源码编译打包>3.1.2 克隆源码编译打包</h4><p>克隆最新版本的 HugeGraph-Computer 源码包:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>$ git clone https://github.com/apache/hugegraph-computer.git
</span></span></code></pre></div><p>编译生成tar包:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#204a87>cd</span> hugegraph-computer
</span></span><span style=display:flex><span>mvn clean package -DskipTests
</span></span></code></pre></div><h4 id=313-启动-master-节点>3.1.3 启动 master 节点</h4><blockquote><p>您可以使用 <code>-c</code> 参数指定配置文件, 更多computer 配置请看: <a href=/docs/config/config-computer#computer-config-options>Computer Config Options</a></p></blockquote><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#204a87>cd</span> hugegraph-computer
</span></span><span style=display:flex><span>bin/start-computer.sh -d <span style=color:#204a87>local</span> -r master
</span></span></code></pre></div><h4 id=314-启动-worker-节点>3.1.4 启动 worker 节点</h4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>bin/start-computer.sh -d <span style=color:#204a87>local</span> -r worker
</span></span></code></pre></div><h4 id=315-查询算法结果>3.1.5 查询算法结果</h4><p>2.5.1 为 server 启用 <code>OLAP</code> 索引查询</p><p>如果没有启用OLAP索引,则需要启用, 更多参考: <a href=/docs/clients/restful-api/graphs/#634-modify-graphs-read-mode-this-operation-requires-administrator-privileges>modify-graphs-read-mode</a></p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-http data-lang=http><span style=display:flex><span><span style=color:#a40000>PUT http://localhost:8080/graphs/hugegraph/graph_read_mode
</span></span></span><span style=display:flex><span><span style=color:#a40000>
</span></span></span><span style=display:flex><span><span style=color:#a40000>&#34;ALL&#34;
</span></span></span></code></pre></div><p>3.1.5.2 查询 <code>page_rank</code> 属性值:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>curl <span style=color:#4e9a06>&#34;http://localhost:8080/graphs/hugegraph/graph/vertices?page&amp;limit=3&#34;</span> <span style=color:#000;font-weight:700>|</span> gunzip
</span></span></code></pre></div><h3 id=32-在-kubernetes-中运行-pagerank-算法>3.2 在 Kubernetes 中运行 PageRank 算法</h3><blockquote><p>要使用 HugeGraph-Computer 运行算法,您需要先部署 HugeGraph-Server</p></blockquote><h4 id=321-安装-hugegraph-computer-crd>3.2.1 安装 HugeGraph-Computer CRD</h4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#8f5902;font-style:italic># Kubernetes version &gt;= v1.16</span>
</span></span><span style=display:flex><span>kubectl apply -f https://raw.githubusercontent.com/apache/hugegraph-computer/master/computer-k8s-operator/manifest/hugegraph-computer-crd.v1.yaml
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># Kubernetes version &lt; v1.16</span>
</span></span><span style=display:flex><span>kubectl apply -f https://raw.githubusercontent.com/apache/hugegraph-computer/master/computer-k8s-operator/manifest/hugegraph-computer-crd.v1beta1.yaml
</span></span></code></pre></div><h4 id=322-显示-crd>3.2.2 显示 CRD</h4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>kubectl get crd
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>NAME CREATED AT
</span></span><span style=display:flex><span>hugegraphcomputerjobs.hugegraph.apache.org 2021-09-16T08:01:08Z
</span></span></code></pre></div><h4 id=323-安装-hugegraph-computer-operatoretcd-server>3.2.3 安装 hugegraph-computer-operator&etcd-server</h4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>kubectl apply -f https://raw.githubusercontent.com/apache/hugegraph-computer/master/computer-k8s-operator/manifest/hugegraph-computer-operator.yaml
</span></span></code></pre></div><h4 id=324-等待-hugegraph-computer-operatoretcd-server-部署完成>3.2.4 等待 hugegraph-computer-operator&etcd-server 部署完成</h4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>kubectl get pod -n hugegraph-computer-operator-system
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>NAME READY STATUS RESTARTS AGE
</span></span><span style=display:flex><span>hugegraph-computer-operator-controller-manager-58c5545949-jqvzl 1/1 Running <span style=color:#0000cf;font-weight:700>0</span> 15h
</span></span><span style=display:flex><span>hugegraph-computer-operator-etcd-28lm67jxk5 1/1 Running <span style=color:#0000cf;font-weight:700>0</span> 15h
</span></span></code></pre></div><h4 id=325-提交作业>3.2.5 提交作业</h4><blockquote><p>更多 computer crd spec 请看: <a href=/docs/config/config-computer#hugegraph-computer-crd>Computer CRD</a></p><p>更多 Computer 配置请看: <a href=/docs/config/config-computer#computer-config-options>Computer Config Options</a></p></blockquote><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-yaml data-lang=yaml><span style=display:flex><span><span style=color:#000>cat &lt;&lt;EOF | kubectl apply --filename -</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#204a87;font-weight:700>apiVersion</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph.apache.org/v1</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#204a87;font-weight:700>kind</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>HugeGraphComputerJob</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#204a87;font-weight:700>metadata</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>namespace</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph-computer-operator-system</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>name</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic>&amp;jobName</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>pagerank-sample</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#204a87;font-weight:700>spec</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>jobId</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic>*jobName</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>algorithmName</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>page_rank</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>image</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph/hugegraph-computer:latest</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic># algorithm image url</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>jarFile</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>/hugegraph/hugegraph-computer/algorithm/builtin-algorithm.jar</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic># algorithm jar path</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>pullPolicy</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>Always</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>workerCpu</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#34;4&#34;</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>workerMemory</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#34;4Gi&#34;</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>workerInstances</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#0000cf;font-weight:700>5</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>computerConf</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>job.partitions_count</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#4e9a06>&#34;20&#34;</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>algorithm.params_class</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>org.apache.hugegraph.computer.algorithm.centrality.pagerank.PageRankParams</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>hugegraph.url</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>http://${hugegraph-server-host}:${hugegraph-server-port}</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic># hugegraph server url</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#204a87;font-weight:700>hugegraph.name</span><span style=color:#000;font-weight:700>:</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>hugegraph</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#8f5902;font-style:italic># hugegraph graph name</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline></span><span style=color:#000>EOF</span><span style=color:#f8f8f8;text-decoration:underline>
</span></span></span></code></pre></div><h4 id=326-显示作业>3.2.6 显示作业</h4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>kubectl get hcjob/pagerank-sample -n hugegraph-computer-operator-system
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span>NAME JOBID JOBSTATUS
</span></span><span style=display:flex><span>pagerank-sample pagerank-sample RUNNING
</span></span></code></pre></div><h4 id=327-显示节点日志>3.2.7 显示节点日志</h4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span><span style=color:#8f5902;font-style:italic># Show the master log</span>
</span></span><span style=display:flex><span>kubectl logs -l <span style=color:#000>component</span><span style=color:#ce5c00;font-weight:700>=</span>pagerank-sample-master -n hugegraph-computer-operator-system
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># Show the worker log</span>
</span></span><span style=display:flex><span>kubectl logs -l <span style=color:#000>component</span><span style=color:#ce5c00;font-weight:700>=</span>pagerank-sample-worker -n hugegraph-computer-operator-system
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># Show diagnostic log of a job</span>
</span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic># 注意: 诊断日志仅在作业失败时存在,并且只会保存一小时。</span>
</span></span><span style=display:flex><span>kubectl get event --field-selector <span style=color:#000>reason</span><span style=color:#ce5c00;font-weight:700>=</span>ComputerJobFailed --field-selector involvedObject.name<span style=color:#ce5c00;font-weight:700>=</span>pagerank-sample -n hugegraph-computer-operator-system
</span></span></code></pre></div><h4 id=328-显示作业的成功事件>3.2.8 显示作业的成功事件</h4><blockquote><p>NOTE: it will only be saved for one hour</p></blockquote><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-bash data-lang=bash><span style=display:flex><span>kubectl get event --field-selector <span style=color:#000>reason</span><span style=color:#ce5c00;font-weight:700>=</span>ComputerJobSucceed --field-selector involvedObject.name<span style=color:#ce5c00;font-weight:700>=</span>pagerank-sample -n hugegraph-computer-operator-system
</span></span></code></pre></div><h4 id=329-查询算法结果>3.2.9 查询算法结果</h4><p>如果输出到 <code>Hugegraph-Server</code> 则与 Locally 模式一致,如果输出到 <code>HDFS</code> ,请检查 <code>hugegraph-computerresults{jobId}</code>目录下的结果文件。</p><h2 id=4-内置算法文档>4 内置算法文档</h2><h3 id=41-支持的算法列表>4.1 支持的算法列表:</h3><h6 id=中心性算法>中心性算法:</h6><ul><li>PageRank</li><li>BetweennessCentrality</li><li>ClosenessCentrality</li><li>DegreeCentrality</li></ul><h6 id=社区算法>社区算法:</h6><ul><li>ClusteringCoefficient</li><li>Kcore</li><li>Lpa</li><li>TriangleCount</li><li>Wcc</li></ul><h6 id=路径算法>路径算法:</h6><ul><li>RingsDetection</li><li>RingsDetectionWithFilter</li></ul><p>更多算法请看: <a href=https://github.com/apache/hugegraph-computer/tree/master/computer-algorithm/src/main/java/org/apache/hugegraph/computer/algorithm>Built-In algorithms</a></p><h3 id=42-算法描述>4.2 算法描述</h3><p>TODO</p><h2 id=5-算法开发指南>5 算法开发指南</h2><p>TODO</p><h2 id=6-注意事项>6 注意事项</h2><ul><li>如果computer-k8s模块下面的某些类不存在,你需要运行<code>mvn compile</code>来提前生成对应的类。</li></ul></div></main></div></div><footer class="bg-dark py-3 row d-print-none"><div class=footer-container><div class="row bg-dark"><div class=col-1></div><div class="col-4 text-center container-center"><div class=footer-row><a href=https://www.apache.org><div class=footer-apache-logo><svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 7127.6 2890" enable-background="new 0 0 7127.6 2890"><path fill="#6d6e71" d="M7104.7 847.8c15.3 15.3 22.9 33.7 22.9 55.2s-7.6 39.9-22.9 55.4c-15.3 15.4-33.8 23.1-55.6 23.1s-40.2-7.6-55.4-22.9c-15.1-15.3-22.7-33.7-22.7-55.2s7.6-39.9 22.9-55.4c15.3-15.4 33.7-23.1 55.4-23.1C7070.9 824.9 7089.4 832.5 7104.7 847.8zM7098.1 951.9c13.3-13.6 20-29.8 20-48.7s-6.6-35-19.8-48.5c-13.2-13.4-29.4-20.1-48.6-20.1-19.2.0-35.4 6.7-48.7 20.2s-19.9 29.7-19.9 48.7 6.6 35.2 19.7 48.6c13.1 13.4 29.3 20.1 48.5 20.1S7084.7 965.4 7098.1 951.9zm-11-63.8c0 14-6.1 22.8-18.4 26.4l22.5 30.5H7073l-20.3-28.3h-18.6V945h-14.7v-84.6h31.8c12.8.0 22 2.2 27.6 6.6C7084.4 871.4 7087.1 878.4 7087.1 888.1zM7068.2 9e2c3-2.4 4.4-6.5 4.4-12s-1.5-9.4-4.5-11.6-8.4-3.2-16-3.2h-18v30.5h17.5C7059.7 903.6 7065.3 902.4 7068.2 9e2z"/><path fill="#6d6e71" d="M1803.6 499.8v155.4h-20V499.8h-56.8v-19.2h133.9v19.2H1803.6z"/><path fill="#6d6e71" d="M2082.2 655.2v-76.9H1977v76.9h-20V480.5h20v78.9h105.2v-78.9h20v174.7h-20z"/><path fill="#6d6e71" d="M2241.4 499.8v57.4h88.1v19.2h-88.1v59.8h101.8v19h-121.8V480.5H2340v19.2H2241.4z"/><path fill="#d22128" d="M1574.5 1852.4l417.3-997.6h80.1l417.3 997.6h-105.4l-129.3-311.9h-448.2l-127.9 311.9H1574.5zM2032.6 970l-205.1 493.2h404.7L2032.6 970z"/><path fill="#d22128" d="M2596.9 1852.4V854.8H3010c171.4.0 295.1 158.8 295.1 313.3.0 163-115.2 316.1-286.6 316.1h-324.6v368.1h-97zm97-455.3h318.9c118 0 193.9-108.2 193.9-229 0-125.1-92.7-226.2-202.3-226.2h-310.5v455.2z"/><path fill="#d22128" d="M3250.5 1852.4l417.3-997.6h80.1l417.3 997.6h-105.4l-129.3-311.9h-448.2l-127.9 311.9H3250.5zM3708.6 970l-205.1 493.2h404.7L3708.6 970z"/><path fill="#d22128" d="M4637.3 849.1c177 0 306.3 89.9 368.1 217.8l-78.7 47.8c-63.2-132.1-186.9-177-295.1-177-238.9.0-369.5 213.6-369.5 414.5.0 220.6 161.6 420.1 373.7 420.1 112.4.0 244.5-56.2 307.7-185.5l81.5 42.1c-64.6 148.9-241.7 231.8-394.8 231.8-274 0-466.5-261.3-466.5-514.2C4163.8 1106.3 4336.6 849.1 4637.3 849.1z"/><path fill="#d22128" d="M5949.1 854.8v997.6h-98.4v-466.5h-591.5v466.5h-96.9V854.8h96.9v444h591.5v-444H5949.1z"/><path fill="#d22128" d="M6844.6 1765.2v87.1h-670.2V854.8H6832v87.1h-560.6v359.7h489v82.9h-489v380.8H6844.6z"/><path fill="#6d6e71" d="M1667.6 2063.6c11.8 3.5 22.2 8.3 31 14.2l-10.3 22.6c-9-6-18.6-10.4-28.9-13.4-10.2-2.9-20-4.4-29.2-4.4-13.6.0-24.5 2.4-32.6 7.3s-12.2 11.8-12.2 20.7c0 7.6 2.3 14 6.8 19s10.2 8.9 17 11.7c6.8 2.8 16.1 6 28 9.6 14.4 4.6 26 8.9 34.7 12.9 8.8 4 16.3 9.9 22.5 17.8 6.2 7.8 9.3 18.2 9.3 31 0 11.7-3.2 21.8-9.5 30.6-6.3 8.7-15.3 15.5-26.8 20.3-11.6 4.8-24.9 7.2-40 7.2s-29.7-2.9-43.9-8.7c-14.2-5.8-26.4-13.6-36.6-23.4l10.7-21.6c9.6 9.4 20.7 16.7 33.3 21.9 12.6 5.2 24.8 7.8 36.8 7.8 15.3.0 27.3-3 36.1-8.9s13.2-13.9 13.2-23.9c0-7.8-2.3-14.3-6.9-19.4-4.6-5.1-10.3-9-17.1-11.9-6.8-2.8-16.1-6-28-9.6-14.2-4.2-25.7-8.3-34.6-12.2-8.9-3.9-16.4-9.7-22.5-17.5-6.1-7.7-9.2-17.9-9.2-30.6.0-10.9 3-20.4 9-28.6s14.6-14.6 25.6-19.1c11.1-4.5 23.8-6.8 38.2-6.8C1643.8 2058.3 1655.7 2060.1 1667.6 2063.6z"/><path fill="#6d6e71" d="M1980.1 2072.8c16.8 9.4 30.2 22.3 40 38.4 9.8 16.2 14.8 33.9 14.8 53.3.0 19.5-4.9 37.4-14.8 53.6-9.8 16.3-23.2 29.1-40 38.6s-35.3 14.3-55.2 14.3c-20.3.0-38.8-4.7-55.7-14.3-16.8-9.5-30.2-22.4-40-38.6-9.8-16.3-14.8-34.1-14.8-53.6s4.9-37.3 14.8-53.5c9.8-16.2 23.2-29 40-38.3 16.8-9.4 35.4-14 55.7-14C1944.8 2058.6 1963.2 2063.3 1980.1 2072.8zM1881.9 2092.7c-13.1 7.4-23.6 17.5-31.4 30.1-7.8 12.6-11.8 26.5-11.8 41.7.0 15.3 3.9 29.3 11.8 42 7.8 12.7 18.3 22.8 31.4 30.2 13.1 7.4 27.4 11.1 42.9 11.1s29.7-3.7 42.7-11.1 23.3-17.4 31.1-30.2c7.7-12.7 11.6-26.7 11.6-42s-3.9-29.2-11.6-41.8c-7.7-12.6-18.1-22.6-31.1-30s-27.2-11.2-42.6-11.2C1909.4 2081.5 1895.1 2085.2 1881.9 2092.7z"/><path fill="#6d6e71" d="M2186.5 2082.4v74h98.4v23.2h-98.4v90.2h-24.1v-210.6h133.8v23.2H2186.5z"/><path fill="#6d6e71" d="M2491.6 2082.4v187.4h-24.1v-187.4h-68.4v-23.2h161.4v23.2H2491.6z"/><path fill="#6d6e71" d="M2871.8 2269.8l-56.8-177.4-57.6 177.4h-24.5l-70.5-210.6h25.9l57.9 182.7 57.1-182.4 24.1-.3 57.7 182.7 57.1-182.7h25l-70.6 210.6H2871.8z"/><path fill="#6d6e71" d="M3087.3 2216.6l-23.5 53.2h-25.6l94.4-210.6h25l94.1 210.6h-26.1l-23.5-53.2H3087.3zM3144.5 2086.6l-46.9 106.8h94.4l-47.5-106.8z"/><path fill="#6d6e71" d="M3461.1 2202.7c-6 .4-10.7.6-14.1.6h-56v66.5h-24v-210.6h80c26.2.0 46.6 6.2 61.2 18.5 14.5 12.3 21.8 29.8 21.8 52.3.0 17.2-4.1 31.7-12.2 43.3-8.1 11.6-19.8 20-35 25l49.2 71.5h-27.3L3461.1 2202.7zM3491.3 2167.6c10.3-8.4 15.5-20.8 15.5-37 0-15.9-5.2-27.9-15.5-36s-25.1-12.2-44.3-12.2h-56v97.8h56C3466.2 2180.2 3481 2176 3491.3 2167.6z"/><path fill="#6d6e71" d="M3688.3 2082.4v69.2h106.2v23.2h-106.2v72.1h122.8v22.9h-146.9v-210.6h142.9v23.2H3688.3z"/><path fill="#6d6e71" d="M4147 2082.4v74h98.4v23.2H4147v90.2h-24.1v-210.6h133.8v23.2H4147z"/><path fill="#6d6e71" d="M4523.3 2072.8c16.8 9.4 30.2 22.3 40 38.4 9.8 16.2 14.8 33.9 14.8 53.3.0 19.5-4.9 37.4-14.8 53.6-9.8 16.3-23.2 29.1-40 38.6s-35.3 14.3-55.2 14.3c-20.3.0-38.8-4.7-55.7-14.3-16.8-9.5-30.2-22.4-40-38.6-9.8-16.3-14.8-34.1-14.8-53.6s4.9-37.3 14.8-53.5c9.8-16.2 23.2-29 40-38.3 16.8-9.4 35.4-14 55.7-14C4488.1 2058.6 4506.5 2063.3 4523.3 2072.8zM4425.2 2092.7c-13.1 7.4-23.6 17.5-31.4 30.1-7.8 12.6-11.8 26.5-11.8 41.7.0 15.3 3.9 29.3 11.8 42 7.8 12.7 18.3 22.8 31.4 30.2 13.1 7.4 27.4 11.1 42.9 11.1s29.7-3.7 42.7-11.1 23.3-17.4 31.1-30.2c7.7-12.7 11.6-26.7 11.6-42s-3.9-29.2-11.6-41.8c-7.7-12.6-18.1-22.6-31.1-30s-27.2-11.2-42.6-11.2C4452.6 2081.5 4438.3 2085.2 4425.2 2092.7z"/><path fill="#6d6e71" d="M4854.7 2247.7c-15.7 15.5-37.3 23.3-64.8 23.3-27.7.0-49.4-7.8-65.1-23.3-15.7-15.5-23.6-37-23.6-64.6v-124h24.1v124c0 20.3 5.8 36.1 17.3 47.5 11.6 11.4 27.3 17.1 47.3 17.1 20.1.0 35.8-5.7 47.1-17 11.4-11.3 17-27.2 17-47.7v-124h24.1v124C4878.2 2210.7 4870.4 2232.2 4854.7 2247.7z"/><path fill="#6d6e71" d="M5169.5 2269.8l-126.3-169.1v169.1h-24.1v-210.6h25l126.3 169.3v-169.3h23.8v210.6H5169.5z"/><path fill="#6d6e71" d="M5478.4 2073.1c16.4 9.3 29.4 21.9 38.9 37.9 9.6 16 14.3 33.9 14.3 53.5s-4.8 37.6-14.3 53.6c-9.5 16.1-22.6 28.7-39.3 37.9-16.6 9.2-35.2 13.8-55.5 13.8h-84.3v-210.6h85.2C5443.7 2059.2 5462 2063.8 5478.4 2073.1zM5362.3 2246.9h61.4c15.5.0 29.6-3.5 42.3-10.6s22.8-16.9 30.2-29.5c7.4-12.5 11.1-26.5 11.1-42s-3.8-29.4-11.3-41.9-17.7-22.3-30.6-29.6c-12.8-7.2-27-10.9-42.6-10.9h-60.5v164.5z"/><path fill="#6d6e71" d="M5668.6 2216.6l-23.5 53.2h-25.6l94.4-210.6h25l94.1 210.6h-26l-23.5-53.2H5668.6zM5725.8 2086.6l-46.9 106.8h94.4l-47.5-106.8z"/><path fill="#6d6e71" d="M5991 2082.4v187.4h-24v-187.4h-68.4v-23.2H6060v23.2h-69z"/><path fill="#6d6e71" d="M6175.9 2269.8v-210.6h24.1v210.6H6175.9z"/><path fill="#6d6e71" d="M6493.7 2072.8c16.8 9.4 30.2 22.3 40 38.4 9.8 16.2 14.8 33.9 14.8 53.3.0 19.5-4.9 37.4-14.8 53.6-9.8 16.3-23.2 29.1-40 38.6s-35.3 14.3-55.2 14.3c-20.3.0-38.8-4.7-55.7-14.3-16.8-9.5-30.2-22.4-40-38.6-9.8-16.3-14.8-34.1-14.8-53.6s4.9-37.3 14.8-53.5c9.8-16.2 23.2-29 40-38.3 16.8-9.4 35.4-14 55.7-14C6458.5 2058.6 6476.9 2063.3 6493.7 2072.8zM6395.6 2092.7c-13.1 7.4-23.6 17.5-31.4 30.1-7.8 12.6-11.8 26.5-11.8 41.7.0 15.3 3.9 29.3 11.8 42 7.8 12.7 18.3 22.8 31.4 30.2 13.1 7.4 27.4 11.1 42.9 11.1s29.7-3.7 42.7-11.1 23.3-17.4 31.1-30.2c7.7-12.7 11.6-26.7 11.6-42s-3.9-29.2-11.6-41.8c-7.7-12.6-18.1-22.6-31.1-30s-27.2-11.2-42.6-11.2C6423 2081.5 6408.8 2085.2 6395.6 2092.7z"/><path fill="#6d6e71" d="M6826.5 2269.8l-126.3-169.1v169.1h-24.1v-210.6h25l126.3 169.3v-169.3h23.8v210.6H6826.5z"/><linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="-4516.6152" y1="-2338.7222" x2="-4108.4111" y2="-1861.3982" gradientTransform="matrix(0.4226 -0.9063 0.9063 0.4226 5117.8774 -2859.9343)"><stop offset="0" style="stop-color:#F69923"/><stop offset=".3123" style="stop-color:#F79A23"/><stop offset=".8383" style="stop-color:#E97826"/></linearGradient><path fill="url(#SVGID_1_)" d="M1230.1 13.7c-45.3 26.8-120.6 102.5-210.5 212.3l82.6 155.9c58-82.9 116.9-157.5 176.3-221.2 4.6-5.1 7-7.5 7-7.5-2.3 2.5-4.6 5-7 7.5-19.2 21.2-77.5 89.2-165.5 224.4 84.7-4.2 214.9-21.6 321.1-39.7 31.6-177-31-258-31-258S1323.4-41.4 1230.1 13.7z"/><path fill="none" d="M1090.2 903.1c.6-.1 1.2-.2 1.8-.3l-11.9 1.3c-.7.3-1.4.7-2.1 1C1082.1 904.4 1086.2 903.7 1090.2 903.1z"/><path fill="none" d="M1005.9 1182.3c-6.7 1.5-13.7 2.7-20.7 3.7C992.3 1185 999.2 1183.8 1005.9 1182.3z"/><path fill="none" d="M432.9 1808.8c.9-2.3 1.8-4.7 2.6-7 18.2-48 36.2-94.7 54-140.1 20-51 39.8-100.4 59.3-148.3 20.6-50.4 40.9-99.2 60.9-146.3 21-49.4 41.7-97 62-142.8 16.5-37.3 32.8-73.4 48.9-108.3 5.4-11.7 10.7-23.2 16-34.6 10.5-22.7 21-44.8 31.3-66.5 9.5-20 19-39.6 28.3-58.8 3.1-6.4 6.2-12.8 9.3-19.1.5-1 1-2 1.5-3.1l-10.2 1.1-8-15.9c-.8 1.6-1.6 3.1-2.4 4.6-14.5 28.8-28.9 57.9-43.1 87.2-8.2 16.9-16.4 34-24.6 51-22.6 47.4-44.8 95.2-66.6 143.3-22.1 48.6-43.7 97.5-64.9 146.5-20.8 48.1-41.3 96.2-61.2 144.2-20 48-39.5 95.7-58.5 143.2-19.9 49.5-39.2 98.7-58 147.2-4.2 10.9-8.5 21.9-12.7 32.8-15 39.2-29.7 77.8-44 116l12.7 25.1 11.4-1.2c.4-1.1.8-2.3 1.3-3.4C396.7 1905.4 414.9 1856.4 432.9 1808.8z"/><path fill="none" d="M980 1186.8c.1.0.1.0.1-.1C980.1 1186.8 980.1 1186.8 980 1186.8z"/><path fill="#be202e" d="M952.6 1323c-10.6 1.9-21.4 3.8-32.5 5.7-.1.0-.1.1-.2.1 5.6-.8 11.2-1.7 16.6-2.6C942 1325.2 947.3 1324.1 952.6 1323z"/><path opacity=".35" fill="#be202e" d="M952.6 1323c-10.6 1.9-21.4 3.8-32.5 5.7-.1.0-.1.1-.2.1 5.6-.8 11.2-1.7 16.6-2.6C942 1325.2 947.3 1324.1 952.6 1323z"/><path fill="#be202e" d="M980.3 1186.7C980.2 1186.7 980.2 1186.7 980.3 1186.7c-.1.1-.2.1-.2.1 1.8-.2 3.5-.5 5.2-.8 7-1 13.9-2.2 20.7-3.7C997.5 1183.8 989 1185.2 980.3 1186.7z"/><path opacity=".35" fill="#be202e" d="M980.3 1186.7C980.2 1186.7 980.2 1186.7 980.3 1186.7c-.1.1-.2.1-.2.1 1.8-.2 3.5-.5 5.2-.8 7-1 13.9-2.2 20.7-3.7C997.5 1183.8 989 1185.2 980.3 1186.7z"/><linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="-7537.7339" y1="-2391.4075" x2="-4625.4141" y2="-2391.4075" gradientTransform="matrix(0.4226 -0.9063 0.9063 0.4226 5117.8774 -2859.9343)"><stop offset=".3233" style="stop-color:#9E2064"/><stop offset=".6302" style="stop-color:#C92037"/><stop offset=".7514" style="stop-color:#CD2335"/><stop offset="1" style="stop-color:#E97826"/></linearGradient><path fill="url(#SVGID_2_)" d="M858.6 784.7c25.1-46.9 50.5-92.8 76.2-137.4 26.7-46.4 53.7-91.3 80.9-134.7 1.6-2.6 3.2-5.2 4.8-7.7 27-42.7 54.2-83.7 81.6-122.9L1019.5 226c-6.2 7.6-12.5 15.3-18.8 23.2-23.8 29.7-48.6 61.6-73.9 95.5-28.6 38.2-58 78.9-87.8 121.7-27.6 39.5-55.5 80.9-83.5 123.7-23.8 36.5-47.7 74-71.4 112.5-.9 1.4-1.8 2.9-2.6 4.3L789 919.2c22.8-45.6 46.1-90.5 69.6-134.5z"/><linearGradient id="SVGID_3_" gradientUnits="userSpaceOnUse" x1="-7186.1777" y1="-2099.3059" x2="-5450.7183" y2="-2099.3059" gradientTransform="matrix(0.4226 -0.9063 0.9063 0.4226 5117.8774 -2859.9343)"><stop offset="0" style="stop-color:#282662"/><stop offset=".0954839" style="stop-color:#662E8D"/><stop offset=".7882" style="stop-color:#9F2064"/><stop offset=".9487" style="stop-color:#CD2032"/></linearGradient><path fill="url(#SVGID_3_)" d="M369 1981c-14.2 39.1-28.5 78.9-42.9 119.6-.2.6-.4 1.2-.6 1.8-2 5.7-4.1 11.5-6.1 17.2-9.7 27.4-18 52.1-37.3 108.2 31.7 14.5 57.1 52.5 81.1 95.6-2.6-44.7-21-86.6-56.2-119.1 156.1 7 290.6-32.4 360.1-146.6 6.2-10.2 11.9-20.9 17-32.2-31.6 40.1-70.8 57.1-144.5 53-.2.1-.3.1-.5.2.2-.1.3-.1.5-.2 108.6-48.6 163.1-95.3 211.2-172.6 11.4-18.3 22.5-38.4 33.8-60.6-94.9 97.5-205 125.3-320.9 104.2l-86.9 9.5C374.4 1966.3 371.7 1973.6 369 1981z"/><linearGradient id="SVGID_4_" gradientUnits="userSpaceOnUse" x1="-7374.1626" y1="-2418.5454" x2="-4461.8428" y2="-2418.5454" gradientTransform="matrix(0.4226 -0.9063 0.9063 0.4226 5117.8774 -2859.9343)"><stop offset=".3233" style="stop-color:#9E2064"/><stop offset=".6302" style="stop-color:#C92037"/><stop offset=".7514" style="stop-color:#CD2335"/><stop offset="1" style="stop-color:#E97826"/></linearGradient><path fill="url(#SVGID_4_)" d="M409.6 1786.3c18.8-48.5 38.1-97.7 58-147.2 19-47.4 38.5-95.2 58.5-143.2s40.4-96.1 61.2-144.2c21.2-49 42.9-97.8 64.9-146.5 21.8-48.1 44-95.9 66.6-143.3 8.1-17.1 16.3-34.1 24.6-51 14.2-29.3 28.6-58.4 43.1-87.2.8-1.6 1.6-3.1 2.4-4.6L681.4 706.8c-1.8 2.9-3.5 5.8-5.3 8.6-25.1 40.9-50 82.7-74.4 125.4-24.7 43.1-49 87.1-72.7 131.7-20 37.6-39.6 75.6-58.6 113.9-3.8 7.8-7.6 15.5-11.3 23.2-23.4 48.2-44.6 94.8-63.7 139.5-21.7 50.7-40.7 99.2-57.5 145.1-11 30.2-21 59.4-30.1 87.4-7.5 24-14.7 47.9-21.5 71.8-16 56.3-29.9 112.4-41.2 168.3L353 1935.1c14.3-38.1 28.9-76.8 44-116C401.1 1808.2 405.4 1797.3 409.6 1786.3z"/><linearGradient id="SVGID_5_" gradientUnits="userSpaceOnUse" x1="-7161.7642" y1="-2379.1431" x2="-5631.2524" y2="-2379.1431" gradientTransform="matrix(0.4226 -0.9063 0.9063 0.4226 5117.8774 -2859.9343)"><stop offset="0" style="stop-color:#282662"/><stop offset=".0954839" style="stop-color:#662E8D"/><stop offset=".7882" style="stop-color:#9F2064"/><stop offset=".9487" style="stop-color:#CD2032"/></linearGradient><path fill="url(#SVGID_5_)" d="M243.5 1729.4c-13.6 68.2-23.2 136.2-28 203.8-.2 2.4-.4 4.7-.5 7.1-33.7-54-124-106.8-123.8-106.2 64.6 93.7 113.7 186.7 120.9 278-34.6 7.1-82-3.2-136.8-23.3 57.1 52.5 1e2 67 116.7 70.9-52.5 3.3-107.1 39.3-162.1 80.8 80.5-32.8 145.5-45.8 192.1-35.3C148.1 2414.2 74.1 2645 0 2890c22.7-6.7 36.2-21.9 43.9-42.6 13.2-44.4 100.8-335.6 238-718.2 3.9-10.9 7.8-21.8 11.8-32.9 1.1-3 2.2-6.1 3.3-9.2 14.5-40.1 29.5-81.1 45.1-122.9 3.5-9.5 7.1-19 10.7-28.6.1-.2.1-.4.2-.6l-107.9-213.2C244.6 1724.4 244 1726.9 243.5 1729.4z"/><linearGradient id="SVGID_6_" gradientUnits="userSpaceOnUse" x1="-7374.1626" y1="-2117.1309" x2="-4461.8428" y2="-2117.1309" gradientTransform="matrix(0.4226 -0.9063 0.9063 0.4226 5117.8774 -2859.9343)"><stop offset=".3233" style="stop-color:#9E2064"/><stop offset=".6302" style="stop-color:#C92037"/><stop offset=".7514" style="stop-color:#CD2335"/><stop offset="1" style="stop-color:#E97826"/></linearGradient><path fill="url(#SVGID_6_)" d="M805.6 937c-3.1 6.3-6.2 12.7-9.3 19.1-9.3 19.2-18.8 38.8-28.3 58.8-10.3 21.7-20.7 43.9-31.3 66.5-5.3 11.4-10.6 22.9-16 34.6-16.1 35-32.4 71.1-48.9 108.3-20.3 45.8-41 93.4-62 142.8-20 47.1-40.3 95.9-60.9 146.3-19.5 47.9-39.3 97.3-59.3 148.3-17.8 45.4-35.9 92.1-54 140.1-.9 2.3-1.8 4.7-2.6 7-18 47.6-36.2 96.6-54.6 146.8-.4 1.1-.8 2.3-1.3 3.4l86.9-9.5c-1.7-.3-3.5-.5-5.2-.9 103.9-13 242.1-90.6 331.4-186.5 41.1-44.2 78.5-96.3 113-157.3 25.7-45.4 49.8-95.8 72.8-151.5 20.1-48.7 39.4-101.4 58-158.6-23.9 12.6-51.2 21.8-81.4 28.2-5.3 1.1-10.7 2.2-16.1 3.1-5.5 1-11 1.8-16.6 2.6.1.0.1-.1.2-.1 96.9-37.3 158-109.2 202.4-197.4-25.5 17.4-66.9 40.1-116.6 51.1-6.7 1.5-13.7 2.7-20.7 3.7-1.7.3-3.5.6-5.2.8.1.0.1.0.1-.1h.1c33.6-14.1 62-29.8 86.6-48.4 5.3-4 10.4-8.1 15.3-12.3 7.5-6.5 14.7-13.3 21.5-20.5 4.4-4.6 8.6-9.3 12.7-14.2 9.6-11.5 18.7-23.9 27.1-37.3 2.6-4.1 5.1-8.3 7.6-12.6 3.2-6.2 6.3-12.3 9.3-18.3 13.5-27.2 24.4-51.5 33-72.8 4.3-10.6 8.1-20.5 11.3-29.7 1.3-3.7 2.5-7.2 3.7-10.6 3.4-10.2 6.2-19.3 8.4-27.3 3.3-12 5.3-21.5 6.4-28.4-3.3 2.6-7.1 5.2-11.3 7.7-29.3 17.5-79.5 33.4-119.9 40.8l79.8-8.8-79.8 8.8c-.6.1-1.2.2-1.8.3-4 .7-8.1 1.3-12.2 2 .7-.3 1.4-.7 2.1-1l-273 29.9C806.6 935 806.1 936 805.6 937z"/><linearGradient id="SVGID_7_" gradientUnits="userSpaceOnUse" x1="-7554.8232" y1="-2132.0981" x2="-4642.5034" y2="-2132.0981" gradientTransform="matrix(0.4226 -0.9063 0.9063 0.4226 5117.8774 -2859.9343)"><stop offset=".3233" style="stop-color:#9E2064"/><stop offset=".6302" style="stop-color:#C92037"/><stop offset=".7514" style="stop-color:#CD2335"/><stop offset="1" style="stop-color:#E97826"/></linearGradient><path fill="url(#SVGID_7_)" d="M1112.9 385.1c-24.3 37.3-50.8 79.6-79.4 127.5-1.5 2.5-3 5.1-4.5 7.6-24.6 41.5-50.8 87.1-78.3 137-23.8 43.1-48.5 89.3-74.3 139C854 839.5 830.8 885.4 807 934l273-29.9c79.5-36.6 115.1-69.7 149.6-117.6 9.2-13.2 18.4-27 27.5-41.3 28-43.8 55.6-92 80.1-139.9 23.7-46.3 44.7-92.2 60.7-133.5 10.2-26.3 18.4-50.8 24.1-72.3 5-19 8.9-36.9 11.9-54.1C1327.9 363.5 1197.6 380.9 1112.9 385.1z"/><path fill="#be202e" d="M936.5 1326.1c-5.5 1-11 1.8-16.6 2.6C925.5 1328 931 1327.1 936.5 1326.1z"/><path opacity=".35" fill="#be202e" d="M936.5 1326.1c-5.5 1-11 1.8-16.6 2.6C925.5 1328 931 1327.1 936.5 1326.1z"/><linearGradient id="SVGID_8_" gradientUnits="userSpaceOnUse" x1="-7374.1626" y1="-2027.484" x2="-4461.8433" y2="-2027.484" gradientTransform="matrix(0.4226 -0.9063 0.9063 0.4226 5117.8774 -2859.9343)"><stop offset=".3233" style="stop-color:#9E2064"/><stop offset=".6302" style="stop-color:#C92037"/><stop offset=".7514" style="stop-color:#CD2335"/><stop offset="1" style="stop-color:#E97826"/></linearGradient><path fill="url(#SVGID_8_)" d="M936.5 1326.1c-5.5 1-11 1.8-16.6 2.6C925.5 1328 931 1327.1 936.5 1326.1z"/><path fill="#be202e" d="M980 1186.8c1.8-.2 3.5-.5 5.2-.8C983.5 1186.3 981.8 1186.6 980 1186.8z"/><path opacity=".35" fill="#be202e" d="M980 1186.8c1.8-.2 3.5-.5 5.2-.8C983.5 1186.3 981.8 1186.6 980 1186.8z"/><linearGradient id="SVGID_9_" gradientUnits="userSpaceOnUse" x1="-7374.1626" y1="-2037.7417" x2="-4461.8433" y2="-2037.7417" gradientTransform="matrix(0.4226 -0.9063 0.9063 0.4226 5117.8774 -2859.9343)"><stop offset=".3233" style="stop-color:#9E2064"/><stop offset=".6302" style="stop-color:#C92037"/><stop offset=".7514" style="stop-color:#CD2335"/><stop offset="1" style="stop-color:#E97826"/></linearGradient><path fill="url(#SVGID_9_)" d="M980 1186.8c1.8-.2 3.5-.5 5.2-.8C983.5 1186.3 981.8 1186.6 980 1186.8z"/><path fill="#be202e" d="M980.2 1186.7z"/><path opacity=".35" fill="#be202e" d="M980.2 1186.7z"/><linearGradient id="SVGID_10_" gradientUnits="userSpaceOnUse" x1="-5738.0635" y1="-2039.799" x2="-5094.3457" y2="-2039.799" gradientTransform="matrix(0.4226 -0.9063 0.9063 0.4226 5117.8774 -2859.9343)"><stop offset=".3233" style="stop-color:#9E2064"/><stop offset=".6302" style="stop-color:#C92037"/><stop offset=".7514" style="stop-color:#CD2335"/><stop offset="1" style="stop-color:#E97826"/></linearGradient><path fill="url(#SVGID_10_)" d="M980.2 1186.7z"/></svg></div></a><ul class=footer-link><li><a class=white href=http://www.apache.org>Foundation</a></li><li><a class=white href=http://www.apache.org/licenses/>License</a></li><li><a class=white href=https://www.apache.org/security/>Security</a></li><li><a class=white href=http://www.apache.org/events/current-event>Events</a></li><li><a class=white href=http://www.apache.org/foundation/sponsorship.html>Sponsorship</a></li><li><a class=white href=http://www.apache.org/foundation/thanks.html>Thanks</a></li><li><a class=white href=https://privacy.apache.org/policies/privacy-policy-public.html target=_blank>Privacy</a></li></ul></div></div><div class="col-6 text-white text-center container-center"><p>Copyright &copy; 2024 The Apache Software Foundation, Licensed under the <a class=white href=https://www.apache.org/licenses/LICENSE-2.0>Apache License Version 2.0</a></p><p>Apache and the Apache feather logo are trademarks of The Apache Software Foundation.</p></div><div class=col-1></div></div></div></footer></div><script src=https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js integrity=sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN crossorigin=anonymous></script>
<script src=https://cdn.jsdelivr.net/npm/bootstrap@4.6.1/dist/js/bootstrap.min.js integrity="sha512-UR25UO94eTnCVwjbXozyeVd6ZqpaAE9naiEUBK/A+QDbfSTQFhPGj5lOR6d8tsgbBk84Ggb5A3EkjsOgPRPcKA==" crossorigin=anonymous></script>
<script src=/js/tabpane-persist.js></script>
<script src=/js/main.min.aa9f4c5dae6a98b2c46277f4c56f1673a2b000d1756ce4ffae93784cab25e6d5.js integrity="sha256-qp9MXa5qmLLEYnf0xW8Wc6KwANF1bOT/rpN4TKsl5tU=" crossorigin=anonymous></script>
<script src=/js/prism.js></script></body></html>