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


Java BatchInserterIndex类代码示例

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


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

示例1: testInsertionSpeed

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

import org.neo4j.unsafe.batchinsert.BatchInserterIndex; //导入依赖的package包/类
private static long getOrCreateUserNodeID(final String userid,
                                          final Map<String, Long> usersNodesMap,
                                          final BatchInserterIndex usersIndex,
                                          final BatchInserter inserter,
                                          final Label label) {

    long userNodeID;

    if (usersNodesMap.containsKey(userid)) {
        userNodeID = usersNodesMap.get(userid);
    } else {
        userNodeID = inserter.createNode(MapUtil.map("node_id", userid), label);
        usersNodesMap.put(userid, userNodeID);
        usersIndex.add(userNodeID, MapUtil.map("node_id", userid));
    }

    return userNodeID;

}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:20,代码来源:ObelixBatchImport.java

示例6: getOrCreateItemNodeID

import org.neo4j.unsafe.batchinsert.BatchInserterIndex; //导入依赖的package包/类
private static long getOrCreateItemNodeID(final String itemid,
                                          final Map<String, Long> itemsNodesMap,
                                          final BatchInserterIndex itemsIndex,
                                          final BatchInserter inserter,
                                          final Label label) {

    long itemNodeID;

    if (itemsNodesMap.containsKey(itemid)) {
        itemNodeID = itemsNodesMap.get(itemid);
    } else {
        itemNodeID = inserter.createNode(MapUtil.map("node_id", itemid), label);
        itemsNodesMap.put(itemid, itemNodeID);
        itemsIndex.add(itemNodeID, MapUtil.map("node_id", itemid));
    }

    return itemNodeID;

}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:20,代码来源:ObelixBatchImport.java

示例7: getOrCreateRelatinshipID

import org.neo4j.unsafe.batchinsert.BatchInserterIndex; //导入依赖的package包/类
private static long getOrCreateRelatinshipID(final String timestamp,
                                             final long userNodeid,
                                             final long itemNodeid,
                                             final Map<String, Long> relationshipsMap,
                                             final BatchInserterIndex relationshipIndex,
                                             final BatchInserter inserter,
                                             final RelationshipType relType) {

    long relationID;
    String uniqueRelationID = userNodeid + itemNodeid + timestamp;
    if (relationshipsMap.containsKey(uniqueRelationID)) {
        relationID = relationshipsMap.get(uniqueRelationID);
    } else {

        relationID = inserter.createRelationship(userNodeid, itemNodeid, relType,
                MapUtil.map("timestamp", timestamp));

        relationshipsMap.put(uniqueRelationID, relationID);
        relationshipIndex.add(relationID, MapUtil.map("useritem", uniqueRelationID));
    }

    return relationID;

}
 
开发者ID:inveniosoftware-contrib,项目名称:obelix,代码行数:25,代码来源:ObelixBatchImport.java

示例8: createIndex

import org.neo4j.unsafe.batchinsert.BatchInserterIndex; //导入依赖的package包/类
public BatchInserterIndex createIndex(String labelName, String pk) {
	BatchInserterIndex idx = this.getIndex(labelName);
	idx.setCacheCapacity(pk, this.cacheCapacity);
	this.counter.put(labelName, this.flushInterval);
	this.pkMap.put(labelName, pk);
	return idx;
}
 
开发者ID:bigbai0210,项目名称:Oracle2Neo4j,代码行数:8,代码来源:NeoDb.java

示例9: createNode

import org.neo4j.unsafe.batchinsert.BatchInserterIndex; //导入依赖的package包/类
private synchronized void createNode(String labelName, Map<String, Object> properties, BatchInserterIndex idx,
		String pk) {
	idx.add(this.inserter.createNode(properties, DynamicLabel.label(labelName)),
			MapUtil.map(pk, properties.get(pk)));
	long n = this.counter.get(labelName);
	this.counter.put(labelName, ++n);
	if(n % this.flushInterval == 0)
		idx.flush();
}
 
