Search in sources :

Example 6 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestProveFiveBillion method proveIt.

@Test
public void proveIt() throws Exception {
    deleteFileOrDirectory(new File(PATH));
    BatchInserter inserter = new BatchInserterImpl(PATH);
    // Create one giant chain of nodes n1->n2->n3 where each node will have
    // an int property and each rel a long string property. This will yield
    // 5b nodes/relationships, 10b property records and 5b dynamic records.
    // Start off by creating the first 4 billion (or so) entities with the
    // batch inserter just to speed things up a little
    long first = inserter.getReferenceNode();
    int max = (int) pow(2, 32) - 1000;
    Map<String, Object> nodeProperties = map("number", 123);
    Map<String, Object> relationshipProperties = map("string", "A long string, which is longer than shortstring boundaries");
    long i = 0;
    for (; i < max; i++) {
        long second = inserter.createNode(nodeProperties);
        inserter.createRelationship(first, second, TYPE, relationshipProperties);
        if (i > 0 && i % 1000000 == 0)
            System.out.println((i / 1000000) + "M");
        first = second;
    }
    inserter.shutdown();
    System.out.println("Switch to embedded");
    // Then create the rest with embedded graph db.
    GraphDatabaseService db = new EmbeddedGraphDatabase(PATH);
    Node firstNode = db.getNodeById(first);
    Transaction tx = db.beginTx();
    for (; i < 5000000000L; i++) {
        Node secondNode = db.createNode();
        firstNode.createRelationshipTo(secondNode, TYPE);
        firstNode = secondNode;
        if (i % 100000 == 0) {
            tx.success();
            tx.finish();
            System.out.println((i / 1000000) + "M");
            tx = db.beginTx();
        }
    }
    // Here we have a huge db. Loop through it and count chain length.
    /*        long count = 0;
        Node node = db.getReferenceNode();
        while ( true )
        {
            Relationship relationship = node.getSingleRelationship( TYPE, Direction.OUTGOING );
            if ( relationship == null )
            {
                break;
            }
        }
        System.out.println( count );
        assertTrue( count > 4900000000L );*/
    db.shutdown();
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) BatchInserter(org.neo4j.kernel.impl.batchinsert.BatchInserter) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) BatchInserterImpl(org.neo4j.kernel.impl.batchinsert.BatchInserterImpl) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) File(java.io.File) Test(org.junit.Test)

Example 7 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestBigStore method doBefore.

@Before
public void doBefore() {
    // Delete before just to be sure
    deleteFileOrDirectory(new File(PATH));
    db = new EmbeddedGraphDatabase(PATH);
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) File(java.io.File) Before(org.junit.Before)

Example 8 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestCacheTypes method testWeakRefCache.

@Test
public void testWeakRefCache() {
    GraphDatabaseService db = newDb("weak");
    assertEquals(CacheType.weak, ((EmbeddedGraphDatabase) db).getConfig().getGraphDbModule().getNodeManager().getCacheType());
    db.shutdown();
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Test(org.junit.Test)

Example 9 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestCacheTypes method testNoCache.

@Test
public void testNoCache() {
    GraphDatabaseService db = newDb("none");
    assertEquals(CacheType.none, ((EmbeddedGraphDatabase) db).getConfig().getGraphDbModule().getNodeManager().getCacheType());
    db.shutdown();
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Test(org.junit.Test)

Example 10 with EmbeddedGraphDatabase

use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.

the class TestCacheTypes method testSoftRefCache.

@Test
public void testSoftRefCache() {
    GraphDatabaseService db = newDb("soft");
    assertEquals(CacheType.soft, ((EmbeddedGraphDatabase) db).getConfig().getGraphDbModule().getNodeManager().getCacheType());
    db.shutdown();
}
Also used : EmbeddedGraphDatabase(org.neo4j.kernel.EmbeddedGraphDatabase) GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Test(org.junit.Test)

Aggregations

EmbeddedGraphDatabase (org.neo4j.kernel.EmbeddedGraphDatabase)84 Test (org.junit.Test)50 File (java.io.File)35 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)32 Node (org.neo4j.graphdb.Node)26 Transaction (org.neo4j.graphdb.Transaction)17 Relationship (org.neo4j.graphdb.Relationship)14 BeforeClass (org.junit.BeforeClass)13 HashMap (java.util.HashMap)7 BatchInserterImpl (org.neo4j.kernel.impl.batchinsert.BatchInserterImpl)6 RandomAccessFile (java.io.RandomAccessFile)5 BatchInserter (org.neo4j.kernel.impl.batchinsert.BatchInserter)5 BatchInserterIndex (org.neo4j.graphdb.index.BatchInserterIndex)4 TransactionManager (javax.transaction.TransactionManager)3 Before (org.junit.Before)3 DynamicRelationshipType (org.neo4j.graphdb.DynamicRelationshipType)3 TransactionFailureException (org.neo4j.graphdb.TransactionFailureException)3 BatchInserterIndexProvider (org.neo4j.graphdb.index.BatchInserterIndexProvider)3 IndexManager (org.neo4j.graphdb.index.IndexManager)3 Transaction (javax.transaction.Transaction)2