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

Java ResourceIterable类代码示例

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

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



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

示例1: run

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public void run() {
  logger.info("Starting anonymous nodes tagger...");
  int taggedNodes = 0;
  Transaction tx = graphDb.beginTx();

  ResourceIterable<Node> allNodes = graphDb.getAllNodes();
  for (Node n : allNodes) {
    if (n.hasProperty(anonymousProperty)) {
      n.addLabel(OwlLabels.OWL_ANONYMOUS);
      taggedNodes++;
    }
    if (taggedNodes % batchCommitSize == 0) {
      tx.success();
      tx.close();
      tx = graphDb.beginTx();
    }
  }

  logger.info(taggedNodes + " nodes tagged.");
  tx.success();
  tx.close();
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:24,代码来源:AnonymousNodeTagger.java


示例2: run

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public void run() {
  logger.info("Starting all nodes labeling...");
  int processedNodes = 0;

  Transaction tx = graphDb.beginTx();

  ResourceIterable<Node> allNodes = graphDb.getAllNodes();
  for (Node n : allNodes) {
    n.addLabel(label);
    if (processedNodes % batchCommitSize == 0) {
      tx.success();
      tx.close();
      tx = graphDb.beginTx();
    }
    processedNodes++;
  }

  logger.info(processedNodes + " nodes labeled.");
  tx.success();
  tx.close();
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:23,代码来源:AllNodesLabeler.java


示例3: getAllNodes

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
public static List<String> getAllNodes(final GraphDatabaseService graphDb,
                                       final String labelName) {

    List<String> nodeIds = new ArrayList<>();
    Label label = DynamicLabel.label(labelName);
    ResourceIterable<Node> nodes;

    try (Transaction tx = graphDb.beginTx()) {
        nodes = GlobalGraphOperations.at(graphDb).getAllNodesWithLabel(label);

        for (Node node : nodes) {
            try {
                nodeIds.add(node.getProperty("node_id").toString());
            } catch (Exception e) {
                LOGGER.warn("Can't find a given node... skipping");
            }
        }

        tx.success();
    }

    return nodeIds;

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


示例4: getNodesFromCommunity

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public Set<Integer> getNodesFromCommunity(int community)
{
    Set<Integer> nodes = new HashSet<Integer>();
    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            ResourceIterable<Node> iter = neo4jGraph.findNodesByLabelAndProperty(NODE_LABEL, COMMUNITY, community);
            for (Node n : iter)
            {
                String nodeIdString = (String) (n.getProperty(NODE_ID));
                nodes.add(Integer.valueOf(nodeIdString));
            }
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to get nodes from community", e);
        }
    }
    return nodes;
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:25,代码来源:Neo4jGraphDatabase.java


示例5: moveNode

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public void moveNode(int nodeCommunity, int toCommunity)
{
    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            ResourceIterable<Node> fromIter = neo4jGraph.findNodesByLabelAndProperty(NODE_LABEL, NODE_COMMUNITY,
                nodeCommunity);
            for (Node node : fromIter)
            {
                node.setProperty(COMMUNITY, toCommunity);
            }
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to move node", e);
        }
    }
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:23,代码来源:Neo4jGraphDatabase.java


示例6: getCommunitySize

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public int getCommunitySize(int community)
{
    Set<Integer> nodeCommunities = new HashSet<Integer>();

    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            ResourceIterable<Node> nodes = neo4jGraph.findNodesByLabelAndProperty(NODE_LABEL, COMMUNITY, community);
            for (Node n : nodes)
            {
                Integer nodeCommunity = (Integer) (n.getProperty(COMMUNITY));
                nodeCommunities.add(nodeCommunity);
            }
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to get community size", e);
        }
    }

    return nodeCommunities.size();
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:27,代码来源:Neo4jGraphDatabase.java


示例7: nodeExists

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public boolean nodeExists(int nodeId)
{
    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            ResourceIterable<Node> nodesIter = neo4jGraph.findNodesByLabelAndProperty(NODE_LABEL, NODE_ID, nodeId);
            if (nodesIter.iterator().hasNext())
            {
                tx.success();
                return true;
            }
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to determine if node exists", e);
        }
    }
    return false;
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:24,代码来源:Neo4jGraphDatabase.java


示例8: getAll

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
public List<Root> getAll() {
    List<Root> roots = new ArrayList<>();
    ResourceIterable<Node> nodes = GlobalGraphOperations.at(database).getAllNodesWithLabel(NodeLabels.ROOT);

    for (Node node : nodes) {
        Root root = session.get(Root.class,node);
        roots.add(root);
    }
    return roots;
}
 
开发者ID:vahidooo,项目名称:quranic-graph,代码行数:11,代码来源:RootManagerImpl.java


示例9: getAll

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
public Iterable<Token> getAll() {
    List<Token> tokens = new ArrayList<>();
    ResourceIterable<Node> nodes = GlobalGraphOperations.at(database).getAllNodesWithLabel(NodeLabels.TOKEN);

    for (Node node : nodes) {
        Token root = session.get(Token.class,node);
        tokens.add(root);
    }
    return tokens;
}
 
