If it's not a very large data set (or you have enough RAM) you could keep stuff like that in a HashMap really, that's how I do it sometimes... that way you can get rid of that extra lookup and it'll be faster. So you insert relationship as usual and in addition store that "relationship" (i.e. start node id, end node id) in f.ex. a HashMap for later lookup.
2010/4/1 Amir Hossein Jadidinejad <amir.jad...@yahoo.com> > Ok. Thank you very much. > I just want to load a huge graph but during insertion I have to lookup for > previous relations (In order to prevent of duplicate relations). Using > BatchInserter isn't applicable?, Better idea? > > --- On Thu, 4/1/10, Mattias Persson <matt...@neotechnology.com> wrote: > > From: Mattias Persson <matt...@neotechnology.com> > Subject: Re: [Neo] Node not found using BatchInserter > To: "Neo user discussions" <user@lists.neo4j.org> > Date: Thursday, April 1, 2010, 2:32 AM > > rel_itr.next() returns relationship ids, not node ids... that's why you get > those NotFoundExceptions. What you'd need to do is to > inserter.getRelationshipById( <rel-id> ) on those ids and get either start > or end node from it. > > But, is it really right to use the batch inserter in your case? > BatchInserter is only meant to be used if you're doing a one-time initial > loading of a big dataset, but never in production or when you have a > database containing data. Use the EmbeddedGraphDatabase for normal use. > > 2010/3/31 Amir Hossein Jadidinejad <amir.jad...@yahoo.com> > > > Hi, > > Check the following code: > > for (Iterator<Long> rel_itr = > > inserter.getRelationshipIds(current_node).iterator(); rel_itr.hasNext();) > { > > long neighbor = rel_itr.next(); > > if (neighbor != current_node && neighbor != -1) { > > try { > > > > > exist_neighbors.add(inserter.getNodeProperties(neighbor).get("cui").toString()); > > } catch (Exception e) { > > e.printStackTrace(); > > } > > } > > } > > > > After running, I have a lot of this error: > > org.neo4j.graphdb.NotFoundException: id=3225225 > > at > > > org.neo4j.kernel.impl.batchinsert.BatchInserterImpl.getNodeRecord(BatchInserterImpl.java:517) > > at > > > org.neo4j.kernel.impl.batchinsert.BatchInserterImpl.getNodeProperties(BatchInserterImpl.java:238) > > at org.qiau.wnng.build.BuildGraph.addAllNodes(BuildGraph.java:220) > > at org.qiau.wnng.build.BuildGraph.main(BuildGraph.java:288) > > > > Is it possible that a neighbor node not found while "getRelationshipIds" > > method return it?! > > > > > > > > > > _______________________________________________ > > Neo mailing list > > User@lists.neo4j.org > > https://lists.neo4j.org/mailman/listinfo/user > > > > > > -- > Mattias Persson, [matt...@neotechnology.com] > Hacker, Neo Technology > www.neotechnology.com > _______________________________________________ > Neo mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > > > > > _______________________________________________ > Neo mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com _______________________________________________ Neo mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user