Search in sources :

Example 11 with GraphDatabaseBuilder

use of org.neo4j.graphdb.factory.GraphDatabaseBuilder in project neo4j by neo4j.

the class LegacyIndexesUpgradeTest method startDatabase.

private GraphDatabaseService startDatabase(boolean allowUpgread) {
    GraphDatabaseFactory factory = new TestGraphDatabaseFactory();
    GraphDatabaseBuilder builder = factory.newEmbeddedDatabaseBuilder(testDir.graphDbDir());
    builder.setConfig(GraphDatabaseSettings.allow_store_upgrade, Boolean.toString(allowUpgread));
    builder.setConfig(GraphDatabaseSettings.pagecache_memory, "8m");
    return builder.newGraphDatabase();
}
Also used : GraphDatabaseFactory(org.neo4j.graphdb.factory.GraphDatabaseFactory) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) GraphDatabaseBuilder(org.neo4j.graphdb.factory.GraphDatabaseBuilder)

Example 12 with GraphDatabaseBuilder

use of org.neo4j.graphdb.factory.GraphDatabaseBuilder in project blueprints by tinkerpop.

the class Neo4j2BatchGraph method removeReferenceNodeAndFinalizeKeyIndices.

private void removeReferenceNodeAndFinalizeKeyIndices() {
    GraphDatabaseService rawGraphDB = null;
    try {
        GraphDatabaseBuilder builder = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(this.rawGraph.getStoreDir());
        if (this.vertexIndexKeys.size() > 0)
            builder.setConfig(GraphDatabaseSettings.node_keys_indexable, vertexIndexKeys.toString().replace("[", "").replace("]", "")).setConfig(GraphDatabaseSettings.node_auto_indexing, "true");
        if (this.edgeIndexKeys.size() > 0)
            builder.setConfig(GraphDatabaseSettings.relationship_keys_indexable, edgeIndexKeys.toString().replace("[", "").replace("]", "")).setConfig(GraphDatabaseSettings.relationship_auto_indexing, "true");
        rawGraphDB = builder.newGraphDatabase();
        Transaction tx = rawGraphDB.beginTx();
        try {
            GlobalGraphOperations graphOperations = GlobalGraphOperations.at(rawGraphDB);
            if (this.vertexIndexKeys.size() > 0)
                populateKeyIndices(rawGraphDB, rawGraphDB.index().getNodeAutoIndexer(), graphOperations.getAllNodes(), Vertex.class);
            if (this.edgeIndexKeys.size() > 0)
                populateKeyIndices(rawGraphDB, rawGraphDB.index().getRelationshipAutoIndexer(), graphOperations.getAllRelationships(), Edge.class);
            tx.success();
        } finally {
            tx.close();
        }
    } catch (Exception e) {
        throw new RuntimeException(e.getMessage(), e);
    } finally {
        if (rawGraphDB != null)
            rawGraphDB.shutdown();
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) Vertex(com.tinkerpop.blueprints.Vertex) Transaction(org.neo4j.graphdb.Transaction) GraphDatabaseFactory(org.neo4j.graphdb.factory.GraphDatabaseFactory) Edge(com.tinkerpop.blueprints.Edge) GraphDatabaseBuilder(org.neo4j.graphdb.factory.GraphDatabaseBuilder) GlobalGraphOperations(org.neo4j.tooling.GlobalGraphOperations)

Example 13 with GraphDatabaseBuilder

use of org.neo4j.graphdb.factory.GraphDatabaseBuilder in project neo4j by neo4j.

the class ConsistencyCheckServiceIntegrationTest method getGraphDatabaseService.

private GraphDatabaseService getGraphDatabaseService() {
    GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(testDirectory.absolutePath());
    builder.setConfig(settings());
    return builder.newGraphDatabase();
}
Also used : TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) GraphDatabaseBuilder(org.neo4j.graphdb.factory.GraphDatabaseBuilder)

Example 14 with GraphDatabaseBuilder

use of org.neo4j.graphdb.factory.GraphDatabaseBuilder in project neo4j by neo4j.

the class GraphStoreFixture method generateInitialData.

