Search in sources :

Example 26 with OIntentMassiveInsert

use of com.orientechnologies.orient.core.intent.OIntentMassiveInsert in project orientdb by orientechnologies.

the class LocalPaginatedStorageRestoreTx method testSimpleRestore.

public void testSimpleRestore() throws Exception {
    List<Future<Void>> futures = new ArrayList<Future<Void>>();
    baseDocumentTx.declareIntent(new OIntentMassiveInsert());
    for (int i = 0; i < 8; i++) futures.add(executorService.submit(new DataPropagationTask()));
    for (Future<Void> future : futures) future.get();
    Thread.sleep(1500);
    copyDataFromTestWithoutClose();
    OStorage storage = baseDocumentTx.getStorage();
    baseDocumentTx.close();
    storage.close();
    testDocumentTx = new ODatabaseDocumentTx("plocal:" + buildDir.getAbsolutePath() + "/testLocalPaginatedStorageRestoreFromTx");
    testDocumentTx.open("admin", "admin");
    testDocumentTx.close();
    ODatabaseCompare databaseCompare = new ODatabaseCompare(testDocumentTx.getURL(), baseDocumentTx.getURL(), "admin", "admin", new OCommandOutputListener() {

        @Override
        public void onMessage(String text) {
            System.out.println(text);
        }
    });
    databaseCompare.setCompareIndexMetadata(true);
    Assert.assertTrue(databaseCompare.compare());
}
Also used : ODatabaseCompare(com.orientechnologies.orient.core.db.tool.ODatabaseCompare) ArrayList(java.util.ArrayList) OStorage(com.orientechnologies.orient.core.storage.OStorage) ODatabaseDocumentTx(com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx) OIntentMassiveInsert(com.orientechnologies.orient.core.intent.OIntentMassiveInsert) Future(java.util.concurrent.Future) OCommandOutputListener(com.orientechnologies.orient.core.command.OCommandOutputListener)

Example 27 with OIntentMassiveInsert

use of com.orientechnologies.orient.core.intent.OIntentMassiveInsert in project orientdb by orientechnologies.

the class GraphIntersectLightweightEdges method testIntersect.

@Test
public void testIntersect() {
    graph.setUseLightweightEdges(true);
    graph.setAutoStartTx(false);
    graph.declareIntent(new OIntentMassiveInsert().setDisableSecurity(true).setDisableHooks(true).setDisableValidation(true).setEnableCache(false));
    // graph.begin();
    // CREATE SUPER NODE1
    final OrientVertex root1 = graph.addVertex(null, "name", "root1");
    for (int i = 0; i < TOT; ++i) {
        root1.addEdge("E", graph.addVertex(null, "child", i));
        if (i % 1000 == 0) {
            graph.commit();
            graph.setUseLog(false);
            // graph.begin();
            System.out.println("commit " + i);
        }
    }
    OLogManager.instance().info(this, "Created root1 with " + TOT + " children");
    // CREATE SUPER NODE2
    final OrientVertex root2 = graph.addVertex(null, "name", "root2");
    for (int i = 0; i < TOT; ++i) {
        root2.addEdge("E", graph.addVertex(null, "child", i));
        if (i % 1000 == 0) {
            graph.commit();
            graph.setUseLog(false);
            // graph.begin();
            System.out.println("commit " + i);
        }
    }
    OLogManager.instance().info(this, "Created root2 with " + TOT + " children");
    // CREATE THE VERTEX IN COMMON
    final OrientVertex common = graph.addVertex(null, "common", true);
    root1.addEdge("E", common);
    root2.addEdge("E", common);
    graph.commit();
    OLogManager.instance().info(this, "Intersecting...");
    Iterable<OrientVertex> result = graph.command(new OCommandSQL("select intersect( out() ) from [?,?]")).execute(root1.getIdentity(), root2.getIdentity());
    OLogManager.instance().info(this, "Intersecting done");
    Assert.assertTrue(result.iterator().hasNext());
    OrientVertex o = result.iterator().next();
    final Collection set = o.getRecord().field("intersect");
    Assert.assertEquals(set.iterator().next(), common);
    result = graph.command(new OCommandSQL("select expand($c) let $a=(select from V limit 20), $b=(select from V skip 10 limit 10), $c=intersect( $a, $b )")).execute();
    Assert.assertTrue(result.iterator().hasNext());
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) Collection(java.util.Collection) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OIntentMassiveInsert(com.orientechnologies.orient.core.intent.OIntentMassiveInsert) GraphNoTxAbstractTest(com.orientechnologies.orient.graph.GraphNoTxAbstractTest) Test(org.junit.Test)

Example 28 with OIntentMassiveInsert

use of com.orientechnologies.orient.core.intent.OIntentMassiveInsert in project orientdb by orientechnologies.

the class GraphIntersectRegularEdges method testIntersect.

