Search in sources :

Example 1 with Vertex

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;
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) Vertex(com.tinkerpop.blueprints.Vertex) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) ONeedRetryException(com.orientechnologies.common.concur.ONeedRetryException) ODistributedException(com.orientechnologies.orient.server.distributed.ODistributedException) ORecordDuplicatedException(com.orientechnologies.orient.core.storage.ORecordDuplicatedException) ORecordNotFoundException(com.orientechnologies.orient.core.exception.ORecordNotFoundException)

Example 2 with Vertex

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();
}
Also used : OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) Vertex(com.tinkerpop.blueprints.Vertex) OClass(com.orientechnologies.orient.core.metadata.schema.OClass) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)

Example 3 with Vertex

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();
        }
    }
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) Future(java.util.concurrent.Future) ONeedRetryException(com.orientechnologies.common.concur.ONeedRetryException) OConcurrentModificationException(com.orientechnologies.orient.core.exception.OConcurrentModificationException)

Example 4 with Vertex

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;
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OImmutableClass(com.orientechnologies.orient.core.metadata.schema.OImmutableClass) OrientEdge(com.tinkerpop.blueprints.impls.orient.OrientEdge) ODocument(com.orientechnologies.orient.core.record.impl.ODocument) HashSet(java.util.HashSet)

Example 5 with Vertex

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;
}
Also used : Vertex(com.tinkerpop.blueprints.Vertex) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) HashSet(java.util.HashSet)

Aggregations

Vertex (com.tinkerpop.blueprints.Vertex)406 Test (org.junit.Test)119 Edge (com.tinkerpop.blueprints.Edge)111 Graph (com.tinkerpop.blueprints.Graph)85 TinkerGraph (com.tinkerpop.blueprints.impls.tg.TinkerGraph)84 JSONObject (org.codehaus.jettison.json.JSONObject)51 HashSet (java.util.HashSet)49 ArrayList (java.util.ArrayList)40 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)37 GremlinPipeline (com.tinkerpop.gremlin.java.GremlinPipeline)28 HashMap (java.util.HashMap)25 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)22 JSONArray (org.codehaus.jettison.json.JSONArray)20 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)19 Test (org.testng.annotations.Test)16 KeyIndexableGraph (com.tinkerpop.blueprints.KeyIndexableGraph)15 Map (java.util.Map)15 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)14 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)13 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)11