Skip to content

Commit

Permalink
update compatibility and branch (#1099)
Browse files Browse the repository at this point in the history
  • Loading branch information
cooper-lzy authored Feb 15, 2022
1 parent c822283 commit ff1a4ec
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 178 deletions.
23 changes: 2 additions & 21 deletions docs-2.0/14.client/3.nebula-cpp-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
- (Recommended) To install a specific version of Nebula CPP, use the Git option `--branch` to specify the branch. For example, to install v{{ cpp.release }}, run the following command:

```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
```

- To install the daily development version, run the following command to download the source code from the `master` branch:
Expand Down Expand Up @@ -103,23 +103,4 @@ Compile the CPP file to an executable file, then you can use it. The following s

### Core of the example code

This sub-section shows the core of the example code. For all the code, see [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();
```
This sub-section shows the core of the example code. For all the code, see [SessionExample](https://github.com/vesoft-inc/nebula-cpp/blob/{{cpp.branch}}/examples/SessionExample.cpp).
55 changes: 5 additions & 50 deletions docs-2.0/14.client/4.nebula-java-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You have installed Java 8.0 or later versions.
- (Recommended) To install a specific version of Nebula Java, use the Git option `--branch` to specify the branch. For example, to install v{{ java.release }}, run the following command:

```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
```

- To install the daily development version, run the following command to download the source code from the `master` branch:
Expand All @@ -39,13 +39,13 @@ When importing a Maven project with tools such as IDEA, set the following depend

!!! note

`2.0.0-SNAPSHOT` indicates the daily development version that may have unknown issues. We recommend that you replace `2.0.0-SNAPSHOT` with a released version number to use a table version.
`3.0.0-SNAPSHOT` indicates the daily development version that may have unknown issues. We recommend that you replace `3.0.0-SNAPSHOT` with a released version number to use a table version.

```bash
<dependency>
<groupId>com.vesoft</groupId>
<artifactId>client</artifactId>
<version>2.0.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</dependency>
```

Expand All @@ -64,50 +64,5 @@ If there is no Maven to manage the project, manually download the [JAR file](htt

### Core of the example code

This sub-section shows the core of the example code. For all the code, see [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<HostAddress> 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();
}
```
This sub-section shows the core of the example code. For all the code, see [GraphClientExample](https://github.com/vesoft-inc/nebula-java/blob/{{java.branch}}/examples/src/main/java/com/vesoft/nebula/examples/GraphClientExample.java).

68 changes: 3 additions & 65 deletions docs-2.0/14.client/5.nebula-python-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ You have installed Python 3.6 or later versions.
### Install Nebula Python with pip

```bash
$ pip install nebula2-python==<version>
$ pip install nebula3-python==<version>
```

### Install Nebula Python from the source code
Expand All @@ -30,7 +30,7 @@ $ pip install nebula2-python==<version>
- (Recommended) To install a specific version of Nebula Python, use the Git option `--branch` to specify the branch. For example, to install v{{ python.release }}, run the following command:

```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
```

- To install the daily development version, run the following command to download the source code from the `master` branch:
Expand All @@ -53,66 +53,4 @@ $ pip install nebula2-python==<version>

## Core of the example code

This section shows the core of the example code. For all the code, see [Example](https://github.com/vesoft-inc/nebula-python/tree/master/example).

### Connect to the Graph Service

```python
# Customize configurations.
config = Config()
config.max_connection_pool_size = 10
# Initialize the connection pool.
connection_pool = ConnectionPool()
# Returns true if the server is healthy, false otherwise.
ok = connection_pool.init([('192.168.xx.1', 9669)], config)
# Method 1: Manually specify when to release the session.
# Get the session from the connection pool.
session = connection_pool.get_session('root', 'nebula')
# Select a graph space.
session.execute('USE basketballplayer')
# Run the SHOW TAGS statement.
result = session.execute('SHOW TAGS')
print(result)
# Release the session.
session.release()
# Method 2: Use session_context to automatically release the session.
with connection_pool.session_context('root', 'nebula') as session:
session.execute('USE basketballplayer;')
result = session.execute('SHOW TAGS;')
print(result)
# Close the connection pool.
connection_pool.close()
```

### Connect to the Storage Server

```python
# Set the IP addresses of all Meta servers.
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)
```
This section shows the core of the example code. For all the code, see [Example](https://github.com/vesoft-inc/nebula-python/tree/{{python.branch}}/example).
41 changes: 3 additions & 38 deletions docs-2.0/14.client/6.nebula-go-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ You have installed Golang 1.13 or later versions.
- (Recommended) To install a specific version of Nebula Go, use the Git option `--branch` to specify the branch. For example, to install v{{ go.release }}, run the following command:

```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
```

- To install the daily development version, run the following command to download the source code from the `master` branch:
Expand All @@ -36,43 +36,8 @@ Run the following command to install or update Nebula Go:
$ go get -u -v github.com/vesoft-inc/nebula-go@<tag>
```

`tag`: Specify the branch, such as `master` or `v{{ go.release }}`.
`tag`: Specify the branch, such as `master` or `{{go.branch}}`.

## Core of the example code

This section shows the core of the example code. For all the code, see [graph_client_basic_example](https://github.com/vesoft-inc/nebula-go/blob/master/basic_example/graph_client_basic_example.go) and [graph_client_goroutines_example](https://github.com/vesoft-inc/nebula-go/blob/master/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")
}
```
This section shows the core of the example code. For all the code, see [graph_client_basic_example](https://github.com/vesoft-inc/nebula-go/blob/{{go.branch}}/basic_example/graph_client_basic_example.go) and [graph_client_goroutines_example](https://github.com/vesoft-inc/nebula-go/blob/{{go.branch}}/gorountines_example/graph_client_goroutines_example.go).
6 changes: 3 additions & 3 deletions docs-2.0/nebula-exchange/ex-ug-FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ $SPARK_HOME/bin/spark-submit --class com.vesoft.nebula.exchange.Exchange \
--files application.conf \
--conf spark.driver.extraClassPath=./ \
--conf spark.executor.extraClassPath=./ \
nebula-exchange-2.0.0.jar \
nebula-exchange-3.0.0.jar \
-c application.conf
```

Expand Down Expand Up @@ -123,7 +123,7 @@ Namely:
--conf spark.driver.extraJavaOptions=-Dfile.encoding=utf-8 \
--conf spark.executor.extraJavaOptions=-Dfile.encoding=utf-8 \
--class com.vesoft.nebula.exchange.Exchange \
<nebula-exchange-2.x.y.jar_path> -c <application.conf_path>
<nebula-exchange-3.x.y.jar_path> -c <application.conf_path>
```

In YARN, use the following command:
Expand All @@ -137,7 +137,7 @@ In YARN, use the following command:
--conf spark.executor.extraClassPath=./ \
--conf spark.driver.extraJavaOptions=-Dfile.encoding=utf-8 \
--conf spark.executor.extraJavaOptions=-Dfile.encoding=utf-8 \
<nebula-exchange-2.x.y.jar_path> \
<nebula-exchange-3.x.y.jar_path> \
-c application.conf
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ After Exchange is compiled, copy the conf file `target/classes/application.conf`
# Spark configuration
spark: {
app: {
name: Nebula Exchange 2.0
name: Nebula Exchange {{exchange.release}}
}
master:local
Expand Down

0 comments on commit ff1a4ec

Please sign in to comment.