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

Java Iterables类代码示例

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

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



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

示例1: testOneMatchWithPlayers

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Test
public void testOneMatchWithPlayers() {
    Player white = new Player("Line");
    Player black = new Player("Ole-Martin");
    white = playerRepository.save(white);
    black = playerRepository.save(black);
    Match match = new Match(white, black);
    match.reportResult(Result.WHITE);
    matchRepository.save(match, 1);

    Iterable<Player> players = playerRepository.findAll();
    List<Player> list = new ArrayList<>();
    Iterables.addAll(list, players);

    assertThat(matchRepository.count(), equalTo(1L));
    assertThat(list.size(), equalTo(2));
    players.forEach(System.out::println);
}
 
开发者ID:olemartin,项目名称:chess-tournament,代码行数:19,代码来源:RepositoriesTest.java


示例2: testExplicitBasionyms

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
/**
 * Make sure explicit basionym i.e. original name usage relations make it into the backbone.
 * Dataset 21 contains a conflicting basionym for Martes martes, make sure we use the preferred source dataset 20.
 */
@Test
public void testExplicitBasionyms() throws Exception {
  ClasspathSourceList src = ClasspathSourceList.source(20, 21);
  build(src);

  assertEquals(1, Iterables.count(getCanonical("Mustela martes", Rank.SPECIES).node.getRelationships(RelType.BASIONYM_OF)));
  assertEquals(1, Iterables.count(getCanonical("Martes martes", Rank.SPECIES).node.getRelationships(RelType.BASIONYM_OF)));

  NameUsage u = getUsage(getCanonical("Martes martes", Rank.SPECIES).node);
  assertEquals("Mustela martes Linnaeus, 1758", u.getBasionym());

  u = getUsage(getCanonical("Martes markusis", Rank.SPECIES).node);
  assertEquals("Cellophania markusa Döring, 2001", u.getBasionym());

  u = getUsage(getCanonical("Cellophania markusa", Rank.SPECIES).node);
  assertNull(u.getBasionym());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:22,代码来源:NubBuilderIT.java


示例3: testProParteSynonym

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
/**
 * Pro parte synonyms should exist as a single synonym node with multiple synonym relations
 */
@Test
public void testProParteSynonym() throws Exception {
  ClasspathSourceList src = ClasspathSourceList.source(15, 16);
  build(src);

  NubUsage u = assertCanonical("Poa pubescens", "Lej.", null, Rank.SPECIES, Origin.SOURCE, TaxonomicStatus.PROPARTE_SYNONYM, null);
  assertEquals(3, u.sourceIds.size());

  NameUsage nu = dao.readUsage(u.node, true);
  assertEquals("Poa pratensis L.", nu.getAccepted());

  List<Relationship> rels = Iterables.asList(u.node.getRelationships(RelType.PROPARTE_SYNONYM_OF, Direction.OUTGOING));
  Relationship acc = Iterables.single(u.node.getRelationships(RelType.SYNONYM_OF, Direction.OUTGOING));
  assertEquals(1, rels.size());
  assertNotEquals(rels.get(0).getEndNode(), acc.getEndNode());

  assertTree("15 16.txt");
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:22,代码来源:NubBuilderIT.java


示例4: assertTree

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
private void assertTree(String filename) throws IOException {
  System.out.println("assert tree from " + filename);
  NubTree expected = NubTree.read("trees/" + filename);

  // compare trees
  assertEquals("Number of roots differ", expected.getRoot().children.size(), Iterators.count(dao.allRootTaxa()));
  TreeAsserter treeAssert = new TreeAsserter(expected);
  TreeWalker.walkTree(dao.getNeo(), true, treeAssert);
  assertTrue("There should be more taxa", treeAssert.completed());

  // verify all nodes are walked in the tree and contains the expected numbers
  long neoCnt = Iterables.count(dao.getNeo().getAllNodes());
  // pro parte nodes are counted multiple times, so expected count can be higher than pure number of nodes - but never less!
  System.out.println("expected nodes: " + expected.getCount());
  System.out.println("counted nodes: " + neoCnt);
  assertTrue(expected.getCount() >= neoCnt);
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:18,代码来源:NubBuilderIT.java


示例5: shouldNotLeaveLuceneIndexFilesHangingAroundIfConstraintCreationFails

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Test
public void shouldNotLeaveLuceneIndexFilesHangingAroundIfConstraintCreationFails()
{
    // given
    GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI();

    try ( Transaction tx = db.beginTx() )
    {
        for ( int i = 0; i < 2; i++ )
        {
            Node node1 = db.createNode( LABEL );
            node1.setProperty( "prop", true );
        }

        tx.success();
    }

    // when
    try ( Transaction tx = db.beginTx() )
    {
        db.schema().constraintFor( LABEL ).assertPropertyIsUnique( "prop" ).create();
        fail("Should have failed with ConstraintViolationException");
        tx.success();
    }
    catch ( ConstraintViolationException ignored )  { }

    // then
    try(Transaction ignore = db.beginTx())
    {
        assertEquals(0, Iterables.count(db.schema().getIndexes() ));
    }

    File schemaStorePath = SchemaIndexProvider
            .getRootDirectory( new File( db.getStoreDir() ), LuceneSchemaIndexProviderFactory.KEY );

    String indexId = "1";
    File[] files = new File(schemaStorePath, indexId ).listFiles();
    assertNotNull( files );
    assertEquals(0, files.length);
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:41,代码来源:ConstraintCreationIT.java


示例6: removeNodeFromIndex

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
private void removeNodeFromIndex(Node node, String entityLabel) {
	List<Label> labels = Iterables.asList(node.getLabels());
	if(labels.contains(LABEL_ENTITY_TYPE_CLASS)) {
		graphdb.index().forNodes(ENTITY_TYPE_CLASS).remove(node);
	}
	if(labels.contains(LABEL_PROPERTY_ENTITY_TYPE)) {
		graphdb.index().forNodes(PROPERTY_ENTITY_TYPE).remove(node);
	}
	if(labels.contains(Label.label(entityLabel))) {
		graphdb.index().forNodes(entityLabel).remove(node);
	}
}
 
开发者ID:EsfingeFramework,项目名称:aomrolemapper,代码行数:13,代码来源:Neo4jAOM.java


示例7: findEntityByIDAndEntityType

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
private Node findEntityByIDAndEntityType(Object id, IEntityType entityType) throws EsfingeAOMException {
	ResourceIterator<Node> findNodes = graphdb.findNodes(Label.label(entityType.getName()));
	for (Node entityTypeGraphNode : findNodes.stream().collect(Collectors.toList())) {
		Iterable<Relationship> typeObjectsRelationships = entityTypeGraphNode.getRelationships(RELATIONSHIP_ENTITY_TYPE_OBJECT);
		for (Relationship relationship : Iterables.asList(typeObjectsRelationships)) {
			Node entityGraphNode = relationship.getEndNode();
			if(entityGraphNode.getProperty(ID_FIELD_NAME).equals(id)){
				return entityGraphNode;
			}
		}
	}
	return null;
}
 
开发者ID:EsfingeFramework,项目名称:aomrolemapper,代码行数:14,代码来源:Neo4jAOM.java


示例8: existsRelationshipForPropertyType

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
private boolean existsRelationshipForPropertyType(Node entityTypeGraphNode, String propertyTypeName) {
	List<Relationship> relationships = Iterables.asList(entityTypeGraphNode.getRelationships());
	for (Relationship relationship : relationships) {
		Node propertyTypeGraphNode = relationship.getEndNode();
		if(propertyTypeGraphNode.hasProperty(PROPERTY_TYPE_NAME) &&
		   propertyTypeGraphNode.getProperty(PROPERTY_TYPE_NAME).equals(propertyTypeName)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:EsfingeFramework,项目名称:aomrolemapper,代码行数:12,代码来源:Neo4jAOM.java


示例9: resetPropertiesValues

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
public void resetPropertiesValues() {
	long nodesCount = 0;

	if (graph != null) {
		nodesCount = Iterables.count(GlobalGraphOperations.at(graph).getAllNodes());
	}

	// Tuning
	if (nodesCount >= 100) {
		setScalingRatio(2.0);
	} else {
		setScalingRatio(10.0);
	}
	setStrongGravityMode(false);
	setGravity(1.);

	// Behavior
	setOutboundAttractionDistribution(false);
	setLinLogMode(false);
	setAdjustSizes(false);
	setEdgeWeightInfluence(1.);

	// Performance
	if (nodesCount >= 50000) {
		setJitterTolerance(10d);
	} else if (nodesCount >= 5000) {
		setJitterTolerance(1d);
	} else {
		setJitterTolerance(0.1d);
	}
	if (nodesCount >= 1000) {
		setBarnesHutOptimize(true);
	} else {
		setBarnesHutOptimize(false);
	}
	setBarnesHutTheta(1.2);
	setThreadsCount(2);
}
 
开发者ID:gsummer,项目名称:neoLayouts,代码行数:39,代码来源:ForceAtlas2.java


示例10: parents

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
/**
 * @return the parent (or accepted) nodes for a given node.
 */
public List<Node> parents(Node n) {
  return Iterables.asList(Traversals.PARENTS
      .relationships(RelType.SYNONYM_OF, Direction.OUTGOING)
      .traverse(n)
      .nodes());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:10,代码来源:NubDb.java


示例11: testListSources

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
/**
 * Test reading the source list
 */
@Test
public void testListSources() throws Exception {
  List<NubSource> sources = Iterables.asList(src);
  assertEquals(3, sources.size());
  assertEquals(Rank.PHYLUM, sources.get(0).ignoreRanksAbove);
  assertEquals(Rank.FAMILY, sources.get(1).ignoreRanksAbove);
  assertEquals(Rank.FAMILY, sources.get(2).ignoreRanksAbove);
  assertEquals(CHECKLIST_KEY, sources.get(0).key);
  assertEquals(oldDKey, sources.get(1).key);
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:14,代码来源:ClbSourceListTest.java


示例12: testListSources

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Test
public void testListSources() throws Exception {
  ClasspathSourceList src = ClasspathSourceList.source(1, 2, 3, 4, 5, 10, 11, 23, 12, 31);
  src.setSourceRank(23, Rank.KINGDOM);
  List<NubSource> sources = Iterables.asList(src);
  assertEquals(10, sources.size());
  assertEquals(Rank.FAMILY, sources.get(0).ignoreRanksAbove);
  assertEquals(Rank.KINGDOM, sources.get(7).ignoreRanksAbove);
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:10,代码来源:ClasspathSourceListTest.java


示例13: testNeoIndices

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Test
public void testNeoIndices() throws Exception {
  final UUID datasetKey = datasetKey(1);

  Normalizer norm = Normalizer.create(cfg, datasetKey);
  norm.run();

  openDb(datasetKey);
  compareStats(norm.getStats());

  Set<String> taxonIndices = Sets.newHashSet();
  taxonIndices.add(NeoProperties.TAXON_ID);
  taxonIndices.add(NeoProperties.SCIENTIFIC_NAME);
  taxonIndices.add(NeoProperties.CANONICAL_NAME);
  try (Transaction tx = beginTx()) {
    Schema schema = dao.getNeo().schema();
    for (IndexDefinition idf : schema.getIndexes(Labels.TAXON)) {
      List<String> idxProps = Iterables.asList(idf.getPropertyKeys());
      assertTrue(idxProps.size() == 1);
      assertTrue(taxonIndices.remove(idxProps.get(0)));
    }

    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.TAXON_ID, "1001")));
    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.SCIENTIFIC_NAME, "Crepis bakeri Greene")));
    assertNotNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.CANONICAL_NAME, "Crepis bakeri")));

    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.TAXON_ID, "x1001")));
    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.SCIENTIFIC_NAME, "xCrepis bakeri Greene")));
    assertNull(Iterators.singleOrNull(dao.getNeo().findNodes(Labels.TAXON, NeoProperties.CANONICAL_NAME, "xCrepis bakeri")));
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:32,代码来源:NormalizerTest.java


