|
11 | 11 | |Nebula Graph 版本|Nebula Java 版本|
|
12 | 12 | |:---|:---|
|
13 | 13 | |{{ nebula.release }}|{{java.release}}|
|
14 |
| -|2.0.1|2.0.0| |
15 |
| -|2.0.0|2.0.0| |
| 14 | +|2.6.x|2.6.1| |
| 15 | +|2.0.x|2.0.0| |
16 | 16 | |2.0.0-rc1|2.0.0-rc1|
|
17 | 17 |
|
18 | 18 | ## 下载 Nebula Java
|
19 | 19 |
|
20 | 20 | - (推荐)如果需要使用指定版本的 Nebula Java,请使用选项`--branch`指定分支。例如使用 v{{ java.release }}发布版本,请执行如下命令:
|
21 | 21 |
|
22 | 22 | ```bash
|
23 |
| - $ git clone --branch v{{ java.release }} https://github.com/vesoft-inc/nebula-java.git |
| 23 | + $ git clone --branch {{java.branch}} https://github.com/vesoft-inc/nebula-java.git |
24 | 24 | ```
|
25 | 25 |
|
26 | 26 | - 如果需要安装日常开发版本,请执行如下命令下载`master`分支的源码:
|
|
39 | 39 |
|
40 | 40 | !!! note
|
41 | 41 |
|
42 |
| - `2.0.0-SNAPSHOT`为日常研发版本,可能存在未知问题,建议使用 release 版本号替换`2.0.0-SNAPSHOT`。 |
| 42 | + `3.0.0-SNAPSHOT`为日常研发版本,可能存在未知问题,建议使用 release 版本号替换`3.0.0-SNAPSHOT`。 |
43 | 43 |
|
44 | 44 | ```bash
|
45 | 45 | <dependency>
|
46 | 46 | <groupId>com.vesoft</groupId>
|
47 | 47 | <artifactId>client</artifactId>
|
48 |
| - <version>2.0.0-SNAPSHOT</version> |
| 48 | + <version>3.0.0-SNAPSHOT</version> |
49 | 49 | </dependency>
|
50 | 50 | ```
|
51 | 51 |
|
|
64 | 64 |
|
65 | 65 | ### 核心代码
|
66 | 66 |
|
67 |
| -详细示例请参见 [GraphClientExample](https://github.com/vesoft-inc/nebula-java/blob/master/examples/src/main/java/com/vesoft/nebula/examples/GraphClientExample.java)。 |
68 |
| - |
69 |
| -```java |
70 |
| -NebulaPool pool = new NebulaPool(); |
71 |
| -Session session = null; |
72 |
| -try { |
73 |
| - NebulaPoolConfig nebulaPoolConfig = new NebulaPoolConfig(); |
74 |
| - nebulaPoolConfig.setMaxConnSize(100); |
75 |
| - List<HostAddress> addresses = Arrays.asList(new HostAddress("192.168.xx.1", 9669), |
76 |
| - new HostAddress("192.168.xx.2", 9670)); |
77 |
| - pool.init(addresses, nebulaPoolConfig); |
78 |
| - session = pool.getSession("root", "nebula", false); |
79 |
| - |
80 |
| - //create space |
81 |
| - String space = "test"; |
82 |
| - String createSpace = "CREATE SPACE IF NOT EXISTS " + space + " (partition_num=15, replica_factor=1, vid_type=fixed_string(30)); "; |
83 |
| - ResultSet resp = session.execute(createSpace); |
84 |
| - |
85 |
| - //create schema |
86 |
| - String createSchema = "USE " + space + "; CREATE TAG IF NOT EXISTS person(name string, age int);" |
87 |
| - + "CREATE EDGE IF NOT EXISTS like(likeness double)"; |
88 |
| - ResultSet resp = session.execute(createSchema); |
89 |
| - |
90 |
| - //insert vertex |
91 |
| - String insertVertexes = "INSERT VERTEX person(name, age) VALUES " + "'Bob':('Bob', 10), " |
92 |
| - + "'Lily':('Lily', 9), " + "'Tom':('Tom', 10), " + "'Jerry':('Jerry', 13), " |
93 |
| - + "'John':('John', 11);"; |
94 |
| - ResultSet resp = session.execute(insertVertexes); |
95 |
| - |
96 |
| - // inert edge |
97 |
| - String insertEdges = "INSERT EDGE like(likeness) VALUES " + "'Bob'->'Lily':(80.0), " |
98 |
| - + "'Bob'->'Tom':(70.0), " + "'Lily'->'Jerry':(84.0), " + "'Tom'->'Jerry':(68.3), " |
99 |
| - + "'Bob'->'John':(97.2);"; |
100 |
| - ResultSet resp = session.execute(insertEdges); |
101 |
| - |
102 |
| - // query |
103 |
| - String query = "GO FROM \"Bob\" OVER like " + "YIELD properties($$).name, properties($$).age, properties(edge).likeness"; |
104 |
| - ResultSet resp = session.execute(query); |
105 |
| - printResult(resp); |
106 |
| -}finally { |
107 |
| - if (session != null) { |
108 |
| - session.release(); |
109 |
| - } |
110 |
| - pool.close(); |
111 |
| -} |
112 |
| -``` |
| 67 | +详细示例请参见 [GraphClientExample](https://github.com/vesoft-inc/nebula-java/blob/{{java.branch}}/examples/src/main/java/com/vesoft/nebula/examples/GraphClientExample.java)。 |
| 68 | + |
0 commit comments