[Question] graph.addVertex NPE in hugeclient (duplicate)
Closed this issue · 2 comments
Problem Type (问题类型)
other exception / error (其他异常报错)
Before submit
- 我已经确认现有的 Issues 与 FAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)
Environment (环境信息)
- Server Version: 1.0.0 (Apache Release Version)
- Backend: RocksDB x nodes, HDD or SSD
- OS: xx CPUs, xx G RAM, Ubuntu 2x.x / CentOS 7.x
- Data Size: xx vertices, xx edges
Your Question (问题描述)
java
public class HiveSqlStatementsParser extends HiveSqlBaseVisitor {
@OverRide
public Object visitCreate_table_stmt(HiveSqlParser.Create_table_stmtContext ctx) {
HugeClient hugeClient = ConstellHugeClient.getInstance();
GraphManager graph = hugeClient.graph();
Vertex zhangsan = graph.addVertex(T.label, "人物", "name", "张三",
"age", 29, "city", "Beijing");
System.out.println("+++++");
报错为
Exception in thread "main" class java.lang.IllegalArgumentException: The properties of vertex can't be null
at com.baidu.hugegraph.exception.ServerException.fromResponse(ServerException.java:47)
at com.baidu.hugegraph.client.RestClient.checkStatus(RestClient.java:93)
at com.baidu.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:231)
at com.baidu.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:205)
at com.baidu.hugegraph.api.graph.VertexAPI.create(VertexAPI.java:51)
at com.baidu.hugegraph.driver.GraphManager.addVertex(GraphManager.java:59)
at com.baidu.hugegraph.driver.GraphManager.addVertex(GraphManager.java:74)
但是这段代码
HugeClient hugeClient = ConstellHugeClient.getInstance();
GraphManager graph = hugeClient.graph();
Vertex zhangsan = graph.addVertex(T.label, "人物", "name", "张三",
"age", 29, "city", "Beijing");
放入main函数中是正常的
Vertex/Edge example (问题点 / 边数据举例)
No response
Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
schema.propertyKey("name").asText().ifNotExist().create();
schema.propertyKey("age").asInt().ifNotExist().create();
schema.propertyKey("city").asText().ifNotExist().create();
schema.propertyKey("weight").asDouble().ifNotExist().create();
schema.propertyKey("lang").asText().ifNotExist().create();
schema.propertyKey("date").asDate().ifNotExist().create();
schema.propertyKey("price").asInt().ifNotExist().create();
schema.vertexLabel("人物")
.properties("name", "age", "city")
.primaryKeys("name")
.ifNotExist()
.create();
which client version use?
'com.baidu.hugegraph.exception'
if your server version is 1.0.0, your java client may be 1.0.0
<!--for hugegraph1.0.0 dependency-->
<dependency>
<groupId>org.apache.hugegraph</groupId>
<artifactId>hugegraph-client</artifactId>
<version>1.0.0</version>
</dependency>
对的,是jar包冲突了,谢谢您的回答