东方DB顶点误差之间创建边,顶点利用东方DB SQL函数

我现在面临的问题创造顶点,其中顶点之一是通过使用SQL定向功能越来越之间的边缘,东方DB顶点误差之间创建边,顶点利用东方DB SQL函数

下面

阅读是要求

让我说我有3个顶点vertex1(@rid:#9:0),vertex2(@rid:#10:0),vertex3(@rid:#11:0)和边缘beteween vertex1和顶点2已经存在。 现在我需要从vertex2获得vertex1创造vertex1和vertex3之间的边缘

Graph graph = new OrientGraph("remote:localhost:2424/test", "username", "password"); 

String query = "select @rid ad base, inE('child').outV() as source from V where name='vertex3'";

OrientGraph oGraph = (OrientGraph)graph;

OCommandSQL oCommandSQL = new OCommandSQL(query);

Iterable<Vertex> vertices = oGraph.command(oCommandSQL).execute();

Iterator<Vertex> verticesIterator = vertices.iterator();

Vertex resultVertex = verticesIterator.next();

OrientElementIterable<Element> elements = resultVertex.getProperty("source");

Iterator<Element> elementIterator = elements.iterator();

Vertex sourceVertex = null;

while (elementIterator.hasNext()) {

sourceVertex = (Vertex) elementIterator.next();

}

Vertex v3 = graph.getVertex("#11:0");

Edge edge = graph.addEdge(null, v3, sourceVertex, "new");

graph.shutdown();

例外:

java.lang.IllegalArgumentException异常:群集段#-2不在数据库中存在 “测试' 在com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.checkClusterSegmentIndexRange(OAbstractPaginatedStorage.java:4627) 在com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.getClusterById(OAbstractPaginatedStorage.java :3013)(ODbabaseDocumentTx.java: 3411) 在com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.executeReadRecord(ODatabaseDocumentTx.java:2022) 在com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:187) 在com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:162) 在com.orientechnologies.orient.core.tx.OTransactionOptimistic.loadRecord(OTransactionOptimistic.java:291) 在com.orientechnologies.orient。 core.db.document.ODatabaseDocumentTx .load(ODatabaseDocumentTx.java:1739) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.load(ODatabaseDocumentTx.java:103) at com.orientechnologies.orient.core.id.ORecordId.getRecord(ORecordId .java:329) at com.orientechnologies.orient.server.tx.OTransactionOptimisticProxy.begin(OTransactionOptimisticProxy.java:176) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.begin(ODatabaseDocumentTx.java:1881 ) at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.begin(ODatabaseDocumentTx.java:103) at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.commit(ONetworkProtocolBinary.java:1426 ) at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.exe cuteRequest(ONetworkProtocolBinary.java:668) at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.sessionRequest(ONetworkProtocolBinary.java:398) at com.orientechnologies.orient.server.network.protocol.binary。 ONetworkProtocolBinary.execute(ONetworkProtocolBinary.java:217) at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread。Java的:82)

回答:

最后我得到了我的代码以UNWIND功能工作

String query = "select @rid ad base, inE('child').outV() as source from V where name='vertex3' UNWIND source"; 

我们还可以使用EXPAND功能

String query = "select @rid ad base, EXPAND(inE('child').outV()) as source from V where name='vertex3'"; 

但它会忽略多个投影

以下链接帮助我解决了这个问题

OrientDB SELECT and subqueries

https://github.com/orientechnologies/orientdb/issues/3755

http://orientdb.com/docs/last/SQL-Query.html#unwinding

谢谢

以上是 东方DB顶点误差之间创建边,顶点利用东方DB SQL函数 的全部内容, 来源链接: utcz.com/qa/261610.html

回到顶部