From 761b3274f968d8e2976225ad13df7ac9d19f51e0 Mon Sep 17 00:00:00 2001 From: cooper-lzy <78672629+cooper-lzy@users.noreply.github.com> Date: Tue, 15 Feb 2022 09:24:50 +0800 Subject: [PATCH] update branch of client (#1469) --- docs-2.0/14.client/3.nebula-cpp-client.md | 25 ++------ docs-2.0/14.client/4.nebula-java-client.md | 50 +-------------- docs-2.0/14.client/5.nebula-python-client.md | 67 +------------------- docs-2.0/14.client/6.nebula-go-client.md | 40 +----------- 4 files changed, 13 insertions(+), 169 deletions(-) diff --git a/docs-2.0/14.client/3.nebula-cpp-client.md b/docs-2.0/14.client/3.nebula-cpp-client.md index 8c3e8b17f50..dacaeb3350d 100644 --- a/docs-2.0/14.client/3.nebula-cpp-client.md +++ b/docs-2.0/14.client/3.nebula-cpp-client.md @@ -24,7 +24,7 @@ - (推荐)如果需要安装指定版本的 Nebula CPP,请使用选项`--branch`指定分支。例如安装 v{{ cpp.release }}发布版本,请执行如下命令: ```bash - $ git clone --branch v{{ cpp.release }} https://github.com/vesoft-inc/nebula-cpp.git + $ git clone --branch {{cpp.branch}} https://github.com/vesoft-inc/nebula-cpp.git ``` - 如果需要安装日常开发版本,请执行如下命令下载`master`分支的源码: @@ -83,7 +83,7 @@ 将 CPP 文件编译为可执行文件即可。接下来以`SessionExample.cpp`为例,介绍如何操作。 -1. 使用[示例代码](https://github.com/vesoft-inc/nebula-cpp/blob/master/examples/SessionExample.cpp)创建`SessionExample.cpp`文件。 +1. 使用[示例代码](https://github.com/vesoft-inc/nebula-cpp/blob/{{cpp.branch}}/examples/SessionExample.cpp)创建`SessionExample.cpp`文件。 2. 编译文件,命令如下: @@ -103,22 +103,5 @@ ### 核心代码 -详细示例请参见 [SessionExample](https://github.com/vesoft-inc/nebula-cpp/blob/master/examples/SessionExample.cpp)。 - -```C++ -nebula::init(&argc, &argv); -auto address = "192.168.xx.1:9669"; -nebula::ConnectionPool pool; -pool.init({address}, nebula::Config{}); -auto session = pool.getSession("root", "nebula"); - -auto result = session.execute("SHOW HOSTS"); -std::cout << *result.data; - -std::atomic_bool complete{false}; -session.asyncExecute("SHOW HOSTS", [&complete](nebula::ExecutionResponse&& cbResult) { - std::cout << *cbResult.data; - complete.store(true); -}); -session.release(); -``` +详细示例请参见 [SessionExample](https://github.com/vesoft-inc/nebula-cpp/blob/{{cpp.branch}}/examples/SessionExample.cpp)。 + diff --git a/docs-2.0/14.client/4.nebula-java-client.md b/docs-2.0/14.client/4.nebula-java-client.md index fe1abf6433d..0c2089c1207 100644 --- a/docs-2.0/14.client/4.nebula-java-client.md +++ b/docs-2.0/14.client/4.nebula-java-client.md @@ -20,7 +20,7 @@ - (推荐)如果需要使用指定版本的 Nebula Java,请使用选项`--branch`指定分支。例如使用 v{{ java.release }}发布版本,请执行如下命令: ```bash - $ git clone --branch v{{ java.release }} https://github.com/vesoft-inc/nebula-java.git + $ git clone --branch {{java.branch}} https://github.com/vesoft-inc/nebula-java.git ``` - 如果需要安装日常开发版本,请执行如下命令下载`master`分支的源码: @@ -64,49 +64,5 @@ ### 核心代码 -详细示例请参见 [GraphClientExample](https://github.com/vesoft-inc/nebula-java/blob/master/examples/src/main/java/com/vesoft/nebula/examples/GraphClientExample.java)。 - -```java -NebulaPool pool = new NebulaPool(); -Session session = null; -try { - NebulaPoolConfig nebulaPoolConfig = new NebulaPoolConfig(); - nebulaPoolConfig.setMaxConnSize(100); - List addresses = Arrays.asList(new HostAddress("192.168.xx.1", 9669), - new HostAddress("192.168.xx.2", 9670)); - pool.init(addresses, nebulaPoolConfig); - session = pool.getSession("root", "nebula", false); - - //create space - String space = "test"; - String createSpace = "CREATE SPACE IF NOT EXISTS " + space + " (partition_num=15, replica_factor=1, vid_type=fixed_string(30)); "; - ResultSet resp = session.execute(createSpace); - - //create schema - String createSchema = "USE " + space + "; CREATE TAG IF NOT EXISTS person(name string, age int);" - + "CREATE EDGE IF NOT EXISTS like(likeness double)"; - ResultSet resp = session.execute(createSchema); - - //insert vertex - String insertVertexes = "INSERT VERTEX person(name, age) VALUES " + "'Bob':('Bob', 10), " - + "'Lily':('Lily', 9), " + "'Tom':('Tom', 10), " + "'Jerry':('Jerry', 13), " - + "'John':('John', 11);"; - ResultSet resp = session.execute(insertVertexes); - - // inert edge - String insertEdges = "INSERT EDGE like(likeness) VALUES " + "'Bob'->'Lily':(80.0), " - + "'Bob'->'Tom':(70.0), " + "'Lily'->'Jerry':(84.0), " + "'Tom'->'Jerry':(68.3), " - + "'Bob'->'John':(97.2);"; - ResultSet resp = session.execute(insertEdges); - - // query - String query = "GO FROM \"Bob\" OVER like " + "YIELD properties($$).name, properties($$).age, properties(edge).likeness"; - ResultSet resp = session.execute(query); - printResult(resp); -}finally { - if (session != null) { - session.release(); - } - pool.close(); -} -``` +详细示例请参见 [GraphClientExample](https://github.com/vesoft-inc/nebula-java/blob/{{java.branch}}/examples/src/main/java/com/vesoft/nebula/examples/GraphClientExample.java)。 + diff --git a/docs-2.0/14.client/5.nebula-python-client.md b/docs-2.0/14.client/5.nebula-python-client.md index e912d6a2693..39cafeb3ff9 100644 --- a/docs-2.0/14.client/5.nebula-python-client.md +++ b/docs-2.0/14.client/5.nebula-python-client.md @@ -20,7 +20,7 @@ ### pip 安装 ```bash -$ pip install nebula2-python== +$ pip install nebula3-python== ``` ### 克隆源码安装 @@ -30,7 +30,7 @@ $ pip install nebula2-python== - (推荐)如果需要安装指定版本的 Nebula Python,请使用选项`--branch`指定分支。例如安装 v{{ python.release }}发布版本,请执行如下命令: ```bash - $ git clone --branch v{{ python.release }} https://github.com/vesoft-inc/nebula-python.git + $ git clone --branch {{python.branch}} https://github.com/vesoft-inc/nebula-python.git ``` - 如果需要安装日常开发版本,请执行如下命令下载`master`分支的源码: @@ -53,66 +53,5 @@ $ pip install nebula2-python== ## 核心代码 -详细示例请参见 [Example](https://github.com/vesoft-inc/nebula-python/tree/master/example)。 +详细示例请参见 [Example](https://github.com/vesoft-inc/nebula-python/tree/{{python.branch}}/example)。 -### 连接 Graph 服务 - -```python -# 定义配置 -config = Config() -config.max_connection_pool_size = 10 -# 初始化连接池 -connection_pool = ConnectionPool() -# 如果给定的服务器正常,则返回 true,否则返回 false。 -ok = connection_pool.init([('192.168.xx.1', 9669)], config) - -# 方法 1:控制连接自行释放。 -# 从连接池中获取会话 -session = connection_pool.get_session('root', 'nebula') - -# 选择图空间 -session.execute('USE basketballplayer') - -# 执行查看 TAG 命令 -result = session.execute('SHOW TAGS') -print(result) - -# 释放会话 -session.release() - -# 方法 2:使用 session_context,会话将被自动释放。 -with connection_pool.session_context('root', 'nebula') as session: - session.execute('USE basketballplayer;') - result = session.execute('SHOW TAGS;') - print(result) - -# 关闭连接池 -connection_pool.close() -``` - -### 连接 Storage 服务 - -```python -# 设置所有 Meta 服务地址 -meta_cache = MetaCache([('192.168.xx.1', 9559), - ('192.168.xx.2', 9559), - ('192.168.xx.3', 9559)], - 50000) -graph_storage_client = GraphStorageClient(meta_cache) - -resp = graph_storage_client.scan_vertex( - space_name='ScanSpace', - tag_name='person') -while resp.has_next(): - result = resp.next() - for vertex_data in result: - print(vertex_data) - -resp = graph_storage_client.scan_edge( - space_name='ScanSpace', - edge_name='friend') -while resp.has_next(): - result = resp.next() - for edge_data in result: - print(edge_data) -``` diff --git a/docs-2.0/14.client/6.nebula-go-client.md b/docs-2.0/14.client/6.nebula-go-client.md index 296b900d5eb..802f7417ad1 100644 --- a/docs-2.0/14.client/6.nebula-go-client.md +++ b/docs-2.0/14.client/6.nebula-go-client.md @@ -19,7 +19,7 @@ - (推荐)如果需要下载指定版本的 Nebula Go,请使用选项`--branch`指定分支。例如安装 v{{ go.release }}发布版本,请执行如下命令: ```bash - $ git clone --branch v{{ go.release }} https://github.com/vesoft-inc/nebula-go.git + $ git clone --branch {{go.branch}} https://github.com/vesoft-inc/nebula-go.git ``` - 如果需要安装日常开发版本,请执行如下命令下载`master`分支的源码: @@ -36,43 +36,9 @@ $ go get -u -v github.com/vesoft-inc/nebula-go@ ``` -`tag`:指定分支。例如`master`或`v{{ go.release }}`。 +`tag`:指定分支。例如`master`或`{{go.branch}}`。 ## 核心代码 -详细示例请参见 [graph_client_basic_example](https://github.com/vesoft-inc/nebula-go/blob/master/basic_example/graph_client_basic_example.go) 和 [graph_client_goroutines_example](https://github.com/vesoft-inc/nebula-go/blob/master/gorountines_example/graph_client_goroutines_example.go)。 +详细示例请参见 [graph_client_basic_example](https://github.com/vesoft-inc/nebula-go/blob/{{go.branch}}/basic_example/graph_client_basic_example.go) 和 [graph_client_goroutines_example](https://github.com/vesoft-inc/nebula-go/blob/{{go.branch}}/gorountines_example/graph_client_goroutines_example.go)。 -```bash -const ( - address = "192.168.xx.1" - port = 9669 - username = "root" - password = "nebula" -) - -func main() { - hostAddress := nebula.HostAddress{Host: address, Port: port} - hostList := []nebula.HostAddress{hostAddress} - testPoolConfig := nebula.GetDefaultConf() - pool, err := nebula.NewConnectionPool(hostList, testPoolConfig, log) - defer pool.Close() - session, err := pool.GetSession(username, password) - defer session.Release() - - checkResultSet := func(prefix string, res *nebula.ResultSet) { - if !res.IsSucceed() { - log.Fatal(fmt.Sprintf("%s, ErrorCode: %v, ErrorMsg: %s", prefix, res.GetErrorCode(), res.GetErrorMsg())) - } - } - { - createSchema := "CREATE SPACE IF NOT EXISTS basic_example_space(vid_type=FIXED_STRING(20)); " + - "USE basic_example_space;" + - "CREATE TAG IF NOT EXISTS person(name string, age int);" + - "CREATE EDGE IF NOT EXISTS like(likeness double)" - resultSet, err := session.Execute(createSchema) - checkResultSet(createSchema, resultSet) - } - fmt.Print("\n") - log.Info("Nebula Go Client Basic Example Finished") -} -```