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


Java BatchInserters类代码示例

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


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

示例1: shouldNotIndexNodesWithWrongLabel

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
@Test
public void shouldNotIndexNodesWithWrongLabel() throws Exception
{
    // Given
    BatchInserter inserter = BatchInserters.inserter( dbRule.getStoreDirAbsolutePath() );

    inserter.createNode( map("name", "Bob"), label( "User" ), label("Admin"));

    inserter.createDeferredSchemaIndex( label( "Banana" ) ).on( "name" ).create();

    // When
    inserter.shutdown();

    // Then
    GraphDatabaseService db = dbRule.getGraphDatabaseService();
    try(Transaction tx = db.beginTx())
    {
        assertThat( count( db.findNodes( label( "Banana" ), "name", "Bob" ) ), equalTo(0) );
    }
    finally
    {
        db.shutdown();
    }

}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:26,代码来源:BatchInsertionIT.java

示例2: shouldBeAbleToMakeRepeatedCallsToSetNodeProperty

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
@Test
public void shouldBeAbleToMakeRepeatedCallsToSetNodeProperty() throws Exception
{
    BatchInserter inserter = BatchInserters.inserter( dbRule.getStoreDirAbsolutePath() );
    long nodeId = inserter.createNode( Collections.<String, Object>emptyMap() );

    final Object finalValue = 87;
    inserter.setNodeProperty( nodeId, "a", "some property value" );
    inserter.setNodeProperty( nodeId, "a", 42 );
    inserter.setNodeProperty( nodeId, "a", 3.14 );
    inserter.setNodeProperty( nodeId, "a", true );
    inserter.setNodeProperty( nodeId, "a", finalValue );
    inserter.shutdown();

    GraphDatabaseService db = dbRule.getGraphDatabaseService();
    try(Transaction ignored = db.beginTx())
    {
        assertThat( db.getNodeById( nodeId ).getProperty( "a" ), equalTo( finalValue ) );
    }
    finally
    {
        db.shutdown();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:25,代码来源:BatchInsertionIT.java

示例3: testInsertionSpeed

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
@Ignore
@Test
public void testInsertionSpeed() throws Exception
{
    BatchInserter inserter = BatchInserters.inserter( dbRule.getStoreDirAbsolutePath() );
    BatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider( inserter );
    BatchInserterIndex index = provider.nodeIndex( "yeah", EXACT_CONFIG );
    index.setCacheCapacity( "key", 1000000 );
    long t = currentTimeMillis();
    for ( int i = 0; i < 1000000; i++ )
    {
        Map<String, Object> properties = map( "key", "value" + i );
        long id = inserter.createNode( properties );
        index.add( id, properties );
    }
    System.out.println( "insert:" + ( currentTimeMillis() - t ) );
    index.flush();

    t = currentTimeMillis();
    for ( int i = 0; i < 1000000; i++ )
    {
        count( (Iterator<Long>) index.get( "key", "value" + i ) );
    }
    System.out.println( "get:" + ( currentTimeMillis() - t ) );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:26,代码来源:BatchInsertionIT.java

示例4: testBatchIndexToAutoIndex

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
@Test
public void testBatchIndexToAutoIndex() throws IOException {
  BatchInserter inserter = BatchInserters.inserter(new File(path));
  BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(inserter);
  BatchInserterIndex index =
      indexProvider.nodeIndex("node_auto_index", MapUtil.stringMap("type", "exact"));
  long node = inserter.createNode(MapUtil.map("foo", "bar"));
  index.add(node, MapUtil.map("foo", "bar"));
  index.flush();
  assertThat("Batch indexed node can be retrieved", index.get("foo", "bar").next(), is(node));
  indexProvider.shutdown();
  inserter.shutdown();
  graphDb = getGraphDb();
  try (Transaction tx = graphDb.beginTx()) {
    assertThat("AutoIndex is not enabled after reopening the graph", graphDb.index()
        .getNodeAutoIndexer().isEnabled(), is(false));
    assertThat("AutoIndexed properties are not maintained after closing the graph", graphDb
        .index().getNodeAutoIndexer().getAutoIndexedProperties(), is(empty()));
    assertThat("Batch index properties are in the index", graphDb.index().getNodeAutoIndexer()
        .getAutoIndex().query("foo", "bar").size(), is(1));
    tx.success();
  }
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:24,代码来源:Neo4jIndexingTest.java

示例5: Neo4jBatchBuilder

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
/**
 * Create a new {@link Neo4jBatchBuilder}, which batch inserts to
 * the specified database path.
 * @param storeDir the path where the database is stored.
 * @param annotations the {@link AnnotationCollection} to connect the nodes with.
 * @param phylogeny the phylogenetic tree, for linking the source nodes together.
 */
public Neo4jBatchBuilder(String storeDir, AnnotationCollection annotations,
		TreeNode phylogeny) {
	this.annotations = annotations;
	this.storeDir = storeDir;
	this.phylogeny = phylogeny;

	batchInserter = BatchInserters.inserter(storeDir);
	annotationIDToNodeID = new HashMap<>();
	sequenceIDToNodeID = new HashMap<>();
	sourceToNodeID = new HashMap<>();
	annotationProperties = new HashMap<>();
	nodeProperties = new HashMap<>();

	annotations.getAll().forEach(e ->
			annotationIDToNodeID.put(e.getGeneName(), createAnnotation(e)));
}
 
开发者ID:ProgrammingLife2015,项目名称:dnainator,代码行数:24,代码来源:Neo4jBatchBuilder.java

示例6: NeoDb

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
public NeoDb(String dbPath, long flushInterval, int cacheCapacity) throws IOException {
	this.flushInterval = flushInterval;
	this.cacheCapacity = cacheCapacity;
	File tempStoreDir = new File(dbPath);
	FileUtils.deleteRecursively(tempStoreDir);
	this.inserter = BatchInserters.inserter(tempStoreDir);
	this.indexProvider = new LuceneBatchInserterIndexProvider(this.inserter);
}
 
开发者ID:bigbai0210,项目名称:Oracle2Neo4j,代码行数:9,代码来源:NeoDb.java

示例7: Neo4jBatchDatabase

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
/**
 * Constructor that create an embedded database.
 *
 * @param path          Path of the graph database folder
 * @param configuration Configuration map of database
 */
public Neo4jBatchDatabase(String path, Map<String, String> configuration) {
    try {
        // Initialize batch inserter
        this.inserter = BatchInserters.inserter(new File(path), configuration);

        // Init
        this.indexProvider = new LuceneBatchInserterIndexProvider(inserter);
        this.batchInserterIndexes = new HashMap<>();

    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:sim51,项目名称:neo4j-talend-component,代码行数:20,代码来源:Neo4jBatchDatabase.java

示例8: batchInsert

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
@Test
public void batchInsert() throws Exception
{
    Neo4jTestCase.deleteFileOrDirectory( new File(
            "target/neo4jdb-batchinsert" ) );
    // START SNIPPET: batchInsert
    BatchInserter inserter = BatchInserters.inserter( "target/neo4jdb-batchinsert" );
    BatchInserterIndexProvider indexProvider =
            new LuceneBatchInserterIndexProvider( inserter );
    BatchInserterIndex actors =
            indexProvider.nodeIndex( "actors", MapUtil.stringMap( "type", "exact" ) );
    actors.setCacheCapacity( "name", 100000 );

    Map<String, Object> properties = MapUtil.map( "name", "Keanu Reeves" );
    long node = inserter.createNode( properties );
    actors.add( node, properties );

    //make the changes visible for reading, use this sparsely, requires IO!
    actors.flush();

    // Make sure to shut down the index provider as well
    indexProvider.shutdown();
    inserter.shutdown();
    // END SNIPPET: batchInsert

    GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( "target/neo4jdb-batchinsert" );
    try ( Transaction tx = db.beginTx() )
    {
        Index<Node> index = db.index().forNodes( "actors" );
        Node reeves = index.get( "name", "Keanu Reeves" ).next();
        assertEquals( node, reeves.getId() );
    }
    db.shutdown();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:35,代码来源:ImdbDocTest.java

示例9: shouldIndexNodesWithMultipleLabels

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
@Test
public void shouldIndexNodesWithMultipleLabels() throws Exception
{
    // Given
    String path = dbRule.getStoreDirAbsolutePath();
    BatchInserter inserter = BatchInserters.inserter( path );

    inserter.createNode( map( "name", "Bob" ), label( "User" ), label( "Admin" ) );

    inserter.createDeferredSchemaIndex( label( "User" ) ).on( "name" ).create();
    inserter.createDeferredSchemaIndex( label( "Admin" ) ).on( "name" ).create();

    // When
    inserter.shutdown();

    // Then
    GraphDatabaseService db = dbRule.getGraphDatabaseService();
    try ( Transaction tx = db.beginTx() )
    {
        assertThat( count( db.findNodes( label( "User" ), "name", "Bob" ) ), equalTo(1) );
        assertThat( count( db.findNodes( label( "Admin" ), "name", "Bob" ) ), equalTo(1) );
    }
    finally
    {
        db.shutdown();
    }

}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:29,代码来源:BatchInsertionIT.java

示例10: shouldBeAbleToMakeRepeatedCallsToSetNodePropertyWithMultiplePropertiesPerBlock

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
@Test
public void shouldBeAbleToMakeRepeatedCallsToSetNodePropertyWithMultiplePropertiesPerBlock() throws Exception
{
    BatchInserter inserter = BatchInserters.inserter( dbRule.getStoreDirAbsolutePath() );
    long nodeId = inserter.createNode( Collections.<String, Object>emptyMap() );

    final Object finalValue1 = 87;
    final Object finalValue2 = 3.14;
    inserter.setNodeProperty( nodeId, "a", "some property value" );
    inserter.setNodeProperty( nodeId, "a", 42 );
    inserter.setNodeProperty( nodeId, "b", finalValue2 );
    inserter.setNodeProperty( nodeId, "a", finalValue2 );
    inserter.setNodeProperty( nodeId, "a", true );
    inserter.setNodeProperty( nodeId, "a", finalValue1 );
    inserter.shutdown();

    GraphDatabaseService db = dbRule.getGraphDatabaseService();
    try(Transaction ignored = db.beginTx())
    {
        assertThat( db.getNodeById( nodeId ).getProperty( "a" ), equalTo( finalValue1 ) );
        assertThat( db.getNodeById( nodeId ).getProperty( "b" ), equalTo( finalValue2 ) );
    }
    finally
    {
        db.shutdown();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:28,代码来源:BatchInsertionIT.java

示例11: getBatchInserterInstance

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
/**
 * 
 * @return
 * @return
 */
private static BatchInserter getBatchInserterInstance(Map<String, String> config)
{
  if (batchInserter == null)
  {
  	try {
      batchInserter = BatchInserters.inserter(new File(NEO4J_STORE_DIR), config);
  	}
  	catch (Exception e) {
  	}
  }

  return batchInserter;
}
 
开发者ID:neo4art,项目名称:neo4art,代码行数:19,代码来源:Neo4ArtBatchInserterSingleton.java

示例12: newBatchInserterInstance

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
private void newBatchInserterInstance(File storeDir, Map<String, String> config) {
  
  if (batchInserter == null) {
    try {
      batchInserter = BatchInserters.inserter(storeDir, config);
      logger.info("Batch inserter instance created. Neo4j store directory = " + storeDir);
    }
    catch (Exception e) {
      logger.error("Error creating batch inserter in store dir " + storeDir);
    }
  }    
}
 
开发者ID:neo4art,项目名称:neo4art,代码行数:13,代码来源:BatchInserterConnectionManager.java

示例13: getGraph

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
public static BatchInserter getGraph(String st) {

		File f = new File(st);

		Map<String, String> config = new HashMap<String, String>();
		long x = Runtime.getRuntime().maxMemory() / 1000000 / 60;
		config.put("neostore.nodestore.db.mapped_memory", 3 * x + "M");
		config.put("neostore.relationshipstore.db.mapped_memory", 14 * x + "M");
		config.put("neostore.propertystore.db.mapped_memory", x + "M");
		config.put("neostore.propertystore.db.strings.mapped_memory", 2 * x
				+ "M");
		config.put("neostore.propertystore.db.arrays.mapped_memory", x + "M");
		config.put("neostore.propertystore.db.index.keys.mapped_memory", x
				+ "M");
		config.put("neostore.propertystore.db.index.mapped_memory", x + "M");
		config.put("keep_logical_logs", "false");

		System.out.println("Opening: " + f.getPath() + "\nWITH: "
				+ Runtime.getRuntime().maxMemory() / 1000000000 + "."
				+ Runtime.getRuntime().maxMemory() % 1000000000
				+ " GB of HEAP and: " + getTotalVM(config) / 1000 + "."
				+ getTotalVM(config) % 1000
				+ " GB of Database VM (embedded in heap)");

		BatchInserter i = BatchInserters.inserter(f.getPath(), config);

		registerShutdownHook(i);

		return i;

	}
 
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:32,代码来源:Neo4JBatchUtil.java

示例14: main

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
public static void main(String[] args) {
	//GraphDatabaseService njgraph = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(NEO_STORE).loadPropertiesFromFile("neo4j.properties").newGraphDatabase();
	BatchInserter db = BatchInserters.inserter(NEO_STORE);
	Course_Test.write(db);
	//Course_Test.getJob(njgraph);
	//Course_Test.search(njgraph);
	//Course_Test.insertData(njgraph);
	//njgraph.shutdown();
	db.shutdown();
	log.info("Connection closed");
}
 
开发者ID:semr,项目名称:neo4jena,代码行数:12,代码来源:Course_Test.java

示例15: getInserter

import org.neo4j.unsafe.batchinsert.BatchInserters; //导入依赖的package包/类
@Provides
@Singleton
BatchInserter getInserter() throws IOException {
  File location = new File(config.getGraphConfiguration().getLocation());
  logger.info("Getting BatchInserter for " + location);
  return BatchInserters.inserter(new File(location.toString()), config.getGraphConfiguration()
      .getNeo4jConfig());
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:9,代码来源:OwlLoaderModule.java


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