尝试使用ArangoDB Java API创建顶点和边,没有激活批处理模式时,一切正常。但是当启用批处理模式时,创建顶点时会抛出未知错误。以下是Java代码和异常详细信息。 有任何想法为什么会发生这种情况吗? 提前感谢!
代码
public static void main(String[] args) throws ArangoException {
createNodesInBatch();
}
static public void createNodesInBatch() throws ArangoException {
ArangoConfigure configure = new ArangoConfigure();
configure.init();
ArangoDriver arangoDriver = new ArangoDriver(configure);
arangoDriver.createDatabase("small_db");
System.out.println("Database created.");
arangoDriver.setDefaultDatabase("small_db");
arangoDriver.createCollection("testEdgeCollection",
new CollectionOptions().setType(CollectionType.EDGE));
arangoDriver.createCollection("testVertexCollection",
new CollectionOptions().setType(CollectionType.DOCUMENT));
EdgeDefinitionEntity ed = new EdgeDefinitionEntity();
// add edge collection name
ed.setCollection("testEdgeCollection");
// add vertex collection names
ed.getFrom().add("testVertexCollection");
// add vertex collection names
ed.getTo().add("testVertexCollection");
List<EdgeDefinitionEntity> edgeDefinitions = new ArrayList<EdgeDefinitionEntity>();
edgeDefinitions.add(ed);
arangoDriver.createGraph("testGraph", edgeDefinitions, null, false);
System.out.println("Graph created.");
arangoDriver.startBatchMode();;
System.out.println("Batch mode started.");
for (int nodeIdx = 0; nodeIdx < 10; nodeIdx++)
{
String nodeName = "node_" + nodeIdx;
SimpleNode node = new SimpleNode(nodeName);
VertexEntity<SimpleNode> vertex = arangoDriver.graphCreateVertex("testGraph", "vertextCollection", node, false);
}
System.out.println("Batch execution started to create nodes");
arangoDriver.executeBatch();
}
异常信息
数据库已创建。
图形已创建。
批处理模式已启动。
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy14.createVertex(Unknown Source)
at com.arangodb.ArangoDriver.graphCreateVertex(ArangoDriver.java:4570)
at WhichDB.ArangoDBTest.App.createNodesInBatch(App.java:311)
at WhichDB.ArangoDBTest.App.main(App.java:327)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.arangodb.http.InvocationHandlerImpl.invoke(InvocationHandlerImpl.java:38)
... 4 more
Caused by: com.arangodb.ArangoException: unknown error
at com.arangodb.impl.InternalGraphDriverImpl.createVertex(InternalGraphDriverImpl.java:329)
at com.arangodb.impl.InternalGraphDriverImpl.createVertex(InternalGraphDriverImpl.java:294)
... 9 more