Search in sources :

Example 26 with TestGraphDatabaseFactory

use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.

the class AStarPerformanceIT method somePerformanceTesting.

@Test
public void somePerformanceTesting() throws Exception {
    // GIVEN
    int numberOfNodes = 200000;
    GeoDataGenerator generator = new GeoDataGenerator(numberOfNodes, 5d, 1000, 1000);
    generator.generate(directory);
    // WHEN
    long[][] points = new long[][] { new long[] { 9415, 158154 }, new long[] { 89237, 192863 }, new long[] { 68072, 150484 }, new long[] { 186309, 194495 }, new long[] { 152097, 99289 }, new long[] { 92150, 161182 }, new long[] { 188446, 115873 }, new long[] { 85033, 7772 }, new long[] { 291, 86707 }, new long[] { 188345, 158468 } };
    GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase(directory.getAbsoluteFile());
    PathFinder<WeightedPath> algo = aStar(allTypesAndDirections(), doubleCostEvaluator("weight", 0), GeoDataGenerator.estimateEvaluator());
    for (int i = 0; i < 10; i++) {
        System.out.println("----- " + i);
        for (long[] p : points) {
            try (Transaction tx = db.beginTx()) {
                Node start = db.getNodeById(p[0]);
                Node end = db.getNodeById(p[1]);
                long time = currentTimeMillis();
                WeightedPath path = algo.findSinglePath(start, end);
                time = currentTimeMillis() - time;
                System.out.println("time: " + time + ", len:" + path.length() + ", weight:" + path.weight());
                tx.success();
            }
        }
    }
    // THEN
    db.shutdown();
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) WeightedPath(org.neo4j.graphalgo.WeightedPath) Transaction(org.neo4j.graphdb.Transaction) Node(org.neo4j.graphdb.Node) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) Test(org.junit.Test)

Example 27 with TestGraphDatabaseFactory

use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.

the class RecoveryRequiredCheckerTest method createSomeDataAndCrash.

private FileSystemAbstraction createSomeDataAndCrash(File store, EphemeralFileSystemAbstraction fileSystem) throws IOException {
    final GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem(fileSystem).newImpermanentDatabase(store);
    try (Transaction tx = db.beginTx()) {
        db.createNode();
        tx.success();
    }
    EphemeralFileSystemAbstraction snapshot = fileSystem.snapshot();
    db.shutdown();
    return snapshot;
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) EphemeralFileSystemAbstraction(org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory)

Example 28 with TestGraphDatabaseFactory

use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.

the class BatchInsertTest method switchToEmbeddedGraphDatabaseService.

private GraphDatabaseService switchToEmbeddedGraphDatabaseService(BatchInserter inserter) {
    inserter.shutdown();
    TestGraphDatabaseFactory factory = new TestGraphDatabaseFactory();
    factory.setFileSystem(fileSystemRule.get());
    GraphDatabaseService db = factory.newImpermanentDatabaseBuilder(new File(inserter.getStoreDir())).setConfig(configuration()).newGraphDatabase();
    try (Transaction tx = db.beginTx()) {
        db.schema().awaitIndexesOnline(10, TimeUnit.SECONDS);
        tx.success();
    }
    return db;
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) File(java.io.File)

Example 29 with TestGraphDatabaseFactory

use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.

the class GuardIT method startDataBase.

private GraphDatabaseAPI startDataBase() {
    GraphDatabaseAPI database = (GraphDatabaseAPI) new TestGraphDatabaseFactory().newImpermanentDatabase();
    cleanupRule.add(database);
    return database;
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory)

Example 30 with TestGraphDatabaseFactory

use of org.neo4j.test.TestGraphDatabaseFactory in project neo4j by neo4j.

the class BatchingNeoStoresTest method someDataInTheDatabase.

private void someDataInTheDatabase() {
    GraphDatabaseService db = new TestGraphDatabaseFactory().setFileSystem(new UncloseableDelegatingFileSystemAbstraction(fsr.get())).newImpermanentDatabase(storeDir);
    try (Transaction tx = db.beginTx()) {
        db.createNode().createRelationshipTo(db.createNode(), MyRelTypes.TEST);
        tx.success();
    } finally {
        db.shutdown();
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Transaction(org.neo4j.graphdb.Transaction) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) UncloseableDelegatingFileSystemAbstraction(org.neo4j.graphdb.mockfs.UncloseableDelegatingFileSystemAbstraction)

Aggregations

TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)156 Test (org.junit.Test)70 Transaction (org.neo4j.graphdb.Transaction)62 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)61 File (java.io.File)34 Node (org.neo4j.graphdb.Node)28 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)26 BeforeClass (org.junit.BeforeClass)25 Before (org.junit.Before)22 EphemeralFileSystemAbstraction (org.neo4j.graphdb.mockfs.EphemeralFileSystemAbstraction)9 Relationship (org.neo4j.graphdb.Relationship)8 Result (org.neo4j.graphdb.Result)6 GraphDatabaseBuilder (org.neo4j.graphdb.factory.GraphDatabaseBuilder)6 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)6 GraphDatabaseShellServer (org.neo4j.shell.kernel.GraphDatabaseShellServer)6 HashMap (java.util.HashMap)5 DependencyResolver (org.neo4j.graphdb.DependencyResolver)5 PageCache (org.neo4j.io.pagecache.PageCache)5 WrappedDatabase (org.neo4j.server.database.WrappedDatabase)5 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)4