本文整理汇总了Java中org.neo4j.graphdb.factory.GraphDatabaseBuilder.setConfig方法的典型用法代码示例。如果您正苦于以下问题:Java GraphDatabaseBuilder.setConfig方法的具体用法?Java GraphDatabaseBuilder.setConfig怎么用?Java GraphDatabaseBuilder.setConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.factory.GraphDatabaseBuilder
的用法示例。
在下文中一共展示了GraphDatabaseBuilder.setConfig方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGraphDB
import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入方法依赖的package包/类
@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();
}
示例2: createGraphDatabaseService
import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入方法依赖的package包/类
@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());
}
GraphDatabaseBuilder databaseBuilder = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(new File(path));
Properties neo4jProperties = Neo4jPropertyHelper.getNeo4jProperties(properties);
for (String name : neo4jProperties.stringPropertyNames()) {
databaseBuilder.setConfig(name, neo4jProperties.getProperty(name));
}
GraphDatabaseService graphDatabaseService = databaseBuilder.newGraphDatabase();
return new EmbeddedNeo4jDatastore(graphDatabaseService);
}
示例3: switchToGraphDatabaseService
import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入方法依赖的package包/类
private void switchToGraphDatabaseService( ConfigurationParameter... config )
{
shutdownInserter();
GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir );
for ( ConfigurationParameter configurationParameter : config )
{
builder = builder.setConfig( configurationParameter.key, configurationParameter.value );
}
db = builder.newGraphDatabase();
}
示例4: configure
import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入方法依赖的package包/类
@Override
protected void configure( GraphDatabaseBuilder builder )
{
super.configure( builder );
builder.setConfig( GraphDatabaseSettings.relationship_keys_indexable, "Type" );
builder.setConfig( GraphDatabaseSettings.relationship_auto_indexing, "true" );
}
示例5: createGraphDB
import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入方法依赖的package包/类
@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();
}
示例6: getGraphDatabaseService
import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入方法依赖的package包/类
@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);
}
if (enableGuard) {
graphDatabaseBuilder.setConfig(GraphDatabaseSettings.execution_guard_enabled,
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;
}
}
示例7: Neo4jEmbedded
import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入方法依赖的package包/类
public Neo4jEmbedded(JsonObject config, Logger logger) {
GraphDatabaseBuilder gdbb = new GraphDatabaseFactory()
.newEmbeddedDatabaseBuilder(config.getString("datastore-path"));
JsonObject neo4jConfig = config.getObject("neo4j");
if (neo4jConfig != null) {
gdbb.setConfig(GraphDatabaseSettings.node_keys_indexable,
neo4jConfig.getString("node_keys_indexable"));
gdbb.setConfig(GraphDatabaseSettings.node_auto_indexing,
neo4jConfig.getString("node_auto_indexing", "false"));
gdbb.setConfig(GraphDatabaseSettings.relationship_keys_indexable,
neo4jConfig.getString("relationship_keys_indexable"));
gdbb.setConfig(GraphDatabaseSettings.relationship_auto_indexing,
neo4jConfig.getString("relationship_auto_indexing", "false"));
gdbb.setConfig(GraphDatabaseSettings.allow_store_upgrade,
neo4jConfig.getString("allow_store_upgrade", "true"));
}
gdb = gdbb.newGraphDatabase();
registerShutdownHook(gdb);
if (neo4jConfig != null) {
JsonArray legacyIndexes = neo4jConfig.getArray("legacy-indexes");
if (legacyIndexes != null && legacyIndexes.size() > 0) {
try (Transaction tx = gdb.beginTx()) {
for (Object o : legacyIndexes) {
if (!(o instanceof JsonObject)) continue;
JsonObject j = (JsonObject) o;
if ("node".equals(j.getString("for"))) {
gdb.index().forNodes(j.getString("name"), MapUtil.stringMap(
IndexManager.PROVIDER, "lucene", "type", j.getString("type", "exact")));
} else if ("relationship".equals(j.getString("for"))) {
gdb.index().forRelationships(j.getString("name"), MapUtil.stringMap(
IndexManager.PROVIDER, "lucene", "type", j.getString("type", "exact")));
}
}
tx.success();
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
}
engine = new ExecutionEngine(gdb);
this.logger = logger;
}
示例8: initGraphDatabaseService
import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入方法依赖的package包/类
protected void initGraphDatabaseService() {
if (databasePath == null) {
databasePath = new File(configuration.getDatabasePath());
}
if (graphDatabase == null) {
if (configuration.hasHaconfig()) {
TinkerPopConfig.HaConfig haconfig = configuration.getHaconfig();
LOG.info(
"Launching HA mode. Server id is " +
haconfig.getServerId() +
" database is at " +
databasePath.getAbsolutePath() +
". allow init cluster is " +
haconfig.allowInitCluster()
);
final GraphDatabaseBuilder graphDatabaseBuilder =
new HighlyAvailableGraphDatabaseFactory()
.setUserLogProvider(new Slf4jLogProvider())
.newEmbeddedDatabaseBuilder(databasePath)
.setConfig(GraphDatabaseSettings.allow_store_upgrade, "true")
.setConfig(ClusterSettings.allow_init_cluster, haconfig.allowInitCluster())
.setConfig(ClusterSettings.server_id, haconfig.getServerId())
.setConfig(ClusterSettings.initial_hosts, haconfig.getInitialHosts())
.setConfig(ClusterSettings.cluster_server, haconfig.getIp() + ":5001")
.setConfig(HaSettings.ha_server, haconfig.getIp() + ":6001")
/*
* Neo4j synchronizes the slave databases via pulls of the master data. By default this property is not
* activated (set to 0s). So this property has to be set. An alternative is to set 'ha.tx_push_factor'.
* Since a network connection might be temporarily down, a pull is safer then a push. The push_factor is
* meant for ensuring data duplication so that a master can safely crash
*/
.setConfig(HaSettings.pull_interval, haconfig.getPullInterval())
.setConfig(HaSettings.tx_push_factor, haconfig.getPushFactor());
if (configuration.getPageCacheMemory().length() > 0) {
graphDatabaseBuilder.setConfig(GraphDatabaseSettings.pagecache_memory, configuration.getPageCacheMemory());
}
graphDatabase = graphDatabaseBuilder.newGraphDatabase();
} else {
LOG.info("Launching local non-ha mode. Database at " + databasePath.getAbsolutePath());
graphDatabase = new GraphDatabaseFactory()
.setUserLogProvider( new Slf4jLogProvider() )
.newEmbeddedDatabaseBuilder(databasePath)
.setConfig(GraphDatabaseSettings.allow_store_upgrade, "true")
.newGraphDatabase();
}
}
}