public void cleanup() { try { dataset.close(); } catch (Exception e) { logger.info("Dataset {} is already closed. Nothing to do here", TDB_DIRECTORY); } if (!isHPCEnabled) { try { getReentrantLock().lock(); TDBFactory.release(dataset); //TODO: Clean up temp files if done // File f = new File(TDB_DIRECTORY); // FileUtils.deleteDirectory(f); // } catch (IOException e) { // e.printStackTrace(); } finally { getReentrantLock().unlock(); } } dataset = null; System.gc(); }
@Override public synchronized void commit() { if (super.isHPCEnabled) { // nothing to do here } else { if (this.totalTriples > 0) { logger.info("Commiting in-mem Model Resource to Datagraph. Metric: "+super.metricURI+". Number of triples added: "+this.totalTriples+" dataset location: "+super.location); this.totalTriples = 0; dataset.begin(ReadWrite.WRITE) ; try { super.getReentrantLock().lock(); dataset.addNamedModel(getNamedGraph(), this._m); } finally { dataset.commit(); dataset.end(); super.getReentrantLock().unlock(); } this._m.removeAll(); this._m = null; System.gc(); this._m = ModelFactory.createDefaultModel(); } } } }
@Override public synchronized void commit() { if (super.isHPCEnabled) { // nothing to do here } else { if (this.totalTriples > 0) { logger.info("Commiting in-mem Model to Datagraph. Metric: "+super.metricURI+". Number of triples added: "+this.totalTriples+" dataset location: "+super.location); this.totalTriples = 0; dataset.begin(ReadWrite.WRITE) ; try { super.getReentrantLock().lock(); dataset.addNamedModel(getNamedGraph(), this._m); } finally { dataset.commit(); dataset.end(); super.getReentrantLock().unlock(); } this._m.removeAll(); this._m = null; System.gc(); this._m = ModelFactory.createDefaultModel(); } } } }
/** * Create instance triples corresponding towards a Quality Report * * @param computedOn - The resource URI of the dataset computed on * @param problemCollection - A list of quality problem collections * */ public void addToQualityProblemReport(ProblemCollection<?> problemCollection){ Resource problemURI = problemCollection.getProblemURI(); this.m.add(new StatementImpl(this.reportURI, QPRO.hasProblem, problemURI)); Dataset d = problemCollection.getDataset(); try { d.begin(ReadWrite.READ); problemCollection.getReentrantLock().lock(); Model _m = d.getNamedModel(problemCollection.getNamedGraph()); RDFDataMgr.write(this.serialisationOutput, _m, RDFFormat.TURTLE_PRETTY); } finally { problemCollection.getReentrantLock().unlock(); d.end(); d.close(); } problemCollection.cleanup(); }