[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
|
@ -61,6 +61,9 @@ public abstract class RDFServiceJena extends RDFServiceImpl implements RDFServic
|
||||||
|
|
||||||
protected abstract DatasetWrapper getDatasetWrapper();
|
protected abstract DatasetWrapper getDatasetWrapper();
|
||||||
|
|
||||||
|
protected volatile boolean rebuildGraphURICache = true;
|
||||||
|
private final List<String> graphURIs = new ArrayList<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract boolean changeSetUpdate(ChangeSet changeSet) throws RDFServiceException;
|
public abstract boolean changeSetUpdate(ChangeSet changeSet) throws RDFServiceException;
|
||||||
|
|
||||||
|
@ -527,18 +530,28 @@ public abstract class RDFServiceJena extends RDFServiceImpl implements RDFServic
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> getGraphURIs() throws RDFServiceException {
|
public List<String> getGraphURIs() throws RDFServiceException {
|
||||||
DatasetWrapper dw = getDatasetWrapper();
|
if (rebuildGraphURICache) {
|
||||||
try {
|
synchronized (RDFServiceJena.class) {
|
||||||
Dataset d = dw.getDataset();
|
if (rebuildGraphURICache) {
|
||||||
List<String> graphURIs = new ArrayList<String>();
|
rebuildGraphURICache = false;
|
||||||
Iterator<String> nameIt = d.listNames();
|
graphURIs.clear();
|
||||||
while (nameIt.hasNext()) {
|
|
||||||
graphURIs.add(nameIt.next());
|
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
|
@Override
|
||||||
|
|
|
@ -110,6 +110,7 @@ public class RDFServiceSDB extends RDFServiceJena implements RDFService {
|
||||||
abortTransaction(sdbConn);
|
abortTransaction(sdbConn);
|
||||||
throw new RDFServiceException(e);
|
throw new RDFServiceException(e);
|
||||||
} finally {
|
} finally {
|
||||||
|
rebuildGraphURICache = true;
|
||||||
close(sdbConn);
|
close(sdbConn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,8 @@ public class RDFServiceTDB extends RDFServiceJena {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
throw new RDFServiceException(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 {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
verbModel(model, graphURI, "INSERT");
|
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 {
|
try {
|
||||||
verbModel(model, graphURI, "DELETE");
|
verbModel(model, graphURI, "DELETE");
|
||||||
} finally {
|
} finally {
|
||||||
|
|
Loading…
Add table
Reference in a new issue