Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding relationships to a Neo4j database in parallel
    primarykey
    data
    text
    <p>Im trying to add relationships to a Neo4j graph I created in parallel using Java's ExecutorService. I'm having two issues. First, is while all my runnables are sumbitted my program jumps forward and closes the Transaction. Second, if I keep the Transaction open (via an infinite before hand so it doesn't close so that problem isn't really solved), when the runnables are being executed they are not able to add the relationships and seem to be stuck on those lines of code. </p> <pre><code>private void createDB() { graphDB = new GraphDatabaseFactory().newEmbeddedDatabase(Neo4j_DBPath); registerShutdownHook( graphDB ); Transaction tx = graphDB.beginTx(); try { parser.read(File, graphDB); parser.similirize(); while (Global.running) { } tx.success(); System.out.println("donedone"); } finally { System.out.println("closing"); tx.finish(); } } </code></pre> <p>read parses through some files and creates my database. Similirize makes m x n comparisons and add these relationships to the graph. I was hoping to do this in parallel. This is what I have for similirize right now: </p> <pre><code>public void similirize() { System.out.println("starting ||"); final Node NoSim = graphDB.createNode(); NoSim.setProperty("type", "No Similarites"); int threads = Runtime.getRuntime().availableProcessors(); System.out.println(threads); final ExecutorService service = Executors.newFixedThreadPool(threads); for (final Reaction r: FailedRxns){ System.out.println("submitting runnable"); service.submit(new Runnable() { @Override public void run() { System.out.println("running runnable"); try { System.out.println("try"); Node SIM = Parser.this.mostSimilar(r); while (!Thread.interrupted()) { System.out.println("while"); if (SIM != null) { System.out.println("if"); r.getUnderlyingNode().createRelationshipTo(SIM, RelTypes.SIMILAR_TO); System.out.println("btwn the lines"); r.getUnderlyingNode().createRelationshipTo(SIM.getRelationships(Direction.OUTGOING).iterator().next().getOtherNode(SIM), RelTypes.INFERRED_IN); System.out.println("made connection!"); } else { System.out.println("else"); r.getUnderlyingNode().createRelationshipTo(NoSim, RelTypes.IN); System.out.println("Couldn't make connection :("); } } } finally { service.shutdown(); } } }); } } </code></pre> <p>my output looks something like: starting || submitting runnable submitting runnable....(goes on for a long time) running runnable try while if running runnable try while if running runnable try while if running runnable try while if</p> <p>and then it is stuck here forever. </p> <p>Thanks for all your help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload