use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class TestGraphRecovering method testRecoverBrokenGraphAllEdges.
@Test
public void testRecoverBrokenGraphAllEdges() {
final OrientBaseGraph g = new OrientGraphNoTx("memory:testRecoverBrokenGraphAllEdges");
try {
init(g, false);
for (Edge e : g.getEdges()) {
((OrientEdge) e).getRecord().removeField("out");
((OrientEdge) e).getRecord().save();
}
final TestListener eventListener = new TestListener();
new OGraphRepair().setEventListener(eventListener).repair(g, null, null);
Assert.assertEquals(eventListener.scannedEdges, 3);
Assert.assertEquals(eventListener.removedEdges, 3);
Assert.assertEquals(eventListener.scannedVertices, 3);
Assert.assertEquals(eventListener.scannedLinks, 6);
Assert.assertEquals(eventListener.removedLinks, 6);
Assert.assertEquals(eventListener.repairedVertices, 3);
} finally {
g.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class TestGraphRecovering method testRecoverBrokenGraphLinksInVerticesNonLW.
@Test
public void testRecoverBrokenGraphLinksInVerticesNonLW() {
final OrientBaseGraph g = new OrientGraphNoTx("memory:testRecoverBrokenGraphLinksInVerticesNonLW");
try {
init(g, false);
for (Vertex v : g.getVertices()) {
for (String f : ((OrientVertex) v).getRecord().fieldNames()) {
if (f.startsWith("out_"))
((OrientVertex) v).getRecord().removeField(f);
}
}
final TestListener eventListener = new TestListener();
new OGraphRepair().setEventListener(eventListener).repair(g, null, null);
Assert.assertEquals(eventListener.scannedEdges, 3);
Assert.assertEquals(eventListener.removedEdges, 3);
Assert.assertEquals(eventListener.scannedVertices, 3);
Assert.assertEquals(eventListener.scannedLinks, 3);
Assert.assertEquals(eventListener.removedLinks, 3);
Assert.assertEquals(eventListener.repairedVertices, 3);
} finally {
g.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class TestGraphRecovering method testRecoverBrokenGraphLinksInVerticesLW.
@Test
public void testRecoverBrokenGraphLinksInVerticesLW() {
final OrientBaseGraph g = new OrientGraphNoTx("memory:testRecoverBrokenGraphLinksInVerticesLW");
try {
init(g, true);
for (Vertex v : g.getVertices()) {
final ODocument record = ((OrientVertex) v).getRecord();
int key = v.getProperty("key");
if (key == 0)
record.field("out_", record);
else if (key == 1)
record.field("in_E1", new ORecordId(100, 200));
else if (key == 2)
record.field("out_E2", record);
record.save();
}
final TestListener eventListener = new TestListener();
new OGraphRepair().setEventListener(eventListener).repair(g, null, null);
Assert.assertEquals(eventListener.scannedEdges, 0);
Assert.assertEquals(eventListener.removedEdges, 0);
Assert.assertEquals(eventListener.scannedVertices, 3);
Assert.assertEquals(eventListener.scannedLinks, 7);
Assert.assertEquals(eventListener.removedLinks, 5);
Assert.assertEquals(eventListener.repairedVertices, 3);
} finally {
g.shutdown();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class LuceneGraphTXTest method graphTxTest.
@Test
public void graphTxTest() throws Exception {
OrientGraph graph = new OrientGraph("memory:graphTx");
try {
graph.executeOutsideTx(new OCallable<Object, OrientBaseGraph>() {
@Override
public Object call(OrientBaseGraph graph) {
OrientVertexType city = graph.createVertexType("City");
city.createProperty("name", OType.STRING);
graph.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
return null;
}
});
OrientVertex v = graph.addVertex("class:City", "name", "London");
v.save();
Collection results = graph.getRawGraph().command(new OCommandSQL("select from City where name lucene 'London'")).execute();
Assert.assertEquals(results.size(), 1);
v.setProperty("name", "Berlin");
v.save();
results = graph.getRawGraph().command(new OCommandSQL("select from City where name lucene 'Berlin'")).execute();
Assert.assertEquals(results.size(), 1);
results = graph.getRawGraph().command(new OCommandSQL("select from City where name lucene 'London'")).execute();
Assert.assertEquals(results.size(), 0);
graph.commit();
// Assert After Commit
results = graph.getRawGraph().command(new OCommandSQL("select from City where name lucene 'Berlin'")).execute();
Assert.assertEquals(results.size(), 1);
results = graph.getRawGraph().command(new OCommandSQL("select from City where name lucene 'London'")).execute();
Assert.assertEquals(results.size(), 0);
} finally {
graph.drop();
}
}
use of com.tinkerpop.blueprints.impls.orient.OrientBaseGraph in project orientdb by orientechnologies.
the class BlueprintsConcurrentGraphChangesTestNoTx method assertCreatedGraph.
private void assertCreatedGraph() {
OrientBaseGraph graph = getGraph();
graph.setUseLightweightEdges(false);
Assert.assertEquals(VERTEXES_COUNT, graph.countVertices("TestVertex"));
Assert.assertEquals(EDGES_COUNT, graph.countEdges("TestEdge"));
for (TestVertex vertex : vertexes) {
Iterable<Vertex> vertexes = graph.command(new OSQLSynchQuery<Vertex>("select from TestVertex where uuid = '" + vertex.uuid + "'")).execute();
Assert.assertTrue(vertexes.iterator().hasNext());
}
for (TestEdge edge : edges) {
Iterable<Edge> edges = graph.command(new OSQLSynchQuery<Edge>("select from TestEdge where uuid = '" + edge.uuid + "'")).execute();
Assert.assertTrue(edges.iterator().hasNext());
}
for (TestVertex vertex : vertexes) {
Iterable<Vertex> vertexes = graph.command(new OSQLSynchQuery<Vertex>("select from TestVertex where uuid = '" + vertex.uuid + "'")).execute();
Assert.assertTrue(vertexes.iterator().hasNext());
Vertex gVertex = vertexes.iterator().next();
Iterable<Edge> outEdges = gVertex.getEdges(Direction.OUT);
Iterator<Edge> outGEdgesIterator = outEdges.iterator();
int counter = 0;
while (outGEdgesIterator.hasNext()) {
counter++;
Edge gEdge = outGEdgesIterator.next();
TestEdge testEdge = new TestEdge();
testEdge.uuid = gEdge.getProperty("uuid");
Assert.assertTrue(vertex.outEdges.contains(testEdge));
}
Assert.assertEquals(vertex.outEdges.size(), counter);
Iterable<Edge> inEdges = gVertex.getEdges(Direction.IN);
Iterator<Edge> inGEdgesIterator = inEdges.iterator();
counter = 0;
while (inGEdgesIterator.hasNext()) {
counter++;
Edge gEdge = inGEdgesIterator.next();
TestEdge testEdge = new TestEdge();
testEdge.uuid = gEdge.getProperty("uuid");
Assert.assertTrue(vertex.inEdges.contains(testEdge));
}
Assert.assertEquals(vertex.inEdges.size(), counter);
}
assertGraphIsConsistent(graph);
graph.shutdown();
}
Aggregations