org.neo4j.graphdb.factory.GraphDatabaseSettings Java Examples
The following examples show how to use
org.neo4j.graphdb.factory.GraphDatabaseSettings.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InMemoryDBAccess.java From jcypher with Apache License 2.0 | 6 votes |
@Override protected GraphDatabaseService createGraphDB() { GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder(); if (this.properties != null) { if (this.properties .getProperty(DBProperties.PAGECACHE_MEMORY) != null) builder.setConfig( GraphDatabaseSettings.pagecache_memory, DBProperties.PAGECACHE_MEMORY); if (this.properties.getProperty(DBProperties.STRING_BLOCK_SIZE) != null) builder.setConfig(GraphDatabaseSettings.string_block_size, DBProperties.ARRAY_BLOCK_SIZE); if (this.properties.getProperty(DBProperties.STRING_BLOCK_SIZE) != null) builder.setConfig(GraphDatabaseSettings.array_block_size, DBProperties.ARRAY_BLOCK_SIZE); } // builder.setConfig(GraphDatabaseSettings.cypher_planner, "RULE"); return builder.newGraphDatabase(); }
Example #2
Source File: Neo4jModule.java From SciGraph with Apache License 2.0 | 5 votes |
@Provides @Singleton GraphDatabaseService getGraphDatabaseService() throws IOException { try { GraphDatabaseBuilder graphDatabaseBuilder = new GraphDatabaseFactory() .newEmbeddedDatabaseBuilder(new File(configuration.getLocation())) .setConfig(configuration.getNeo4jConfig()); if (readOnly) { graphDatabaseBuilder.setConfig(GraphDatabaseSettings.read_only, Settings.TRUE); } // #198 - do not keep transaction logs graphDatabaseBuilder.setConfig(GraphDatabaseSettings.keep_logical_logs, Settings.FALSE); final GraphDatabaseService graphDb = graphDatabaseBuilder.newGraphDatabase(); Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { graphDb.shutdown(); } }); if (!readOnly) { // No need of auto-indexing in read-only mode setupAutoIndexing(graphDb, configuration); } setupSchemaIndexes(graphDb, configuration); return graphDb; } catch (Exception e) { if (Throwables.getRootCause(e).getMessage().contains("lock file")) { throw new IOException(format("The graph at \"%s\" is locked by another process", configuration.getLocation())); } throw e; } }
Example #3
Source File: EmbeddedDBAccess.java From jcypher with Apache License 2.0 | 5 votes |
@Override protected GraphDatabaseService createGraphDB() { // TODO the following applies to version 2.3.0 and above // File dbDir = new File(this.properties // .getProperty(DBProperties.DATABASE_DIR)); // GraphDatabaseBuilder builder = new GraphDatabaseFactory() // .newEmbeddedDatabaseBuilder(dbDir); GraphDatabaseBuilder builder = new GraphDatabaseFactory() .newEmbeddedDatabaseBuilder(new File(this.properties .getProperty(DBProperties.DATABASE_DIR))); if (this.properties .getProperty(DBProperties.PAGECACHE_MEMORY) != null) builder.setConfig( GraphDatabaseSettings.pagecache_memory, DBProperties.PAGECACHE_MEMORY); if (this.properties.getProperty(DBProperties.STRING_BLOCK_SIZE) != null) builder.setConfig(GraphDatabaseSettings.string_block_size, DBProperties.ARRAY_BLOCK_SIZE); if (this.properties.getProperty(DBProperties.STRING_BLOCK_SIZE) != null) builder.setConfig(GraphDatabaseSettings.array_block_size, DBProperties.ARRAY_BLOCK_SIZE); // builder.setConfig(GraphDatabaseSettings.cypher_planner, "RULE"); return builder.newGraphDatabase(); }
Example #4
Source File: CustomizeFullTextSearcherTest.java From ongdb-lab-apoc with Apache License 2.0 | 4 votes |
@Before public void before() { GraphDatabaseFactory factory = new GraphDatabaseFactory(); builder = factory.newEmbeddedDatabaseBuilder(testDirectory.databaseDir()); builder.setConfig(GraphDatabaseSettings.store_internal_log_level, "DEBUG"); }
Example #5
Source File: TestUtil.java From atlas with GNU General Public License v3.0 | 4 votes |
public static GraphDatabaseBuilder apocGraphDatabaseBuilder() { return new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder().setConfig(GraphDatabaseSettings.procedure_unrestricted,"apoc.*"); }
Example #6
Source File: Neo4jSNAMain.java From Neo4jSNA with Apache License 2.0 | 4 votes |
public static void main(String[] args) { String zipFile = "data/cineasts_12k_movies_50k_actors_2.1.6.zip"; String path = "data/cineasts_12k_movies_50k_actors.db/"; try { FileUtils.deleteRecursively(new File(path)); extractFolder(zipFile); } catch (Exception e) { e.printStackTrace(); System.exit(1); } long nodeCount, relsCount; // Open a database instance GraphDatabaseService g = new GraphDatabaseFactory() .newEmbeddedDatabaseBuilder(path) .setConfig(GraphDatabaseSettings.allow_store_upgrade, "true") .newGraphDatabase(); try (Transaction tx = g.beginTx() ) { nodeCount = IteratorUtil.count( GlobalGraphOperations.at(g).getAllNodes() ); relsCount = IteratorUtil.count( GlobalGraphOperations.at(g).getAllRelationships() ); tx.success(); } System.out.println("Node count: "+nodeCount); System.out.println("Rel count: " + relsCount); // Declare the GraphAlgoEngine on the database instance GraphAlgoEngine engine = new GraphAlgoEngine(g); if( args.length > 1 && args[1].equals("off") ) engine.disableLogging(); Louvain louvain = new Louvain(g); louvain.execute(); LouvainResult result = louvain.getResult(); for (int layer : result.layers()) { System.out.println("Layer " + layer + ": " + result.layer(layer).size() + " nodes"); } LabelPropagation lp = new LabelPropagation(); // Starts the algorithm on the given graph g engine.execute(lp); Long2LongMap communityMap = lp.getResult(); long totCommunities = new LongOpenHashSet( communityMap.values() ).size(); System.out.println("There are " + totCommunities + " communities according to Label Propagation"); DirectedModularity modularity = new DirectedModularity(g); engine.execute(modularity); System.out.println("The directed modularity of this network is " + modularity.getResult()); UndirectedModularity umodularity = new UndirectedModularity(g); engine.execute(umodularity); System.out.println("The undirected modularity of this network is " + umodularity.getResult()); engine.clean(lp); // Now you can clean Label propagation results TriangleCount tc = new TriangleCount(); engine.execute(tc); Long2LongMap triangleCount = tc.getResult(); Optional<Long> totalTriangles = triangleCount.values().stream().reduce( (x, y) -> x + y ); System.out.println("There are "+totalTriangles.get()+" triangles"); PageRank pr = new PageRank(g); engine.execute(pr); Long2DoubleMap ranks = pr.getResult(); engine.clean(pr); Optional<Double> res = ranks.values().parallelStream().reduce( (x, y) -> x + y ); System.out.println("Check PageRank sum is 1.0: "+ res.get()); ConnectedComponents cc = new ConnectedComponents(); engine.execute(cc); Long2LongMap components = cc.getResult(); engine.clean(cc); int totalComponents = new LongOpenHashSet( components.values() ).size(); System.out.println("There are "+ totalComponents+ " different connected components"); StronglyConnectedComponents scc = new StronglyConnectedComponents(); engine.execute(scc); components = scc.getResult(); engine.clean(scc); totalComponents = new LongOpenHashSet( components.values() ).size(); System.out.println("There are "+ totalComponents+ " different strongly connected components"); // Don't forget to shutdown the database g.shutdown(); }