Search in sources :

Example 26 with OrientVertexType

use of com.tinkerpop.blueprints.impls.orient.OrientVertexType 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();
    }
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) Collection(java.util.Collection) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OrientBaseGraph(com.tinkerpop.blueprints.impls.orient.OrientBaseGraph) Test(org.junit.Test)

Example 27 with OrientVertexType

use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.

the class LuceneIndexCreateDropTest method init.

@Before
public void init() {
    OrientGraph graph = new OrientGraph(db, false);
    OrientVertexType type = graph.createVertexType("City");
    type.createProperty("name", OType.STRING);
    db.command(new OCommandSQL("create index City.name on City (name) FULLTEXT ENGINE LUCENE")).execute();
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType) Before(org.junit.Before)

Example 28 with OrientVertexType

use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.

the class LuceneTransactionCompositeQueryTest method init.

@Before
public void init() {
    final OrientVertexType c1 = new OrientGraphNoTx(db).createVertexType("Foo");
    c1.createProperty("name", OType.STRING);
    c1.createProperty("bar", OType.STRING);
    c1.createIndex("Foo.bar", "FULLTEXT", null, null, "LUCENE", new String[] { "bar" });
    c1.createIndex("Foo.name", "NOTUNIQUE", null, null, "SBTREE", new String[] { "name" });
}
Also used : OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType) OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) Before(org.junit.Before)

Example 29 with OrientVertexType

use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.

the class IndexTest method testIndexEdgeComposite.

public void testIndexEdgeComposite() {
    OrientGraph graphNoTx = new OrientGraph((ODatabaseDocumentTx) database.getUnderlying());
    OrientVertexType vertexType = null;
    if (!graphNoTx.getRawGraph().existsCluster("CustomVertex")) {
        vertexType = graphNoTx.createVertexType("CustomVertex");
    } else {
        vertexType = graphNoTx.getVertexType("CustomVertex");
    }
    if (!graphNoTx.getRawGraph().existsCluster("CustomEdge")) {
        OrientEdgeType edgeType = graphNoTx.createEdgeType("CustomEdge");
        edgeType.createProperty("out", OType.LINK, vertexType);
        edgeType.createProperty("in", OType.LINK, vertexType);
        edgeType.createIndex("CustomEdge.in", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "in" });
        edgeType.createIndex("CustomEdge.out", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "out" });
        edgeType.createIndex("CustomEdge.compositeInOut", OClass.INDEX_TYPE.UNIQUE.toString(), null, new ODocument().fields("ignoreNullValues", true), new String[] { "out", "in" });
    }
    // graphNoTx.shutdown();
    OrientGraph graph = new OrientGraph((ODatabaseDocumentTx) database.getUnderlying());
    Vertex inVert = null;
    for (int i = 0; i < 5; ++i) {
        Vertex currentVert = graph.addVertex("class:CustomVertex");
        if (inVert != null) {
            graph.addEdge("class:CustomEdge", currentVert, inVert, "CustomEdge");
        }
        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();
    checkIndexKeys(graph, "CustomEdge.in");
    checkIndexKeys(graph, "CustomEdge.out");
    checkIndexKeys(graph, "CustomEdge.compositeInOut");
}
Also used : OrientEdgeType(com.tinkerpop.blueprints.impls.orient.OrientEdgeType) Vertex(com.tinkerpop.blueprints.Vertex) OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 30 with OrientVertexType

use of com.tinkerpop.blueprints.impls.orient.OrientVertexType in project orientdb by orientechnologies.

the class PLocalCreateVerticesMultiThreadSpeedTest method init.

@Override
public void init() {
    final OrientGraphNoTx graph = factory.getNoTx();
    try {
        if (graph.getVertexType("Client") == null) {
            final OrientVertexType clientType = graph.createVertexType("Client");
            final OrientVertexType.OrientVertexProperty property = clientType.createProperty("uid", OType.STRING);
            property.createIndex(OClass.INDEX_TYPE.UNIQUE_HASH_INDEX);
            // CREATE ONE CLUSTER PER THREAD
            for (int i = 0; i < getThreads(); ++i) {
                System.out.println("Creating cluster: client_" + i + "...");
                clientType.addCluster("client_" + i);
            }
            foundObjects = 0;
        } else
            foundObjects = graph.countVertices("Client");
    } finally {
        graph.shutdown();
    }
}
Also used : OrientGraphNoTx(com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType)

Aggregations

OrientVertexType (com.tinkerpop.blueprints.impls.orient.OrientVertexType)31 OrientGraphNoTx (com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx)17 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)13 OrientGraph (com.tinkerpop.blueprints.impls.orient.OrientGraph)12 Test (org.junit.Test)9 OCommandSQL (com.orientechnologies.orient.core.sql.OCommandSQL)8 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)5 OrientEdgeType (com.tinkerpop.blueprints.impls.orient.OrientEdgeType)5 Vertex (com.tinkerpop.blueprints.Vertex)4 OrientGraphFactory (com.tinkerpop.blueprints.impls.orient.OrientGraphFactory)4 Before (org.junit.Before)4 OSQLSynchQuery (com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)3 OrientBaseGraph (com.tinkerpop.blueprints.impls.orient.OrientBaseGraph)3 OValidationException (com.orientechnologies.orient.core.exception.OValidationException)2 ORecordId (com.orientechnologies.orient.core.id.ORecordId)2 OClass (com.orientechnologies.orient.core.metadata.schema.OClass)2 OSchema (com.orientechnologies.orient.core.metadata.schema.OSchema)2 ONeedRetryException (com.orientechnologies.common.concur.ONeedRetryException)1 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)1 ORID (com.orientechnologies.orient.core.id.ORID)1