[VIVO-1399] Improve performance of Graph URI lookups
This commit is contained in:
parent
e729fc9f38
commit
107c2bff03
4 changed files with 29 additions and 13 deletions
|
@ -60,7 +60,10 @@ public abstract class RDFServiceJena extends RDFServiceImpl implements RDFServic
|
|||
private final static Log log = LogFactory.getLog(RDFServiceJena.class);
|
||||
|
||||
protected abstract DatasetWrapper getDatasetWrapper();
|
||||
|
||||
|
||||
protected volatile boolean rebuildGraphURICache = true;
|
||||
private final List<String> graphURIs = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public abstract boolean changeSetUpdate(ChangeSet changeSet) throws RDFServiceException;
|
||||
|
||||
|
@ -527,18 +530,28 @@ public abstract class RDFServiceJena extends RDFServiceImpl implements RDFServic
|
|||
|
||||
@Override
|
||||
public List<String> getGraphURIs() throws RDFServiceException {
|
||||
DatasetWrapper dw = getDatasetWrapper();
|
||||
try {
|
||||
Dataset d = dw.getDataset();
|
||||
List<String> graphURIs = new ArrayList<String>();
|
||||
Iterator<String> nameIt = d.listNames();
|
||||
while (nameIt.hasNext()) {
|
||||
graphURIs.add(nameIt.next());
|
||||
if (rebuildGraphURICache) {
|
||||
synchronized (RDFServiceJena.class) {
|
||||
if (rebuildGraphURICache) {
|
||||
rebuildGraphURICache = false;
|
||||
graphURIs.clear();
|
||||
|
||||
DatasetWrapper dw = getDatasetWrapper();
|
||||
try {
|
||||
Dataset d = dw.getDataset();
|
||||
Iterator<String> nameIt = d.listNames();
|
||||
while (nameIt.hasNext()) {
|
||||
graphURIs.add(nameIt.next());
|
||||
}
|
||||
return graphURIs;
|
||||
} finally {
|
||||
dw.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
return graphURIs;
|
||||
} finally {
|
||||
dw.close();
|
||||
}
|
||||
|
||||
return graphURIs;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -110,6 +110,7 @@ public class RDFServiceSDB extends RDFServiceJena implements RDFService {
|
|||
abortTransaction(sdbConn);
|
||||
throw new RDFServiceException(e);
|
||||
} finally {
|
||||
rebuildGraphURICache = true;
|
||||
close(sdbConn);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,6 +88,8 @@ public class RDFServiceTDB extends RDFServiceJena {
|
|||
} catch (Exception e) {
|
||||
log.error(e, e);
|
||||
throw new RDFServiceException(e);
|
||||
} finally {
|
||||
rebuildGraphURICache = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -514,7 +514,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService {
|
|||
}
|
||||
}
|
||||
|
||||
public void addModel(Model model, String graphURI) throws RDFServiceException {
|
||||
private void addModel(Model model, String graphURI) throws RDFServiceException {
|
||||
try {
|
||||
long start = System.currentTimeMillis();
|
||||
verbModel(model, graphURI, "INSERT");
|
||||
|
@ -524,7 +524,7 @@ public class RDFServiceSparql extends RDFServiceImpl implements RDFService {
|
|||
}
|
||||
}
|
||||
|
||||
public void deleteModel(Model model, String graphURI) throws RDFServiceException {
|
||||
private void deleteModel(Model model, String graphURI) throws RDFServiceException {
|
||||
try {
|
||||
verbModel(model, graphURI, "DELETE");
|
||||
} finally {
|
||||
|
|
Loading…
Add table
Reference in a new issue