开发者ID:bigbai0210,项目名称:Oracle2Neo4j,代码行数:10,代码来源:NeoDb.java

示例10: createBatchIndex

import org.neo4j.unsafe.batchinsert.BatchInserterIndex; //导入依赖的package包/类
/**
 * Create and store the index, if it doesn't exist.
 *
 * @param indexName      Name of the index
 * @param indexCacheSize Number of element into the cache size for the index
 */
public void createBatchIndex(String indexName, Integer indexCacheSize) {
    if (!batchInserterIndexes.containsKey(indexName)) {
        BatchInserterIndex index = indexProvider.nodeIndex(indexName, MapUtil.stringMap("type", "exact"));
        if (indexCacheSize > 0) {
            index.setCacheCapacity(BACTH_INDEX_ID_NAME, indexCacheSize);
        }
        batchInserterIndexes.put(indexName, index);
    } else {
        log.trace("Index [" + indexName + "] already exist");
    }
}
 
开发者ID:sim51,项目名称:neo4j-talend-component,代码行数:18,代码来源:Neo4jBatchDatabase.java

示例11: flushBatchIndex

import org.neo4j.unsafe.batchinsert.BatchInserterIndex; //导入依赖的package包/类
/**
 * Flush the specified index on the disk, so it will be available after for search.
 *
 * @param indexName Name of the index to flush
 */
public void flushBatchIndex(String indexName) {
    if (batchInserterIndexes.containsKey(indexName)) {
        BatchInserterIndex index = batchInserterIndexes.get(indexName);
        index.flush();
    } else {
        log.trace("Flushing a non exist index ... [" + indexName + "]");
    }
}
 
开发者ID:sim51,项目名称:neo4j-talend-component,代码行数:14,代码来源:Neo4jBatchDatabase.java

示例12: indexNodeInBatchIndex

import org.neo4j.unsafe.batchinsert.BatchInserterIndex; //导入依赖的package包/类
/**
 * Push a node importId into the batch index.
 *
 * @param indexName     The batch index name
 * @param node          Neo4j identifier
 * @param importIdValue Import identifier
 */
public void indexNodeInBatchIndex(String indexName, long node, Object importIdValue) {
    if (batchInserterIndexes.containsKey(indexName)) {
        BatchInserterIndex index = batchInserterIndexes.get(indexName);

        Map<String, Object> props = new HashMap<>();
        props.put(BACTH_INDEX_ID_NAME, importIdValue);
        index.add(node, props);
    } else {
        log.trace("Can't index node " + node + "/" + importIdValue + " into a none existant index [" + indexName + "]");
    }
}
 
开发者ID:sim51,项目名称:neo4j-talend-component,代码行数:19,代码来源:Neo4jBatchDatabase.java

示例13: batchInsert

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

示例14: createLegacyNodeIndex

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

示例15: getFromLegacyNodeIndex

import org.neo4j.unsafe.batchinsert.BatchInserterIndex; //导入依赖的package包/类
/**
 * TODO it's not necessary to provide key and value: we could also just pass a Node 'cause we already know the key (defined at index creation time) 
 * 
 * @param indexName
 * @param key
 * @param value
 * @return
 */
public static IndexHits<Long> getFromLegacyNodeIndex(Neo4ArtLegacyIndex neo4ArtLegacyIndex, String key, Object value)
{
  BatchInserterIndex batchInserterIndex = getBatchInserterIndexProviderInstance().nodeIndex(neo4ArtLegacyIndex.getName(), getLegacyNodeIndexConfig(neo4ArtLegacyIndex.getType()));
  
  if (batchInserterIndex == null)
  {
    throw new IllegalArgumentException("Index " + neo4ArtLegacyIndex.getName() + " doesn't exists. You must create it before getting something from it.");
  }    

  return batchInserterIndex.get(key, value);
}
 
开发者ID:neo4art,项目名称:neo4art,代码行数:20,代码来源:Neo4ArtBatchInserterSingleton.java


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