use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class EdgeIndexingTest method testOutLinksUniquenessThree.
/**
* Test that "out_vertex" has edges to only single "in_vertex" but we may have several edges to single "in_vertex".
*/
@Test
public void testOutLinksUniquenessThree() {
final String url = "memory:" + this.getClass().getSimpleName();
OrientGraph graph = new OrientGraph(url, "admin", "admin", false);
graph.drop();
graph = new OrientGraph(url, "admin", "admin", false);
graph.setUseLightweightEdges(true);
graph.createEdgeType("link");
OClass inVertexType = graph.createVertexType("IndexedInVertex");
inVertexType.createProperty("in_link", OType.LINKBAG);
inVertexType.createIndex("uniqueLinkIndex", "unique", "in_link");
graph.setAutoStartTx(true);
Vertex vertexOutOne = graph.addVertex(null);
Vertex vertexInOne = graph.addVertex("class:IndexedInVertex");
Vertex vertexInTwo = graph.addVertex("class:IndexedInVertex");
vertexOutOne.addEdge("link", vertexInOne);
vertexOutOne.addEdge("link", vertexInTwo);
try {
graph.commit();
Assert.fail();
// in vertex can be linked by only one out vertex.
} catch (ORecordDuplicatedException e) {
}
graph.drop();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class EdgeIndexingTest method testOutLinksUniquenessTwo.
/**
* Test that "in_vertex" has edges to only single "out_vertex" but we may have several edges to single "out_vertex".
*/
@Test
public void testOutLinksUniquenessTwo() {
final String url = "memory:" + this.getClass().getSimpleName();
OrientGraph graph = new OrientGraph(url);
graph.drop();
graph = new OrientGraph(url);
graph.setUseLightweightEdges(true);
graph.createEdgeType("link");
graph.setAutoStartTx(false);
OClass outVertexType = graph.createVertexType("IndexedOutVertex");
outVertexType.createProperty("out_link", OType.LINKBAG);
outVertexType.createIndex("uniqueLinkIndex", "unique", "out_link");
graph.setAutoStartTx(true);
Vertex vertexOutOne = graph.addVertex("class:IndexedOutVertex");
Vertex vertexInOne = graph.addVertex(null);
Vertex vertexInTwo = graph.addVertex(null);
vertexOutOne.addEdge("link", vertexInOne);
vertexOutOne.addEdge("link", vertexInTwo);
Vertex vertexOutTwo = graph.addVertex("class:IndexedOutVertex");
vertexOutTwo.addEdge("link", vertexInTwo);
try {
graph.commit();
// in vertex can be linked by only one out vertex.
Assert.fail();
} catch (ORecordDuplicatedException e) {
}
graph.drop();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class EdgeSaveShouldNotReinsertVerticesTest method test.
@Test
public void test() {
final OrientGraph graph = factory.getTx();
graph.createVertexType("Person").createProperty("name", OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE_HASH_INDEX);
graph.begin();
final OrientVertex v1 = graph.addVertex("class:Person", "name", "1");
final OrientVertex v2 = graph.addVertex("class:Person", "name", "2");
v1.setProperty("name", "2");
v2.setProperty("name", "1");
// At this point v1 and v2 are considered new, not updated, by internals of ODirtyManager, during the save of created edge
// they got reinserted into indexes and storage (?).
v1.addEdge("edge", v2);
v1.setProperty("name", "1");
v2.setProperty("name", "2");
graph.commit();
graph.shutdown();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class GraphFunctionsTest method before.
@BeforeClass
public static void before() {
graph = new OrientGraph(DB_URL);
if (graph.getEdgeType("SubEdge") == null)
graph.createEdgeType("SubEdge");
if (graph.getVertexType("SubVertex") == null)
graph.createVertexType("SubVertex");
v1 = graph.addVertex("class:SubVertex");
v2 = graph.addVertex("class:SubVertex");
v3 = graph.addVertex(null);
e1 = graph.addEdge("class:SubEdge", v1, v2, null);
e2 = graph.addEdge(null, v1, v3, "contains");
graph.commit();
}
use of com.tinkerpop.blueprints.impls.orient.OrientGraph in project orientdb by orientechnologies.
the class OrderedEdgesGraphTest method testReplacePosition.
@Test
public void testReplacePosition() {
OrientVertex loadedPerson;
List<ODocument> edges;
try {
loadedPerson = graph.getVertex(mainPerson.getId());
graph.setUseLightweightEdges(true);
int i = 1;
edges = loadedPerson.getRecord().field("out_Knows");
ODocument edge10 = edges.remove(9);
edges.add(edge10);
} finally {
graph.shutdown();
}
graph = new OrientGraph(DB_URL);
try {
graph.setUseLightweightEdges(true);
loadedPerson = graph.getVertex(mainPerson.getId());
edges = loadedPerson.getRecord().field("out_Knows");
assertEquals(graph.getVertex(edges.get(9)).getProperty("index"), 11);
assertEquals(graph.getVertex(edges.get(99)).getProperty("index"), 10);
} finally {
graph.shutdown();
}
}
Aggregations