开发者ID:vahidooo,项目名称:quranic-graph,代码行数:11,代码来源:TokenManagerImpl.java


示例10: create

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
public static ResourceIterable<Path> create(final List<Node> roots, final TraversalDescription td) {
  return new ResourceIterable<Path>() {
    @Override
    public ResourceIterator<Path> iterator() {
      return new MultiRootPathIterator(roots, td);
    }
  };
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:9,代码来源:MultiRootPathIterator.java


示例11: create

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
public static ResourceIterable<Node> create(final List<Node> roots, final TraversalDescription td) {
  return new ResourceIterable<Node>() {
    @Override
    public ResourceIterator<Node> iterator() {
      return new MultiRootNodeIterator(roots, td);
    }
  };
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:9,代码来源:MultiRootNodeIterator.java


示例12: getCommunitiesConnectedToNodeCommunities

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public Set<Integer> getCommunitiesConnectedToNodeCommunities(int nodeCommunities)
{
    Set<Integer> communities = new HashSet<Integer>();
    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            ResourceIterable<Node> nodes = neo4jGraph.findNodesByLabelAndProperty(Neo4jGraphDatabase.NODE_LABEL,
                NODE_COMMUNITY, nodeCommunities);
            for (Node n : nodes)
            {
                for (Relationship r : n.getRelationships(RelTypes.SIMILAR, Direction.OUTGOING))
                {
                    Node neighbour = r.getOtherNode(n);
                    Integer community = (Integer) (neighbour.getProperty(COMMUNITY));
                    communities.add(community);
                }
            }
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to get communities connected to node communities", e);
        }
    }

    return communities;
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:31,代码来源:Neo4jGraphDatabase.java


示例13: getNodesFromNodeCommunity

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public Set<Integer> getNodesFromNodeCommunity(int nodeCommunity)
{
    Set<Integer> nodes = new HashSet<Integer>();

    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            ResourceIterable<Node> iter = neo4jGraph.findNodesByLabelAndProperty(NODE_LABEL, NODE_COMMUNITY,
                nodeCommunity);
            for (Node n : iter)
            {
                String nodeIdString = (String) (n.getProperty(NODE_ID));
                nodes.add(Integer.valueOf(nodeIdString));
            }
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to get nodes from node community", e);
        }
    }

    return nodes;
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:28,代码来源:Neo4jGraphDatabase.java


示例14: getEdgesInsideCommunity

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public double getEdgesInsideCommunity(int nodeCommunity, int communityNodes)
{
    double edges = 0;
    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            ResourceIterable<Node> nodes = neo4jGraph.findNodesByLabelAndProperty(NODE_LABEL, NODE_COMMUNITY,
                nodeCommunity);
            ResourceIterable<Node> comNodes = neo4jGraph.findNodesByLabelAndProperty(NODE_LABEL, COMMUNITY,
                communityNodes);
            for (Node node : nodes)
            {
                Iterable<Relationship> relationships = node.getRelationships(RelTypes.SIMILAR, Direction.OUTGOING);
                for (Relationship r : relationships)
                {
                    Node neighbor = r.getOtherNode(node);
                    if (Iterables.contains(comNodes, neighbor))
                    {
                        edges++;
                    }
                }
            }
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to get edges inside community", e);
        }
    }

    return edges;
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:36,代码来源:Neo4jGraphDatabase.java


示例15: getCommunityWeight

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public double getCommunityWeight(int community)
{
    double communityWeight = 0;
    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            ResourceIterable<Node> iter = neo4jGraph.findNodesByLabelAndProperty(NODE_LABEL, COMMUNITY, community);
            if (Iterables.size(iter) > 1)
            {
                for (Node n : iter)
                {
                    communityWeight += getNodeOutDegree(n);
                }
            }
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to get community weight", e);
        }
    }

    return communityWeight;
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:28,代码来源:Neo4jGraphDatabase.java


示例16: getNodeCommunityWeight

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public double getNodeCommunityWeight(int nodeCommunity)
{
    double nodeCommunityWeight = 0;
    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            ResourceIterable<Node> iter = neo4jGraph.findNodesByLabelAndProperty(NODE_LABEL, NODE_COMMUNITY,
                nodeCommunity);
            if (Iterables.size(iter) > 1)
            {
                for (Node n : iter)
                {
                    nodeCommunityWeight += getNodeOutDegree(n);
                }
            }
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to get node community weight", e);
        }
    }

    return nodeCommunityWeight;
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:29,代码来源:Neo4jGraphDatabase.java


