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


Java MapUtil类代码示例

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


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

示例1: testBatchIndexToAutoIndex

import org.neo4j.helpers.collection.MapUtil; //导入依赖的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

示例2: fulltext

import org.neo4j.helpers.collection.MapUtil; //导入依赖的package包/类
@Test
public void fulltext()
{
    // START SNIPPET: fulltext
    IndexManager index = graphDb.index();
    Index<Node> fulltextMovies = index.forNodes( "movies-fulltext",
            MapUtil.stringMap( IndexManager.PROVIDER, "lucene", "type", "fulltext" ) );
    // END SNIPPET: fulltext

    Index<Node> movies = index.forNodes( "movies" );
    Node theMatrix = movies.get( "title", "The Matrix" ).getSingle();
    Node theMatrixReloaded = movies.get( "title", "The Matrix Reloaded" ).getSingle();

    // START SNIPPET: fulltext
    fulltextMovies.add( theMatrix, "title", "The Matrix" );
    fulltextMovies.add( theMatrixReloaded, "title", "The Matrix Reloaded" );
    // search in the fulltext index
    Node found = fulltextMovies.query( "title", "reloAdEd" ).getSingle();
    // END SNIPPET: fulltext
    assertEquals( theMatrixReloaded, found );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:22,代码来源:ImdbDocTest.java

示例3: makeSureFulltextIndexCanBeCaseSensitive

import org.neo4j.helpers.collection.MapUtil; //导入依赖的package包/类
@Test
public void makeSureFulltextIndexCanBeCaseSensitive()
{
    Index<Node> index = nodeIndex( MapUtil.stringMap(
            new HashMap<>( LuceneIndexImplementation.FULLTEXT_CONFIG ),
                    "to_lower_case", "false" ) );
    Node node = graphDb.createNode();
    String key = "name";
    String value = "Mattias Persson";
    index.add( node, key, value );
    for ( int i = 0; i < 2; i++ )
    {
        assertThat( index.query( "name", "[A TO Z]" ), contains( node ) );
        assertThat( index.query( "name", "[a TO z]" ), isEmpty() );
        assertThat( index.query( "name", "Matt*" ), contains( node ) );
        assertThat( index.query( "name", "matt*" ), isEmpty() );
        assertThat( index.query( "name", "Persson" ), contains( node ) );
        assertThat( index.query( "name", "persson" ), isEmpty() );
        restartTx();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:22,代码来源:TestLuceneIndex.java

示例4: recoveryForRelationshipCommandsOnly

import org.neo4j.helpers.collection.MapUtil; //导入依赖的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

示例5: Neo4JEdgeIndex

import org.neo4j.helpers.collection.MapUtil; //导入依赖的package包/类
public Neo4JEdgeIndex(String name, Neo4JDatabase neo4jDatabase) {

		graph = neo4jDatabase;
		this.name = name;

		if (neo4jDatabase.getGraph() != null)
			index = neo4jDatabase.getIndexer().forRelationships(
					name,
					MapUtil.stringMap(IndexManager.PROVIDER, "lucene", "type",
							"exact"));
		else
			batchIndex = neo4jDatabase.getBatchIndexer().relationshipIndex(
					name,
					MapUtil.stringMap(IndexManager.PROVIDER, "lucene", "type",
							"exact"));

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

示例6: getOrCreateUserNodeID

import org.neo4j.helpers.collection.MapUtil; //导入依赖的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

示例7: getOrCreateItemNodeID

import org.neo4j.helpers.collection.MapUtil; //导入依赖的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

示例8: getOrCreateRelatinshipID

import org.neo4j.helpers.collection.MapUtil; //导入依赖的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

示例9: createGenomeElementNode

import org.neo4j.helpers.collection.MapUtil; //导入依赖的package包/类
private static long createGenomeElementNode(String version,
        String comment,
        String definition,
        BatchInserter inserter,
        BatchInserterIndex genomeElementVersionIndex,
        BatchInserterIndex nodeTypeIndex) {

    genomeElementProperties.put(GenomeElementNode.VERSION_PROPERTY, version);
    genomeElementProperties.put(GenomeElementNode.COMMENT_PROPERTY, comment);
    genomeElementProperties.put(GenomeElementNode.DEFINITION_PROPERTY, definition);

    long genomeElementId = inserter.createNode(genomeElementProperties);
    genomeElementVersionIndex.add(genomeElementId, MapUtil.map(GenomeElementNode.GENOME_ELEMENT_VERSION_INDEX, version));
    nodeTypeIndex.add(genomeElementId, MapUtil.map(Bio4jManager.NODE_TYPE_INDEX_NAME, GenomeElementNode.NODE_TYPE));

    return genomeElementId;

}
 
开发者ID:bio4j,项目名称:bio4j-neo4j,代码行数:19,代码来源:ImportRefSeq.java

示例10: createNode

import org.neo4j.helpers.collection.MapUtil; //导入依赖的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

示例11: createBatchIndex

import org.neo4j.helpers.collection.MapUtil; //导入依赖的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

示例12: createCategory

import org.neo4j.helpers.collection.MapUtil; //导入依赖的package包/类
private void createCategory(String title) {
      Map<String, Object> properties = MapUtil.map("title", title);
      long nodeId = inserter.createNode(properties, WikiCategory.Category);
      inMemoryIndex.put("c_"+title, nodeId);
      pageCounter.increment();
//System.out.println("Adding category "+title);
  }
 
开发者ID:cotrino,项目名称:language_KnowledgeMap,代码行数:8,代码来源:NodeCreator.java

示例13: batchInsert

import org.neo4j.helpers.collection.MapUtil; //导入依赖的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: makeSureCustomAnalyzerCanBeUsed

import org.neo4j.helpers.collection.MapUtil; //导入依赖的package包/类
@Test
public void makeSureCustomAnalyzerCanBeUsed()
{
    CustomAnalyzer.called = false;
    Index<Node> index = nodeIndex( MapUtil.stringMap(
            IndexManager.PROVIDER, "lucene", "analyzer", org.neo4j.index.impl.lucene.CustomAnalyzer.class.getName(),
            "to_lower_case", "true" ) );
    Node node = graphDb.createNode();
    String key = "name";
    String value = "The value";
    index.add( node, key, value );
    restartTx();
    assertTrue( CustomAnalyzer.called );
    assertThat( index.query( key, "[A TO Z]" ), contains( node ) );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:16,代码来源:TestLuceneIndex.java

示例15: makeSureCustomAnalyzerCanBeUsed2

import org.neo4j.helpers.collection.MapUtil; //导入依赖的package包/类
@Test
public void makeSureCustomAnalyzerCanBeUsed2()
{
    CustomAnalyzer.called = false;
    Index<Node> index = nodeIndex( "w-custom-analyzer-2", MapUtil.stringMap(
            IndexManager.PROVIDER, "lucene", "analyzer", org.neo4j.index.impl.lucene.CustomAnalyzer.class.getName(),
            "to_lower_case", "true", "type", "fulltext" ) );
    Node node = graphDb.createNode();
    String key = "name";
    String value = "The value";
    index.add( node, key, value );
    restartTx();
    assertTrue( CustomAnalyzer.called );
    assertThat( index.query( key, "[A TO Z]" ), contains( node ) );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:16,代码来源:TestLuceneIndex.java


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