Java Code Examples for org.neo4j.graphdb.factory.GraphDatabaseBuilder#setConfig()
The following examples show how to use
org.neo4j.graphdb.factory.GraphDatabaseBuilder#setConfig() .
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: FileDatastoreFactory.java From extended-objects with Apache License 2.0 | 6 votes |
@Override public EmbeddedNeo4jDatastore createGraphDatabaseService(URI uri, Properties properties) throws MalformedURLException { String path; try { path = URLDecoder.decode(uri.toURL().getPath(), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new MalformedURLException(e.getMessage()); } File storeDir = new File(path); storeDir.mkdirs(); LOGGER.debug("Creating graph database service datastore for directory '{}'.", storeDir.getAbsolutePath()); GraphDatabaseBuilder databaseBuilder = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(storeDir); Properties neo4jProperties = Neo4jPropertyHelper.getNeo4jProperties(properties); for (String name : neo4jProperties.stringPropertyNames()) { databaseBuilder.setConfig(name, neo4jProperties.getProperty(name)); } GraphDatabaseService graphDatabaseService = databaseBuilder.newGraphDatabase(); LOGGER.debug("Graph database service for directory '{}' created.", storeDir.getAbsolutePath()); return new EmbeddedNeo4jDatastore(graphDatabaseService); }
Example 3
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 4
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(); }