private void generateInitialData() {
    GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder(directory);
    GraphDatabaseAPI graphDb = (GraphDatabaseAPI) builder.setConfig(GraphDatabaseSettings.record_format, formatName).setConfig(GraphDatabaseSettings.label_block_size, "60").newGraphDatabase();
    try {
        generateInitialData(graphDb);
        StoreAccess stores = new StoreAccess(graphDb.getDependencyResolver().resolveDependency(RecordStorageEngine.class).testAccessNeoStores()).initialize();
        schemaId = stores.getSchemaStore().getHighId();
        nodeId = stores.getNodeStore().getHighId();
        labelId = (int) stores.getLabelTokenStore().getHighId();
        nodeLabelsId = stores.getNodeDynamicLabelStore().getHighId();
        relId = stores.getRelationshipStore().getHighId();
        relGroupId = stores.getRelationshipGroupStore().getHighId();
        propId = (int) stores.getPropertyStore().getHighId();
        stringPropId = stores.getStringStore().getHighId();
        arrayPropId = stores.getArrayStore().getHighId();
        relTypeId = (int) stores.getRelationshipTypeTokenStore().getHighId();
        propKeyId = (int) stores.getPropertyKeyNameStore().getHighId();
    } finally {
        graphDb.shutdown();
    }
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) AccessStatsKeepingStoreAccess(org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess) DirectStoreAccess(org.neo4j.kernel.api.direct.DirectStoreAccess) StoreAccess(org.neo4j.kernel.impl.store.StoreAccess) RecordStorageEngine(org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine) TestGraphDatabaseFactory(org.neo4j.test.TestGraphDatabaseFactory) GraphDatabaseBuilder(org.neo4j.graphdb.factory.GraphDatabaseBuilder)

Example 15 with GraphDatabaseBuilder

use of org.neo4j.graphdb.factory.GraphDatabaseBuilder in project neo4j by neo4j.

the class TransactionGuardIntegrationTest method startCustomGuardedDatabase.

private GraphDatabaseAPI startCustomGuardedDatabase(File storeDir, Map<Setting<?>, String> configMap) {
    CustomClockCommunityFacadeFactory guardCommunityFacadeFactory = new CustomClockGuardedCommunityFacadeFactory();
    GraphDatabaseBuilder databaseBuilder = new CustomGuardTestTestGraphDatabaseFactory(guardCommunityFacadeFactory).newImpermanentDatabaseBuilder(storeDir);
    configMap.forEach(databaseBuilder::setConfig);
    GraphDatabaseAPI database = (GraphDatabaseAPI) databaseBuilder.newGraphDatabase();
    cleanupRule.add(database);
    return database;
}
Also used : GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) GraphDatabaseBuilder(org.neo4j.graphdb.factory.GraphDatabaseBuilder)

Aggregations

GraphDatabaseBuilder (org.neo4j.graphdb.factory.GraphDatabaseBuilder)21 GraphDatabaseService (org.neo4j.graphdb.GraphDatabaseService)8 TestGraphDatabaseFactory (org.neo4j.test.TestGraphDatabaseFactory)8 File (java.io.File)6 Test (org.junit.Test)6 Transaction (org.neo4j.graphdb.Transaction)5 GraphDatabaseFactory (org.neo4j.graphdb.factory.GraphDatabaseFactory)5 GraphDatabaseAPI (org.neo4j.kernel.internal.GraphDatabaseAPI)5 Edge (com.tinkerpop.blueprints.Edge)2 Vertex (com.tinkerpop.blueprints.Vertex)2 Map (java.util.Map)2 GlobalGraphOperations (org.neo4j.tooling.GlobalGraphOperations)2 InputStream (java.io.InputStream)1 HashMap (java.util.HashMap)1 ExecutorService (java.util.concurrent.ExecutorService)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 BooleanSupplier (java.util.function.BooleanSupplier)1 ConsistencyCheckService (org.neo4j.consistency.ConsistencyCheckService)1 AccessStatsKeepingStoreAccess (org.neo4j.consistency.statistics.AccessStatsKeepingStoreAccess)1