示例17: mapCommunities

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public Map<Integer, List<Integer>> mapCommunities(int numberOfCommunities)
{
    Map<Integer, List<Integer>> communities = new HashMap<Integer, List<Integer>>();

    try (final Transaction tx = beginUnforcedTransaction())
    {
        try
        {
            for (int i = 0; i < numberOfCommunities; i++)
            {
                ResourceIterable<Node> nodesIter = neo4jGraph.findNodesByLabelAndProperty(NODE_LABEL, COMMUNITY, i);
                List<Integer> nodes = new ArrayList<Integer>();
                for (Node n : nodesIter)
                {
                    String nodeIdString = (String) (n.getProperty(NODE_ID));
                    nodes.add(Integer.valueOf(nodeIdString));
                }
                communities.put(i, nodes);
            }
            tx.success();
        }
        catch (Exception e)
        {
            tx.failure();
            throw new BenchmarkingException("unable to map communities", e);
        }
    }

    return communities;
}
 
开发者ID:socialsensor,项目名称:graphdb-benchmarks,代码行数:32,代码来源:Neo4jGraphDatabase.java


示例18: run

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public void run() {
  logger.info("Starting edge labeling...");
  Map<String, String> map = new HashMap<String, String>();
  int processedRels = 0;

  Transaction tx = graphDb.beginTx();
  ResourceIterable<Relationship> rels = graphDb.getAllRelationships();

  for (Relationship rel : rels) {

    if (processedRels % batchCommitSize == 0) {
      tx.success();
      tx.close();
      tx = graphDb.beginTx();
    }

    String relName = rel.getType().name();
    if (map.containsKey(relName)) {
      rel.setProperty(edgeProperty, map.get(relName));
    } else {
      String relLabel = relName;
      String query = "START n = node:node_auto_index(iri='" + relName + "') match (n) return n";
      Result result = graphDb.execute(query);
      if (result.hasNext()) {
        Node n = (Node) result.next().get("n");
        if (n.hasProperty(NodeProperties.LABEL)) {
          relLabel =
              GraphUtil.getProperties(n, NodeProperties.LABEL, String.class).iterator().next();
        }
      }
      rel.setProperty(edgeProperty, relLabel);
      map.put(relName, relLabel);
    }

    processedRels++;
  }

  logger.info(processedRels + " relations labeled.");
  tx.success();
  tx.close();
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:43,代码来源:EdgeLabeler.java


示例19: run

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
@Override
public void run() {
  logger.info("Starting clique merge");

  Transaction tx = graphDb.beginTx();
  ResourceIterable<Node> allNodes = graphDb.getAllNodes();
  int size = Iterators.size(allNodes.iterator());
  tx.success();
  tx.close();

  logger.info(size + " nodes left to process");

  tx = graphDb.beginTx();
  TraversalDescription traversalDescription =
      graphDb.traversalDescription().breadthFirst().uniqueness(Uniqueness.NODE_GLOBAL);
  for (RelationshipType rel : relationships) {
    traversalDescription = traversalDescription.relationships(rel, Direction.BOTH);
  }

  Set<Long> processedNodes = new HashSet<Long>();

  for (Node baseNode : allNodes) {

    size -= 1;

    if (size % 100000 == 0) {
      logger.info(size + " nodes left to process");
    }

    if (size % batchCommitSize == 0) {
      logger.fine("Node batch commit");
      tx.success();
      tx.close();
      tx = graphDb.beginTx();
    }

    logger.fine("Processing Node - " + baseNode.getProperty(NodeProperties.IRI));

    if (!processedNodes.contains(baseNode.getId())) {
      // Keep a list of equivalentNodes
      List<Node> clique = new ArrayList<Node>();
      for (Node node : traversalDescription.traverse(baseNode).nodes()) {
        logger.fine("-- " + node.getProperty(NodeProperties.IRI));
        clique.add(node);
        processedNodes.add(node.getId());
      }

      logger.fine("clique size: " + clique.size());
      if (clique.size() == 1) {
        Node defactoLeader = clique.get(0);
        markAsCliqueLeader(defactoLeader);
      } else {
        Node leader = electCliqueLeader(clique, prefixLeaderPriority);
        markAsCliqueLeader(leader);
        clique.remove(leader); // keep only the peasants
        moveEdgesToLeader(leader, clique, tx);
        ensureLabel(leader, clique);
      }

    }

  }

  tx.success();
  tx.close();
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:67,代码来源:Clique.java


示例20: allNodes

import org.neo4j.graphdb.ResourceIterable; //导入依赖的package包/类
/**
 * Iterates over all nodes in taxonomic hierarchy, but unsorted withing each branch.
 */
public static ResourceIterable<Node> allNodes(GraphDatabaseService db, @Nullable Node root, @Nullable Rank lowestRank, boolean inclProParte) {
  return MultiRootNodeIterator.create(findRoot(db, root), filterRank(inclProParte ? Traversals.SORTED_TREE : Traversals.SORTED_TREE_WITHOUT_PRO_PARTE, lowestRank));
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:7,代码来源:TreeIterablesSorted.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java MemoryUtil类代码示例发布时间:2022-05-23
下一篇:
Java ResourceProcessException类代码示例发布时间: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