use of com.tinkerpop.blueprints.Vertex in project orientdb by orientechnologies.
the class AbstractShardingScenarioTest method loadVertex.
protected OrientVertex loadVertex(OrientBaseGraph graph, String shardName, int serverId, int threadId, int i) {
List<OrientVertex> result = null;
try {
final String uniqueId = shardName + "-s" + serverId + "-t" + threadId + "-v" + i;
Iterable<Vertex> it = graph.command(new OCommandSQL("select from Client where name = '" + uniqueId + "'")).execute();
result = new LinkedList<OrientVertex>();
for (Vertex v : it) {
result.add((OrientVertex) v);
}
if (result.size() == 0)
fail("No record found with name = '" + uniqueId + "'!");
else if (result.size() > 1)
fail(result.size() + " records found with name = '" + uniqueId + "'!");
if (result.size() > 0)
return result.get(0);
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Error in loadVertex(): " + e.toString());
}
return null;
}
use of com.tinkerpop.blueprints.Vertex in project orientdb by orientechnologies.
the class ConcurrentDistributedUpdateTest method executeTest.
@Override
public void executeTest() throws Exception {
OrientBaseGraph orientGraph = new OrientGraphNoTx(getPlocalDatabaseURL(serverInstance.get(0)));
OClass clazz = orientGraph.getVertexType("Test");
if (clazz == null) {
log("Creating vertex type - " + "Test");
orientGraph.createVertexType("Test");
}
orientGraph.shutdown();
OrientBaseGraph graph = new OrientGraphNoTx(getPlocalDatabaseURL(serverInstance.get(0)));
for (int i = 0; i < 2; i++) {
Vertex vertex = graph.addVertex("class:Test");
vertex.setProperty("prop1", "v1-" + i);
vertex.setProperty("prop2", "v2-1");
vertex.setProperty("prop3", "v3-1");
graph.commit();
if ((i % 100) == 0) {
log("Created " + i + " nodes");
}
}
graph.shutdown();
executeMultipleTest();
}
use of com.tinkerpop.blueprints.Vertex in project orientdb by orientechnologies.
the class StandAloneDatabaseJavaThreadPoolTest method runTest.
public void runTest() {
OrientBaseGraph orientGraph = new OrientGraphNoTx(getDBURL());
createVertexType(orientGraph, "Test");
createVertexType(orientGraph, "Test1");
orientGraph.shutdown();
OrientBaseGraph graph = getGraphFactory().getTx();
for (int i = 1; i <= 1; i++) {
Vertex vertex = graph.addVertex("class:Test");
vertex.setProperty("prop1", "v1-" + i);
vertex.setProperty("prop2", "v2-1");
vertex.setProperty("prop3", "v3-1");
graph.commit();
if ((i % 100) == 0) {
log("Created " + i + " nodes");
}
}
for (int i = 1; i <= 200; i++) {
Vertex vertex = graph.addVertex("class:Test1");
vertex.setProperty("prop1", "v1-" + i);
vertex.setProperty("prop2", "v2-1");
vertex.setProperty("prop3", "v3-1");
graph.commit();
if ((i % 10) == 0) {
System.out.print("." + i + ".");
}
if ((i % 100) == 0) {
System.out.println();
}
}
graph.shutdown();
// startPoolInfoThread();
List<Future<?>> ths = new ArrayList<Future<?>>();
for (int i = 0; i < 10; i++) {
Future<?> future = getExecutorService().submit(startThread(i, getGraphFactory()));
ths.add(future);
}
for (Future<?> th : ths) {
try {
th.get();
} catch (Exception ex) {
System.out.println("********** Future Exception " + ex);
ex.printStackTrace();
}
}
}
use of com.tinkerpop.blueprints.Vertex in project orientdb by orientechnologies.
the class OSQLFunctionMove method e2v.
protected Object e2v(final OrientBaseGraph graph, final OIdentifiable iRecord, final Direction iDirection, final String[] iLabels) {
final ODocument rec = iRecord.getRecord();
OImmutableClass clazz = ODocumentInternal.getImmutableSchemaClass(rec);
if (clazz != null && clazz.isEdgeType()) {
// EDGE
final OrientEdge edge = graph.getEdge(rec);
if (edge != null) {
if (Direction.BOTH.equals(iDirection)) {
Set<Vertex> result = new HashSet<Vertex>();
result.add(edge.getVertex(Direction.OUT));
result.add(edge.getVertex(Direction.IN));
return result;
} else {
return edge.getVertex(iDirection);
}
}
}
return null;
}
use of com.tinkerpop.blueprints.Vertex in project orientdb by orientechnologies.
the class OSQLFunctionPathFinder method getNeighbors.
protected Set<OrientVertex> getNeighbors(final Vertex node) {
context.incrementVariable("getNeighbors");
final Set<OrientVertex> neighbors = new HashSet<OrientVertex>();
if (node != null) {
for (Vertex v : node.getVertices(paramDirection)) {
final OrientVertex ov = (OrientVertex) v;
if (ov != null && isNotSettled(ov))
neighbors.add(ov);
}
}
return neighbors;
}
Aggregations