@Test
public void testIntersect() {
    graph.setUseLightweightEdges(false);
    graph.setAutoStartTx(false);
    graph.declareIntent(new OIntentMassiveInsert().setDisableSecurity(true).setDisableHooks(true).setDisableValidation(true).setEnableCache(false));
    // graph.begin();
    // CREATE SUPER NODE1
    final OrientVertex root1 = graph.addVertex(null, "name", "root1");
    for (int i = 0; i < TOT; ++i) {
        root1.addEdge("E", graph.addVertex(null, "child", i));
        if (i % 1000 == 0) {
            graph.commit();
            graph.setUseLog(false);
            // graph.begin();
            System.out.println("commit " + i);
        }
    }
    OLogManager.instance().info(this, "Created root1 with " + TOT + " children");
    // CREATE SUPER NODE2
    final OrientVertex root2 = graph.addVertex(null, "name", "root2");
    for (int i = 0; i < TOT; ++i) {
        root2.addEdge("E", graph.addVertex(null, "child", i));
        if (i % 1000 == 0) {
            graph.commit();
            graph.setUseLog(false);
            // graph.begin();
            System.out.println("commit " + i);
        }
    }
    OLogManager.instance().info(this, "Created root2 with " + TOT + " children");
    // CREATE THE VERTEX IN COMMON
    final OrientVertex common = graph.addVertex(null, "common", true);
    root1.addEdge("E", common);
    root2.addEdge("E", common);
    graph.commit();
    OLogManager.instance().info(this, "Intersecting...");
    final Iterable<OrientVertex> result = graph.command(new OCommandSQL("select intersect( out() ) from [?,?]")).execute(root1.getIdentity(), root2.getIdentity());
    OLogManager.instance().info(this, "Intersecting done");
    Assert.assertTrue(result.iterator().hasNext());
    OrientVertex o = result.iterator().next();
    final Set set = o.getRecord().field("intersect");
    Assert.assertEquals(set.iterator().next(), common);
}
Also used : OCommandSQL(com.orientechnologies.orient.core.sql.OCommandSQL) Set(java.util.Set) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) OIntentMassiveInsert(com.orientechnologies.orient.core.intent.OIntentMassiveInsert) GraphNoTxAbstractTest(com.orientechnologies.orient.graph.GraphNoTxAbstractTest) Test(org.junit.Test)

Example 29 with OIntentMassiveInsert

use of com.orientechnologies.orient.core.intent.OIntentMassiveInsert in project orientdb by orientechnologies.

the class TestGraphIntentMassiveInsert method testIntent.

@Test
public void testIntent() {
    final OrientGraph graph = new OrientGraph("memory:default", false);
    graph.setUseLightweightEdges(true);
    graph.getRawGraph().declareIntent(new OIntentMassiveInsert());
    final OrientVertexType c1 = graph.createVertexType("C1");
    c1.createProperty("p1", OType.INTEGER);
    graph.createEdgeType("parent");
    graph.begin();
    final OrientVertex first = graph.addVertex("class:C1");
    first.setProperty("p1", -1);
    for (int i = 0; i < 10; i++) {
        final OrientVertex v = graph.addVertex("class:C1");
        v.setProperty("p1", i);
        first.addEdge("parent", v);
        //this search fills _source
        graph.command(new OSQLSynchQuery("SELECT from V where p1='" + i + "'")).execute();
    }
    graph.commit();
    //here NPE will be thrown
    final Iterable<Edge> edges = first.getEdges(Direction.BOTH);
    Iterator<Edge> ter = edges.iterator();
    for (int i = 0; i < 10; i++) {
        assertTrue(ter.hasNext());
        assertEquals(ter.next().getVertex(Direction.IN).getProperty("p1"), i);
    }
}
Also used : OrientGraph(com.tinkerpop.blueprints.impls.orient.OrientGraph) OSQLSynchQuery(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery) OrientVertexType(com.tinkerpop.blueprints.impls.orient.OrientVertexType) OrientVertex(com.tinkerpop.blueprints.impls.orient.OrientVertex) Edge(com.tinkerpop.blueprints.Edge) OIntentMassiveInsert(com.orientechnologies.orient.core.intent.OIntentMassiveInsert) Test(org.junit.Test)

Example 30 with OIntentMassiveInsert

use of com.orientechnologies.orient.core.intent.OIntentMassiveInsert in project orientdb by orientechnologies.

the class OrientGraphFactoryTest method textReqTx.

@Test
public void textReqTx() {
    final OrientGraphFactory gfactory = new OrientGraphFactory("memory:testPool");
    gfactory.setRequireTransaction(false);
    gfactory.declareIntent(new OIntentMassiveInsert());
    OrientGraph g = gfactory.getTx();
    OrientVertex v1 = g.addVertex(null);
    OrientVertex v2 = g.addVertex(null);
    v1.addEdge("E", v2);
    g.shutdown();
    gfactory.close();
}
Also used : OIntentMassiveInsert(com.orientechnologies.orient.core.intent.OIntentMassiveInsert) Test(org.junit.Test)

Aggregations

OIntentMassiveInsert (com.orientechnologies.orient.core.intent.OIntentMassiveInsert)31 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)14 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)8 ArrayList (java.util.ArrayList)7 ORID (com.orientechnologies.orient.core.id.ORID)5 OrientMonoThreadTest (com.orientechnologies.orient.test.database.base.OrientMonoThreadTest)5 Test (org.junit.Test)5 Test (org.testng.annotations.Test)5 Future (java.util.concurrent.Future)4 OCommandOutputListener (com.orientechnologies.orient.core.command.OCommandOutputListener)3 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)3 ODatabaseCompare (com.orientechnologies.orient.core.db.tool.ODatabaseCompare)3 ORecordBytes (com.orientechnologies.orient.core.record.impl.ORecordBytes)3 OStorage (com.orientechnologies.orient.core.storage.OStorage)3 OrientVertex (com.tinkerpop.blueprints.impls.orient.OrientVertex)3 OException (com.orientechnologies.common.exception.OException)2 ODatabaseDocumentInternal (com.orientechnologies.orient.core.db.ODatabaseDocumentInternal)2 ODatabaseDocument (com.orientechnologies.orient.core.db.document.ODatabaseDocument)2 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)2 OCommandExecutionException (com.orientechnologies.orient.core.exception.OCommandExecutionException)2