Index stores temporary RIDs for vertices created in transaction (remote storage)

29 views
Skip to first unread message

BK

unread,
May 26, 2015, 10:25:50 PM5/26/15
to orient-...@googlegroups.com
Looking for feedback on whether to create an issue: 
Using OrientDB 2.1-rc3 and remote storage, an index on edge in/out link properties will store the temporary (negative) RIDs for endpoint vertices created in the same transaction as an edge.  (This does not happen if memory storage is used - the permanent RIDs are correctly stored in the index in that case.)

Example output (sample code below):
Vertices: #11:0 #11:1 #11:2 #11:3 #11:4 

Index data: CustomEdge.in
key: #-1:-7, rid: CustomEdge#12:3{out:#11:0,in:#11:1} v2
key: #-1:-5, rid: CustomEdge#12:2{out:#11:1,in:#11:2} v2
key: #-1:-3, rid: CustomEdge#12:1{out:#11:2,in:#11:3} v2
key: #-1:-2, rid: CustomEdge#12:0{out:#11:3,in:#11:4} v2

Index data: CustomEdge.out
key: #-1:-9, rid: CustomEdge#12:3{out:#11:0,in:#11:1} v2
key: #-1:-7, rid: CustomEdge#12:2{out:#11:1,in:#11:2} v2
key: #-1:-5, rid: CustomEdge#12:1{out:#11:2,in:#11:3} v2
key: #-1:-3, rid: CustomEdge#12:0{out:#11:3,in:#11:4} v2

Index data: CustomEdge.compositeInOut
key: OCompositeKey{keys=[#-1:-9, #-1:-7]}, rid: CustomEdge#12:3{out:#11:0,in:#11:1} v2
key: OCompositeKey{keys=[#-1:-7, #-1:-5]}, rid: CustomEdge#12:2{out:#11:1,in:#11:2} v2
key: OCompositeKey{keys=[#-1:-5, #-1:-3]}, rid: CustomEdge#12:1{out:#11:2,in:#11:3} v2
key: OCompositeKey{keys=[#-1:-3, #-1:-2]}, rid: CustomEdge#12:0{out:#11:3,in:#11:4} v2




Example code:
package com.example.orientdb.index;

import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientEdgeType;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
import com.tinkerpop.blueprints.impls.orient.OrientVertexType;

public class EdgeIndexTxProblem {
private static final String CUSTOM_VERTEX = "CustomVertex";
private static final String CUSTOM_EDGE = "CustomEdge";
private static final String IN_INDEX_NAME = CUSTOM_EDGE + ".in";
private static final String OUT_INDEX_NAME = CUSTOM_EDGE + ".out";
private static final String COMPOSITE_INDEX_NAME = CUSTOM_EDGE + ".compositeInOut";
public static void main(String[] args) {
OrientGraphFactory graphFactory = null;
// Use NoTx for schema config to avoid warning messages
OrientGraphNoTx graphNoTx = null;
OrientGraph graph = null;
try {
graphFactory = new OrientGraphFactory("remote:localhost/edgeTxProblem", "user", "pass");
graphNoTx = graphFactory.getNoTx();
OrientVertexType vertexType = null;
if( ! graphNoTx.getRawGraph().existsCluster(CUSTOM_VERTEX)) {
vertexType = graphNoTx.createVertexType(CUSTOM_VERTEX);
}
else {
vertexType = graphNoTx.getVertexType(CUSTOM_VERTEX);
}
if( ! graphNoTx.getRawGraph().existsCluster(CUSTOM_EDGE)) {
OrientEdgeType edgeType = graphNoTx.createEdgeType(CUSTOM_EDGE);
edgeType.createProperty("out", OType.LINK, vertexType);
edgeType.createProperty("in", OType.LINK, vertexType);
edgeType.createIndex(IN_INDEX_NAME, OClass.INDEX_TYPE.UNIQUE, "in");
edgeType.createIndex(OUT_INDEX_NAME, OClass.INDEX_TYPE.UNIQUE, "out");
edgeType.createIndex(COMPOSITE_INDEX_NAME, OClass.INDEX_TYPE.UNIQUE, "out", "in");
}
graphNoTx.shutdown();
graph = graphFactory.getTx();
Vertex inVert = null;
for(int i = 0; i < 5; ++i) {
Vertex currentVert = graph.addVertex("class:" + CUSTOM_VERTEX);
if(inVert != null) {
graph.addEdge("class:" + CUSTOM_EDGE, currentVert, inVert, CUSTOM_EDGE);
}
inVert = currentVert;
}
graph.commit();
Iterable<Vertex> verts = graph.getVertices();
StringBuilder vertIds = new StringBuilder();
for(Vertex vert : verts) {
vertIds.append(vert.getId().toString()).append(" ");
}
System.out.println("Vertices: " + vertIds);
System.out.println();
printIndexData(graph, IN_INDEX_NAME);
printIndexData(graph, OUT_INDEX_NAME);
printIndexData(graph, COMPOSITE_INDEX_NAME);
}
finally {
if(graphNoTx != null) {
try {
graphNoTx.shutdown();
}
catch(Throwable t) {
System.err.println("Error shutting down graphNoTx:" + t);
}
}
if(graph != null) {
try {
graph.shutdown();
}
catch(Throwable t) {
System.err.println("Error shutting down graph:" + t);
}
}
if(graphFactory != null) {
graphFactory.close();
}
}
}
private static void printIndexData(OrientGraph graph, String indexName) {
System.out.println("Index data: " + indexName);
Iterable<ODocument> indexDataDocs = graph.getRawGraph().query(
new OSQLSynchQuery<ODocument>("select from index:" + indexName));
for(ODocument indexDataDoc : indexDataDocs) {
System.out.println("key: " + indexDataDoc.field("key") + ", rid: " + indexDataDoc.field("rid"));
}
System.out.println("");
}
}


Andrey Lomakin

unread,
May 27, 2015, 1:50:36 AM5/27/15
to orient-database
Hi,
Could you open issue ?

--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Best regards,
Andrey Lomakin.

BK

unread,
May 27, 2015, 2:24:17 PM5/27/15
to orient-...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages