• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BatchInserterIndexProvider类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testInsertionSpeed

import org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider; //导入依赖的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


示例2: testBatchIndexToAutoIndex

import org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider; //导入依赖的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


示例3: initValueIndex

import org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider; //导入依赖的package包/类
protected void initValueIndex() throws DMPGraphException {

		try {

			final Tuple<BatchInserterIndex, BatchInserterIndexProvider> valuesIndexTuple = getOrCreateIndex(GraphIndexStatics.VALUES_INDEX_NAME,
					GraphStatics.VALUE, true, 1);
			values = valuesIndexTuple.v1();
			valuesProvider = valuesIndexTuple.v2();
		} catch (final Exception e) {

			final String message = "couldn't load indices successfully";

			BatchNeo4jProcessor.LOG.error(message, e);
			BatchNeo4jProcessor.LOG.debug("couldn't finish writing successfully");

			throw new DMPGraphException(message);
		}
	}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:19,代码来源:BatchNeo4jProcessor.java


示例4: initStatementIndex

import org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider; //导入依赖的package包/类
private void initStatementIndex() throws DMPGraphException {

		try {

			final Tuple<BatchInserterIndex, BatchInserterIndexProvider> statementUUIDsIndexTuple = getOrCreateIndex(GraphIndexStatics.STATEMENT_UUIDS_INDEX_NAME, GraphStatics.UUID, false, 1);
			statementUUIDs = statementUUIDsIndexTuple.v1();
			statementUUIDsProvider = statementUUIDsIndexTuple.v2();
		} catch (final Exception e) {

			final String message = "couldn't load indices successfully";

			BatchNeo4jProcessor.LOG.error(message, e);
			BatchNeo4jProcessor.LOG.debug("couldn't finish write TX successfully");

			throw new DMPGraphException(message);
		}
	}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:18,代码来源:BatchNeo4jProcessor.java


示例5: batchInsert

import org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider; //导入依赖的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


示例6: createLegacyNodeIndex

import org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider; //导入依赖的package包/类
/**
 * 
 * @param neo4ArtLegacyIndex
 * @param cacheKey
 * @param cacheSize
 * @return
 */
public static void createLegacyNodeIndex(Neo4ArtLegacyIndex neo4ArtLegacyIndex, String cacheKey, int cacheSize)
{
  BatchInserterIndexProvider batchInserterIndexProvider = getBatchInserterIndexProviderInstance();

  BatchInserterIndex index = batchInserterIndexProvider.nodeIndex(neo4ArtLegacyIndex.getName(), getLegacyNodeIndexConfig(neo4ArtLegacyIndex.getType()));

  if (cacheSize != 0)
  {
    index.setCacheCapacity(cacheKey, cacheSize);
  }
}
 
开发者ID:neo4art,项目名称:neo4art,代码行数:19,代码来源:Neo4ArtBatchInserterSingleton.java


示例7: BatchHandler

import org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider; //导入依赖的package包/类
public BatchHandler(BatchInserter db2, int indexCache, int timeout) {
	this.db = db2;
	this.indexCache = indexCache;
	this.timeout = timeout;

	BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(db);
	index = indexProvider.nodeIndex("ttlIndex", MapUtil.stringMap("type", "exact"));
	index.setCacheCapacity(URI_PROPERTY, indexCache + 1);

}
 
开发者ID:semr,项目名称:neo4jena,代码行数:11,代码来源:BatchHandler.java


示例8: registerShutdownHook

import org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider; //导入依赖的package包/类
private static void registerShutdownHook(final BatchInserter graphDb,
                                         final BatchInserterIndexProvider indexProvider) {
    Runtime.getRuntime().addShutdownHook(new Thread() {
        @Override
        public void run() {
            graphDb.shutdown();
            indexProvider.shutdown();
        }
    });
}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:11,代码来源:ObelixBatchImport.java


示例9: getBatchIndexer

import org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider; //导入依赖的package包/类
public BatchInserterIndexProvider getBatchIndexer() {
	return batchindexer;
}
 
开发者ID:mondo-project,项目名称:mondo-hawk,代码行数:4,代码来源:Neo4JDatabase.java


示例10: getOrCreateIndex

import org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider; //导入依赖的package包/类
protected Tuple<BatchInserterIndex, BatchInserterIndexProvider> getOrCreateIndex(final String name, final String property,
                                                                                 final boolean nodeIndex, final int cachSize) {

	final BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(inserter);
	final BatchInserterIndex index;

	if (nodeIndex) {

		index = indexProvider.nodeIndex(name, MapUtil.stringMap("type", "exact"));
	} else {

		index = indexProvider.relationshipIndex(name, MapUtil.stringMap("type", "exact"));
	}

	index.setCacheCapacity(property, cachSize);

	return Tuple.tuple(index, indexProvider);
}
 
开发者ID:dswarm,项目名称:dswarm-graph-neo4j,代码行数:19,代码来源:BatchNeo4jProcessor.java


示例11: run

import org.neo4j.unsafe.batchinsert.BatchInserterIndexProvider; //导入依赖的package包/类
public static void run(final String neo4storage,
        final String redisQueueName, final String redisHost) {

    ObelixQueue redisQueueManager = new RedisObelixQueue(redisQueueName, redisHost);

    Label userLabel = DynamicLabel.label("User");
    Label itemLabel = DynamicLabel.label("Item");

    Map<String, Long> usersNodesMap = new HashMap<>();
    Map<String, Long> itemsNodesMap = new HashMap<>();
    Map<String, Long> relationshipsMap = new HashMap<>();

    Map<String, String> config = new HashMap<>();
    config.put("neostore.nodestore.db.mapped_memory", "2G");
    config.put("neostore.relationshipstore.db.mapped_memory", "9G");
    config.put("neostore.propertystore.db.mapped_memory", "800M");
    config.put("neostore.propertystore.db.strings.mapped_memory", "800M");
    config.put("neostore.propertystore.db.arrays.mapped_memory", "500M");

    BatchInserter inserter;

    inserter = BatchInserters.inserter(neo4storage, config);

    BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(inserter);

    registerShutdownHook(inserter, indexProvider);

    BatchInserterIndex usersIndex = indexProvider.nodeIndex("users",
            MapUtil.stringMap("type", "exact"));
    usersIndex.setCacheCapacity("node_id", NEO_CACHE_CAPACITY);

    BatchInserterIndex itemsIndex = indexProvider.nodeIndex("items",
            MapUtil.stringMap("type", "exact"));
    usersIndex.setCacheCapacity("node_id", NEO_CACHE_CAPACITY);

    BatchInserterIndex relationshipIndex = indexProvider.relationshipIndex("relationships",
            MapUtil.stringMap("type", "exact"));
    usersIndex.setCacheCapacity("timestamp", NEO_CACHE_CAPACITY);

    boolean notFinised = true;

    int c = 0;
    while (notFinised) {

        ObelixQueueElement result = redisQueueManager.pop();

        if (result == null) {
            notFinised = false;
        }

        if (result != null) {

            NeoEvent event = getEvent(result.toString());

            if (event == null) {
                continue;
            }

            long userid = getOrCreateUserNodeID(event.getUser(), usersNodesMap,
                    usersIndex, inserter, userLabel);

            long itemid = getOrCreateItemNodeID(event.getItem(), itemsNodesMap,
                    itemsIndex, inserter, itemLabel);


            getOrCreateRelatinshipID(event.getTimestamp(),
                    userid, itemid, relationshipsMap, relationshipIndex,
                    inserter, NeoHelpers.RelTypes.VIEWED);

        }

        c += 1;

        if (c % IMPORTS_BETWEEN_EACH_LOG_MESSAGE == 0) {
            LOGGER.info("Imported " + c);
        }
    }
}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:79,代码来源:ObelixBatchImport.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java VisualizationImageServer类代码示例发布时间:2022-05-22
下一篇:
Java Encoder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap