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();
}
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;
}
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;
}
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;
}
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();
}
}
Aggregations