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


Java GraphDatabaseSettings类代码示例

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


GraphDatabaseSettings类属于org.neo4j.graphdb.factory包,在下文中一共展示了GraphDatabaseSettings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testConfigAndAPICompatibility

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
@Test
public void testConfigAndAPICompatibility()
{
    stopDb();
    config = new HashMap<>();
    config.put( GraphDatabaseSettings.node_keys_indexable.name(), "nodeProp1, nodeProp2" );
    config.put( GraphDatabaseSettings.relationship_keys_indexable.name(), "relProp1, relProp2" );
    config.put( GraphDatabaseSettings.node_auto_indexing.name(), "true" );
    config.put( GraphDatabaseSettings.relationship_auto_indexing.name(), "true" );
    startDb();

    assertTrue( graphDb.index().getNodeAutoIndexer().isEnabled() );
    assertTrue( graphDb.index().getRelationshipAutoIndexer().isEnabled() );

    AutoIndexer<Node> autoNodeIndexer = graphDb.index().getNodeAutoIndexer();
    // Start auto indexing a new and an already auto indexed
    autoNodeIndexer.startAutoIndexingProperty( "nodeProp1" );
    autoNodeIndexer.startAutoIndexingProperty( "nodeProp3" );
    assertEquals( 3, autoNodeIndexer.getAutoIndexedProperties().size() );
    assertTrue( autoNodeIndexer.getAutoIndexedProperties().contains(
            "nodeProp1" ) );
    assertTrue( autoNodeIndexer.getAutoIndexedProperties().contains(
            "nodeProp2" ) );
    assertTrue( autoNodeIndexer.getAutoIndexedProperties().contains(
            "nodeProp3" ) );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:27,代码来源:TestAutoIndexing.java

示例2: testDefaultIsOffIfExplicit

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
@Test
public void testDefaultIsOffIfExplicit() throws Exception
{
    stopDb();
    config = new HashMap<>();
    config.put( GraphDatabaseSettings.node_keys_indexable.name(), "nodeProp1, nodeProp2" );
    config.put( GraphDatabaseSettings.relationship_keys_indexable.name(), "relProp1, relProp2" );
    config.put( GraphDatabaseSettings.node_auto_indexing.name(), "false" );
    config.put( GraphDatabaseSettings.relationship_auto_indexing.name(), "false" );
    startDb();

    AutoIndexer<Node> autoIndexer = graphDb.index().getNodeAutoIndexer();
    autoIndexer.startAutoIndexingProperty( "testProp" );
    newTransaction();

    Node node1 = graphDb.createNode();
    node1.setProperty( "nodeProp1", "node1" );
    node1.setProperty( "nodeProp2", "node1" );
    node1.setProperty( "testProp", "node1" );

    newTransaction();

    assertFalse( autoIndexer.getAutoIndex().get( "nodeProp1", "node1" ).hasNext() );
    assertFalse( autoIndexer.getAutoIndex().get( "nodeProp2", "node1" ).hasNext() );
    assertFalse( autoIndexer.getAutoIndex().get( "testProp", "node1" ).hasNext() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:27,代码来源:TestAutoIndexing.java

示例3: recoveryForRelationshipCommandsOnly

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
@Test
public void recoveryForRelationshipCommandsOnly() throws Throwable
{
    // shutdown db here
    String storeDir = db.getStoreDir();
    File path = new File( storeDir );
    shutdownDB();

    // NB: AddRelToIndex will start and shutdown the db
    Process process = Runtime.getRuntime().exec( new String[]{
            "java", "-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005", "-cp",
            System.getProperty( "java.class.path" ),
            AddRelToIndex.class.getName(), storeDir
    } );
    assertEquals( 0, new ProcessStreamHandler( process, false ).waitForResult() );

    FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
    Config config = new Config( MapUtil.stringMap(), GraphDatabaseSettings.class );
    LuceneDataSource ds = new LuceneDataSource( path, config, new IndexConfigStore( path, fileSystem ), fileSystem );
    ds.start();
    ds.stop();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:23,代码来源:RecoveryTest.java

示例4: DBInit

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
private void DBInit()
{
	graph_db = new GraphDatabaseFactory()
		.newEmbeddedDatabaseBuilder(db_name)
		.setConfig(GraphDatabaseSettings.keep_logical_logs, "false")
		.setConfig(GraphDatabaseSettings.use_memory_mapped_buffers, "true")
		.setConfig(ShellSettings.remote_shell_enabled, "true")
		.setConfig(ShellSettings.remote_shell_port, "1337")
		.setConfig(ShellSettings.remote_shell_read_only, "true")
		.newGraphDatabase();

	if(bootstrap)
		DoBootstrap();

	transaction = new NinjaTransaction(graph_db, Neo4jGraph.COUNT_THRESHOLD);
}
 
开发者ID:srcc-msu,项目名称:octotron_core,代码行数:17,代码来源:Neo4jGraph.java

示例5: createGraphDB

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的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

示例6: newEmbeddedDb

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的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

示例7: ClearDatabase

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
/**
 * Clears all data in the DB and reconnects to it afterwards.
 */
public void ClearDatabase(){
	// Shutdown database before erasing it
	log.debug("Shutting down the database");
	mGraphDb.shutdown();
	try
       {
		log.debug("Erasing the database files");
           FileUtils.deleteRecursively( new File( mDbPath ) );
       }
       catch ( IOException e )
       {
           throw new RuntimeException( e );
       }
	// Restart database
	log.debug("Reconnecting to database");
	mGraphDb = new GraphDatabaseFactory().
			newEmbeddedDatabaseBuilder(mDbPath).
			setConfig( GraphDatabaseSettings.node_keys_indexable, KEY_HASH ).
			setConfig( GraphDatabaseSettings.node_auto_indexing, "true" ).
			newGraphDatabase();
	registerShutdownHook(mGraphDb);
}
 
开发者ID:trustathsh,项目名称:visitmeta,代码行数:26,代码来源:Neo4JConnection.java

示例8: EmbeddedTestkitDriver

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
public EmbeddedTestkitDriver(final File storeDir) {
        GraphDatabaseSettings.BoltConnector bolt = GraphDatabaseSettings.boltConnector( "0" );

        String host = "localhost";
        int port = 7687; // this is the default Neo4j port - we start one higher than this
        GraphDatabaseService graphDb = null;
        String address = null;
        while (port < 65000) {
            port++;
            address = String.format("%s:%d", host, port);
            try {
                graphDb = new TestGraphDatabaseFactory()
                    .newImpermanentDatabaseBuilder()
//                    .newEmbeddedDatabaseBuilder(storeDir)
                    .setConfig(bolt.type, "BOLT")
                    .setConfig(bolt.enabled, "true")
                    .setConfig(bolt.address, address)
                    .newGraphDatabase();
            } catch (RuntimeException e) {
                // this is usually a org.neo4j.kernel.lifecycle.LifecycleException
                // caused by org.neo4j.helpers.PortBindException
                e.printStackTrace();
                System.out.println("Cannot connect on port " + port + ", retrying on a higher port.");
                continue;
            }
            break;
        }

        gds = graphDb;
        driver = GraphDatabase.driver("bolt://" + address);
    }
 
开发者ID:FTSRG,项目名称:codemodel-rifle,代码行数:32,代码来源:EmbeddedTestkitDriver.java

示例9: force

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
void force()
{
    for ( IndexReference index : getAllIndexes() )
    {
        try
        {
            index.getWriter().commit();
        }
        catch ( IOException e )
        {
            throw new RuntimeException( "Unable to commit changes to " + index.getIdentifier() + " in " +
                    config.get( GraphDatabaseSettings.store_dir ).getAbsolutePath(), e );
        }
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:16,代码来源:LuceneDataSource.java

示例10: shouldCreateAutoIndexThatIsUsableInEmbedded

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
@Test
public void shouldCreateAutoIndexThatIsUsableInEmbedded() throws Exception
{
    BatchInserterIndexProvider provider = new LuceneBatchInserterIndexProviderNewImpl( inserter );
    BatchInserterIndex index = provider.nodeIndex( "node_auto_index", EXACT_CONFIG );

    long id = inserter.createNode( null );
    Map<String, Object> props = new HashMap<>();
    props.put( "name", "peter" );
    index.add( id, props );
    index.flush();
    provider.shutdown();
    shutdownInserter();

    switchToGraphDatabaseService( configure( GraphDatabaseSettings.node_keys_indexable, "name" ),
            configure( GraphDatabaseSettings.relationship_keys_indexable, "relProp1,relProp2" ),
            configure( GraphDatabaseSettings.node_auto_indexing, "true" ),
            configure( GraphDatabaseSettings.relationship_auto_indexing, "true" ) );
    try ( Transaction tx = db.beginTx() )
    {
        // Create the primitives
        Node node1 = db.createNode();

        // Add indexable and non-indexable properties
        node1.setProperty( "name", "bob" );

        // Make things persistent
        tx.success();
    }

    try ( Transaction tx = db.beginTx() )
    {
        assertTrue( db.index().getNodeAutoIndexer().getAutoIndex().get( "name", "peter" ).hasNext() );
        assertTrue( db.index().getNodeAutoIndexer().getAutoIndex().get( "name", "bob" ).hasNext() );
        assertFalse( db.index().getNodeAutoIndexer().getAutoIndex().get( "name", "joe" ).hasNext() );
        tx.success();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:39,代码来源:TestLuceneBatchInsert.java

示例11: configure

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的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

示例12: testDefaultsAreSeparateForNodesAndRelationships

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
@Test
public void testDefaultsAreSeparateForNodesAndRelationships()
        throws Exception
{
    stopDb();
    config = new HashMap<>();
    config.put( GraphDatabaseSettings.node_keys_indexable.name(), "propName" );
    config.put( GraphDatabaseSettings.node_auto_indexing.name(), "true" );
    // Now only node properties named propName should be indexed.
    startDb();

    newTransaction();

    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    node1.setProperty( "propName", "node1" );
    node2.setProperty( "propName", "node2" );
    node2.setProperty( "propName_", "node2" );

    Relationship rel = node1.createRelationshipTo( node2,
            DynamicRelationshipType.withName( "DYNAMIC" ) );
    rel.setProperty( "propName", "rel1" );

    newTransaction();

    ReadableIndex<Node> autoIndex = graphDb.index().getNodeAutoIndexer().getAutoIndex();
    assertEquals( node1, autoIndex.get( "propName", "node1" ).getSingle() );
    assertEquals( node2, autoIndex.get( "propName", "node2" ).getSingle() );
    assertFalse( graphDb.index().getRelationshipAutoIndexer().getAutoIndex().get(
            "propName", "rel1" ).hasNext() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:32,代码来源:TestAutoIndexing.java

示例13: testStartStopAutoIndexing

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
@Test
public void testStartStopAutoIndexing() throws Exception
{
    stopDb();
    config = new HashMap<>();
    config.put( GraphDatabaseSettings.node_keys_indexable.name(), "propName" );
    config.put( GraphDatabaseSettings.node_auto_indexing.name(), "true" );
    // Now only node properties named propName should be indexed.
    startDb();

    AutoIndexer<Node> autoIndexer = graphDb.index().getNodeAutoIndexer();
    assertTrue( autoIndexer.isEnabled() );

    autoIndexer.setEnabled( false );
    assertFalse( autoIndexer.isEnabled() );
    newTransaction();

    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    node1.setProperty( "propName", "node" );
    newTransaction();

    assertFalse( autoIndexer.getAutoIndex().get( "nodeProp1", "node1" ).hasNext() );
    autoIndexer.setEnabled( true );
    node2.setProperty( "propName", "node" );

    newTransaction();

    assertEquals( node2,
            autoIndexer.getAutoIndex().get( "propName", "node" ).getSingle() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:32,代码来源:TestAutoIndexing.java

示例14: testShouldReturnIndexWriterFromLRUCache

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
@Test
public void testShouldReturnIndexWriterFromLRUCache() throws Throwable
{
    Config config = new Config( config(), GraphDatabaseSettings.class );
    dataSource = life.add( new LuceneDataSource( directory.graphDbDir(), config, indexStore, new DefaultFileSystemAbstraction() ) );
    IndexIdentifier identifier = identifier( "foo" );
    IndexWriter writer = dataSource.getIndexSearcher( identifier ).getWriter();
    assertSame( writer, dataSource.getIndexSearcher( identifier ).getWriter() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:10,代码来源:LuceneDataSourceTest.java

示例15: testShouldReturnIndexSearcherFromLRUCache

import org.neo4j.graphdb.factory.GraphDatabaseSettings; //导入依赖的package包/类
@Test
public void testShouldReturnIndexSearcherFromLRUCache() throws Throwable
{
    Config config = new Config( config(), GraphDatabaseSettings.class );
    dataSource = life.add( new LuceneDataSource( directory.graphDbDir(), config, indexStore, new DefaultFileSystemAbstraction() ) );
    IndexIdentifier identifier = identifier( "foo" );
    IndexReference searcher = dataSource.getIndexSearcher( identifier );
    assertSame( searcher, dataSource.getIndexSearcher( identifier ) );
    searcher.close();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:11,代码来源:LuceneDataSourceTest.java


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