当前位置: 首页>>代码示例>>Java>>正文


Java GraphDatabaseBuilder类代码示例

本文整理汇总了Java中org.neo4j.graphdb.factory.GraphDatabaseBuilder的典型用法代码示例。如果您正苦于以下问题:Java GraphDatabaseBuilder类的具体用法?Java GraphDatabaseBuilder怎么用?Java GraphDatabaseBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GraphDatabaseBuilder类属于org.neo4j.graphdb.factory包,在下文中一共展示了GraphDatabaseBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
	}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:22,代码来源:InMemoryDBAccess.java

示例2: dbFactory

import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private Block dbFactory(final Path dbdir, final String dbkey) {
  return unit -> {
    GraphDatabaseService dbservice = unit.registerMock(GraphDatabaseService.class);
    // unit.mockStatic(RuntimeRegistry.class);
    // expect(RuntimeRegistry.getStartedRuntime(dbservice)).andReturn(null);

    LinkedBindingBuilder<GraphDatabaseService> lbb = unit.mock(LinkedBindingBuilder.class);
    lbb.toInstance(dbservice);

    Binder binder = unit.get(Binder.class);
    expect(binder.bind(Key.get(GraphDatabaseService.class))).andReturn(lbb);

    ServiceKey keys = unit.get(ServiceKey.class);
    keys.generate(eq(GraphDatabaseService.class), eq(dbkey), unit.capture(Consumer.class));

    GraphDatabaseBuilder dbbuilder = unit.registerMock(GraphDatabaseBuilder.class);
    expect(dbbuilder.newGraphDatabase()).andReturn(dbservice);

    GraphDatabaseFactory factory = unit.constructor(GraphDatabaseFactory.class)
        .build();
    expect(factory.setUserLogProvider(isA(Slf4jLogProvider.class))).andReturn(factory);
    expect(factory.newEmbeddedDatabaseBuilder(dbdir.toFile())).andReturn(dbbuilder);
  };
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:26,代码来源:Neo4jTest.java

示例3: UsageDao

import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入依赖的package包/类
/**
 * @param kvp
 * @param neoDir
 * @param neoFactory
 * @param registry
 */
private UsageDao(DB kvp, File neoDir, @Nullable File kvpStore, GraphDatabaseBuilder neoFactory, @Nullable MetricRegistry registry) {
  try {
    this.neoFactory = neoFactory;
    this.neoDir = neoDir;
    this.kvpStore = kvpStore;
    this.kvp = kvp;
    this.registry = registry;

    names = createKvpMap("names", ParsedName.class, 128);
    facts = createKvpMap("facts", UsageFacts.class, 128);
    verbatim = createKvpMap("verbatim", VerbatimNameUsage.class, 512);
    usages = createKvpMap("usages", NameUsage.class, 256);
    extensions = createKvpMap("extensions", UsageExtensions.class, 512);
    srcUsages = createKvpMap("srcUsages", SrcUsage.class, 256);
    nubUsages = createKvpMap("nubUsages", NubUsage.class, 256);

    openNeo();
  } catch (Exception e) {
    LOG.error("Failed to initialize a new DAO", e);
    close();
    throw e;
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:30,代码来源:UsageDao.java

示例4: temporaryDao

import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入依赖的package包/类
/**
 * A memory based backend which is erased after the JVM exits.
 * Useful for short lived tests. Neo4j always persists some files which are cleaned up afterwards automatically
 *
 * @param mappedMemory used for the neo4j db
 */
public static UsageDao temporaryDao(int mappedMemory, Integer shellPort) {
  LOG.debug("Create new in memory dao");
  DB kvp = DBMaker.memoryDB()
      .make();

  File storeDir = Files.createTempDir();
  NeoConfiguration cfg = new NeoConfiguration();
  cfg.mappedMemory = mappedMemory;
  if (shellPort != null) {
    cfg.shell = true;
    cfg.port = shellPort;
  }
  GraphDatabaseBuilder builder = cfg.newEmbeddedDb(storeDir, false);
  CleanupUtils.registerCleanupHook(storeDir);

  return new UsageDao(kvp, storeDir, null, builder, new MetricRegistry());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:24,代码来源:UsageDao.java

示例5: newEmbeddedDb

import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入依赖的package包/类
/**
 * Creates a new embedded db in the neoRepository folder.
 *
 * @param eraseExisting if true deletes previously existing db
 */
public GraphDatabaseBuilder newEmbeddedDb(File storeDir, boolean eraseExisting) {
  if (eraseExisting && storeDir.exists()) {
    // erase previous db
    LOG.debug("Removing previous neo4j database from {}", storeDir.getAbsolutePath());
    FileUtils.deleteQuietly(storeDir);
  }
  GraphDatabaseBuilder builder = new GraphDatabaseFactory()
      .setUserLogProvider(new Slf4jLogProvider())
      .newEmbeddedDatabaseBuilder(storeDir)
      .setConfig(GraphDatabaseSettings.keep_logical_logs, "false")
      .setConfig(GraphDatabaseSettings.pagecache_memory, mappedMemory + "m");
  if (shell) {
    LOG.info("Enable neo4j shell on port " + port);
    builder.setConfig(ShellSettings.remote_shell_enabled, "true")
        .setConfig(ShellSettings.remote_shell_port, String.valueOf(port))
        // listen to all IPs, not localhost only
        .setConfig(ShellSettings.remote_shell_host, "0.0.0.0");
  }
  return builder;
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:26,代码来源:NeoConfiguration.java

示例6: 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);
}
 
开发者ID:buschmais,项目名称:extended-objects,代码行数:17,代码来源:FileDatastoreFactory.java

示例7: 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();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:11,代码来源:TestLuceneBatchInsert.java

示例8: 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" );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:8,代码来源:AutoIndexerTest.java

示例9: getBuilder

import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入依赖的package包/类
public static GraphDatabaseBuilder getBuilder(final Neo4jDeployment deployment, final File graphDatabaseDirectory) {
	switch (deployment) {
		case EMBEDDED:
			return new GraphDatabaseFactory() .newEmbeddedDatabaseBuilder(graphDatabaseDirectory);
		case IN_MEMORY:
			return new TestGraphDatabaseFactory().newImpermanentDatabaseBuilder();
	}
	throw new IllegalStateException("Deployment mode '" + deployment + "' not supported.");
}
 
开发者ID:FTSRG,项目名称:trainbenchmark,代码行数:10,代码来源:Neo4jHelper.java

示例10: 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();
	}
 
开发者ID:Wolfgang-Schuetzelhofer,项目名称:jcypher,代码行数:28,代码来源:EmbeddedDBAccess.java

示例11: persistentDao

import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入依赖的package包/类
/**
 * A backend that is stored in files inside the configured neo directory.
 *
 * @param eraseExisting if true erases any previous data files
 */
public static UsageDao persistentDao(NeoConfiguration cfg, UUID datasetKey, MetricRegistry registry, boolean eraseExisting) {
  DB kvp = null;
  try {
    final File kvpF = cfg.kvp(datasetKey);
    final File storeDir = cfg.neoDir(datasetKey);
    if (eraseExisting) {
      LOG.debug("Remove existing data store");
      if (kvpF.exists()) {
        kvpF.delete();
      }
    }
    FileUtils.forceMkdir(kvpF.getParentFile());
    LOG.debug("Use KVP store {}", kvpF.getAbsolutePath());
    kvp = DBMaker.fileDB(kvpF)
        .fileMmapEnableIfSupported()
        .make();
    GraphDatabaseBuilder builder = cfg.newEmbeddedDb(storeDir, eraseExisting);
    return new UsageDao(kvp, storeDir, kvpF, builder, registry);

  } catch (Exception e) {
    if (kvp != null && !kvp.isClosed()) {
      kvp.close();
    }
    throw new IllegalStateException("Failed to init persistent DAO for " + datasetKey, e);
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:32,代码来源:UsageDao.java

示例12: 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;
  }
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:42,代码来源:Neo4jModule.java

示例13: 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;
}
 
开发者ID:web-education,项目名称:mod-neo4j-persistor,代码行数:43,代码来源:Neo4jEmbedded.java

示例14: embedded

import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "deprecation"})
@Test
public void embedded() throws Exception {
  Path dir = Paths.get("target", "des").toAbsolutePath();
  Path dbdir = dir.resolve("neo4jfs").toAbsolutePath();
  new MockUnit(Env.class, Config.class, Binder.class)
      .expect(hasPath("db.url", false))
      .expect(hasPath("db", true))
      .expect(confString("db", dbdir.toString()))
      .expect(hasPath("com.graphaware", false))
      .expect(hasPath("neo4j", true))
      .expect(confConf("neo4j",
          ConfigFactory.empty().withValue("unsupported.dbms.block_size.array_properties",
              ConfigValueFactory.fromAnyRef(120))))
      .expect(hasPath("db", false))
      .expect(hasPath("neo4j.db", false))
      .expect(props())
      .expect(setProp("database_dir", dbdir.toString()))
      .expect(putProp("unsupported.dbms.block_size.array_properties", 120))
      .expect(serviceKey())
      .expect(dbFactory(dbdir, "db"))
      .expect(embeddedAccess("db"))
      .expect(logdb(null, dbdir.toString()))
      .expect(onStop())
      .expect(unit -> {
        GraphDatabaseBuilder builder = unit.get(GraphDatabaseBuilder.class);
        expect(builder.setConfig("unsupported.dbms.block_size.array_properties", "120"))
            .andReturn(builder);
      })
      .run(unit -> {
            Neo4j neo4j = new Neo4j();
            neo4j.configure(unit.get(Env.class), unit.get(Config.class), unit.get(Binder.class));
          }, closeOnStop(),
          bind(GraphDatabaseService.class, 0),
          bind(IDBAccess.class, 1),
          unit -> {
            IDBAccess db = unit.get(IDBAccess.class);
            bind(db.getClass(), 2).run(unit);
          }, unit -> {
            unit.captured(BiConsumer.class).get(0)
                .accept("unsupported.dbms.block_size.array_properties", "120");
          });
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:44,代码来源:Neo4jTest.java

示例15: AfterAnalyze

import org.neo4j.graphdb.factory.GraphDatabaseBuilder; //导入依赖的package包/类
public AfterAnalyze(JavacTask task, GraphDatabaseBuilder graphDbBuilder, Map<String, String> cuProps) {
    this.graphDbBuilder = graphDbBuilder;
    this.task = task;
    this.cuProps = cuProps;
}
 
开发者ID:raoulDoc,项目名称:WiggleIndexer,代码行数:6,代码来源:AfterAnalyze.java


注:本文中的org.neo4j.graphdb.factory.GraphDatabaseBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。