示例14: getSingleRelationship

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Override
public Relationship getSingleRelationship(RelationshipType relationshipType, Direction direction) {
    return Iterables.single(getRelationships(relationshipType, direction));
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-ml-procedures,代码行数:5,代码来源:VirtualNode.java


示例15: getDegree

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
@Override
public int getDegree(RelationshipType relationshipType) {
    return (int) Iterables.count(getRelationships(relationshipType));
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-ml-procedures,代码行数:5,代码来源:VirtualNode.java


示例16: calculate

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
/***
 * Performs one iteration of the pageRank algorithm.
 *
 * @param nodeLabel The label for which the algorithm needs to be calcualted
 * @param relationship The relationship to use to check if the nodes are related or not
 * @param property The property to update with the new pagerank
 */
@Procedure("pagerank.calculate")
@PerformsWrites
public void calculate( @Name("nodeLabel") String nodeLabel,
                       @Name("relationship") String relationship,
                       @Name("property") String property )
{
    Label label = Label.label(nodeLabel);
    RelationshipType relationshipType = RelationshipType.withName(relationship);

    try (ResourceIterator<Node> nodes = db.findNodes(label)) {
        while (nodes.hasNext()) {
            Node destination = nodes.next();

            Iterable<Relationship> relationships = destination.getRelationships(Direction.INCOMING, relationshipType);

            double points = 0;

            for (Relationship r : relationships) {
                Node source = r.getStartNode();
                if (!source.hasLabel(label)) {
                    continue;
                }
                if (source.equals(destination)) {
                    continue;
                }

                // TODO: this will calculate relations which hav an outgoing link to a node that doesn't have the
                //       needed label as well, but checking this might make the code less performant
                //       it will also calculate relations which go back to the original node, which also skews the result
                long sourceRelationshipCount = Iterables.count(source.getRelationships(Direction.OUTGOING, relationshipType));

                if (source.hasProperty(property) && source.getProperty(property) instanceof Double) {
                    points += (Double)source.getProperty(property) / sourceRelationshipCount;
                }
            }

            destination.setProperty(property, PAGE_RANK_DAMPING + (1-PAGE_RANK_DAMPING)*points);
        }
    }
}
 
开发者ID:sztupy,项目名称:tumblr-neo4j,代码行数:48,代码来源:PageRank.java


示例17: ParallelCentralityTask

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
public ParallelCentralityTask(Set<Node> chunk,Set<Node> component, GraphDatabaseService graph, boolean eccentricityFlag, boolean betweennessFlag, boolean stressFlag, boolean avgSPFlag) {
	this.starts = chunk;
	this.graph = graph;
	

	RelationshipType[] types = null;
	try (Transaction tx = graph.beginTx()){

		types = Iterables.toArray(RelationshipType.class,GlobalGraphOperations.at(graph).getAllRelationshipTypes());
		tx.success();
	}

	SingleSourceShortestPath<Integer> sssPath = new SingleSourceShortestPathDijkstra<Integer>(0, null, new CostEvaluator<Integer>(){
		@Override
		public Integer getCost(Relationship relationship, Direction direction) {

			return new Integer(1);
		}
	}, new IntegerAdder(), new IntegerComparator(), Direction.BOTH, types);

	ppc = new LogParallelCentralityCalculation<Integer>(sssPath, chunk);

	if(eccentricityFlag){
		eccentricity = new Eccentricity2<Integer>( sssPath, 0,component, new IntegerComparator() );
		ppc.addCalculation(eccentricity);
	}

	if(betweennessFlag){
		betweennessCentrality = new BetweennessCentralityMulti<Integer>(sssPath, component );
		ppc.addCalculation(betweennessCentrality);
	}

	if(stressFlag){
		stressCentrality = new StressCentrality<Integer>(sssPath, component );
		ppc.addCalculation(stressCentrality);
	}

	if(avgSPFlag){
		avgSP = new AverageShortestPathMulti<Integer>(sssPath, component);
		ppc.addCalculation(avgSP);
	}

}
 
开发者ID:gsummer,项目名称:neoNetworkAnalyzer,代码行数:44,代码来源:ParallelCentralityTask.java


示例18: findRootUsage

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
private NubUsage findRootUsage(NubUsage u) {
  try (Transaction tx = db.beginTx()) {
    Node root = Iterables.last(Traversals.PARENTS.traverse(u.node).nodes());
    return db.dao().readNub(root);
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:7,代码来源:NeoAssertionEngine.java


示例19: countDescendants

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
private long countDescendants(NubUsage u) {
  return Iterables.count(Traversals.DESCENDANTS.traverse(u.node).nodes());
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:4,代码来源:NubDb.java


示例20: getDirectParent

import org.neo4j.helpers.collection.Iterables; //导入依赖的package包/类
/**
 * @return the last parent or the node itself if no parent exists
 */
protected RankedName getDirectParent(Node n) {
  Node p = Iterables.lastOrNull(Traversals.PARENTS.traverse(n).nodes());
  return dao.readRankedName(p != null ? p : n);
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:8,代码来源:ImportDb.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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