Hi, I am trying to run sparql queries (including LOAD) on Jena with TDB. Other then source code, there is very little additional documentation how this should to be done. So, I based my code on the recent benchmark code referred by Andy few months ago [1]. However, I found that only initial loads run correctly. Other subsequent loads fire java.util.ConcurrentModificationException exception (undeterministically, depending on platform, time instant, ...). In the rest of the message, I include my illustrative test program.
What should be fixed in the given code to enable LOAD sparql queries to work on TDB? Thanks, Milorad [1] https://jena.svn.sourceforge.net/svnroot/jena/TDB/trunk/src-dev/reports/ReportOutOfMemoryManyGraphsTDB.java import java.io.File; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.reasoner.ReasonerRegistry; import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.tdb.TDB; import com.hp.hpl.jena.tdb.TDBFactory; import com.hp.hpl.jena.tdb.base.block.FileMode; import com.hp.hpl.jena.tdb.sys.SystemTDB; import com.hp.hpl.jena.update.UpdateAction; import com.hp.hpl.jena.update.UpdateFactory; import com.hp.hpl.jena.update.UpdateRequest; public class rdfStoreTesting { /** * @param args */ public static void main(String[] args) { File m_baseDir; Model m_triplestore; String baseDirPath = "C:\\Temp"; m_baseDir = new File(baseDirPath+File.separator+"tdb"); boolean succ = m_baseDir.exists() && m_baseDir.isDirectory(); if(!succ) succ = m_baseDir.mkdir(); if(!succ){ m_baseDir = null; m_triplestore = null; System.err.print("Error opening/creating new folder: "+baseDirPath); }else{ SystemTDB.setFileMode(FileMode.direct) ; m_triplestore = TDBFactory.createModel(m_baseDir.getPath()); } String querystr = "LOAD <http://geni-orca.renci.org/owl/nlr.rdf>"; System.out.println("Running "+querystr); // SPARQL UPDATE is handled here m_triplestore.enterCriticalSection(Lock.WRITE); try { UpdateRequest updateRequest = UpdateFactory.create(querystr); System.out.println("UpdateRequest created"); UpdateAction.execute(updateRequest, m_triplestore); }catch (Exception e){ System.err.println(e); } finally { m_triplestore.commit(); m_triplestore.leaveCriticalSection(); TDB.sync(m_triplestore); } System.out.println("==== finished ===="); querystr = "LOAD <http://geni-orca.renci.org/owl/ben-6509.rdf>"; System.out.println("Running "+querystr); // SPARQL UPDATE is handled here m_triplestore.enterCriticalSection(Lock.WRITE); try { UpdateRequest updateRequest = UpdateFactory.create(querystr); System.out.println("UpdateRequest created"); UpdateAction.execute(updateRequest, m_triplestore); }catch (Exception e){ System.err.println(e); } finally { m_triplestore.commit(); m_triplestore.leaveCriticalSection(); TDB.sync(m_triplestore); } System.out.println("==== finished ===="); querystr = "LOAD <http://geni-orca.renci.org/owl/nlr.rdf>"; System.out.println("Running "+querystr); // SPARQL UPDATE is handled here m_triplestore.enterCriticalSection(Lock.WRITE); try { UpdateRequest updateRequest = UpdateFactory.create(querystr); System.out.println("UpdateRequest created"); UpdateAction.execute(updateRequest, m_triplestore); }catch (Exception e){ System.err.println(e); } finally { m_triplestore.commit(); m_triplestore.leaveCriticalSection(); TDB.sync(m_triplestore); } System.out.println("==== finished ===="); } }
