Multithreaded use of Sparksee

67 views
Skip to first unread message

Charnabon

unread,
Oct 30, 2014, 7:16:17 AM10/30/14
to spar...@googlegroups.com
Hello,
What are the patterns for using Sparksee in a mutithreaded application? I have multiple threads performing heavy computation on my data. Every threads, as the result of computation will update the graph by adding new Nodes and/or edges.
How can I make use of sparksee in this scenario. What I have tried always resulted with error 10 or 6 which you said is related to not closing the database.

What I do right now is:
APP INIT :

CREATE SINGLETON WRAPPER for SPARKSEE client
inside:
> create DB if not exists of open
> get one session and retrieve  existing types
> if types don't exist create them
> close session


PER THREAD
computation...
>get one session from singleton
>add/remove/query nodes edges
>close the session
carry on with computation

sessions once created become part of a threadpool and are being reused by the same thread which created it.

What am I doing wrong ?

c3po.ac

unread,
Oct 30, 2014, 7:59:20 AM10/30/14
to
Hi,

There's nothing wrong, but maybe you are missing a proper database closure:

APP FINALIZE :
DESTROY THE SINGLETON
inside:
> all the threads must close their sessions
> close the database


And for each thread, when you use the session, you may want to use the Begin and Commit/Rollback methods instead of calling each api in autcommit mode.  Maybe you are already doing it.

>get one session from singleton
..
> session.Begin
>add/remove/query nodes edges
> session.Commit or session.Rollback
...
> session.Begin
>add/remove/query nodes edges
> session.Commit or session.Rollback
..
>close the session


Anyway you probably want to enable the recovery when you setup the Sparksee configuration. That may affect the performance, but should protect your database integrity from failures like not properly closing it.

http://www.sparsity-technologies.com/UserManual/Configuration.html#recovery

Best regards.


El dijous 30 d’octubre de 2014 12:16:17 UTC+1, Charnabon va escriure:
Reply all
Reply to author
Forward
0 new messages