Improved performance of lucene index build under SDB. NIHVIVO-1795
This commit is contained in:
parent
b321fc38c9
commit
54e6abd53b
5 changed files with 123 additions and 29 deletions
|
@ -115,6 +115,7 @@ public interface Individual extends ResourceBean, VitroTimeWindowedResource, Com
|
|||
|
||||
String getImageUrl();
|
||||
String getThumbUrl();
|
||||
boolean hasThumb();
|
||||
|
||||
String getUrl();
|
||||
void setUrl(String url);
|
||||
|
|
|
@ -501,4 +501,8 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
|
|||
return getURI() + " " + getName();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasThumb() {
|
||||
return getThumbUrl() != null && ! getThumbUrl().isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -646,4 +646,10 @@ public class IndividualFiltering implements Individual {
|
|||
// Since the statements have been filtered, we can just take the first individual without filtering.
|
||||
return stmts.isEmpty() ? null : stmts.get(0).getObject();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean hasThumb() {
|
||||
return _innerIndividual.hasThumb();
|
||||
}
|
||||
}
|
|
@ -71,6 +71,7 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
|||
SDBDatasetMode.ASSERTIONS_AND_INFERENCES;
|
||||
private String individualURI = null;
|
||||
private Model model = null;
|
||||
private Boolean _hasThumb = null;
|
||||
|
||||
public IndividualSDB(String individualURI,
|
||||
DatasetWrapperFactory datasetWrapperFactory,
|
||||
|
@ -431,39 +432,92 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
|||
}
|
||||
|
||||
|
||||
public Date getSunrise() {
|
||||
if (sunrise != null) {
|
||||
return sunrise;
|
||||
} else {
|
||||
constructProperty(ind, VitroVocabulary.SUNRISE);
|
||||
ind.getOntModel().enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
sunrise = webappDaoFactory.getJenaBaseDao()
|
||||
.getPropertyDateTimeValue(
|
||||
ind,webappDaoFactory.getJenaBaseDao().SUNRISE);
|
||||
return sunrise;
|
||||
} finally {
|
||||
ind.getOntModel().leaveCriticalSection();
|
||||
public Date getSunrise() {
|
||||
if( this.sunrise == null ){
|
||||
String[] graphVars = { "?g" };
|
||||
String getPropertyValue =
|
||||
"SELECT ?value" +
|
||||
"WHERE { GRAPH ?g { <" + individualURI + "> " +
|
||||
"<" + webappDaoFactory.getJenaBaseDao().SUNRISE + "> " +
|
||||
"?value} \n" +
|
||||
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
||||
"}";
|
||||
DatasetWrapper w = getDatasetWrapper();
|
||||
Dataset dataset = w.getDataset();
|
||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||
try{
|
||||
sunrise =(Date)
|
||||
((Literal)QueryExecutionFactory.create(QueryFactory.create(getPropertyValue), dataset)
|
||||
.execSelect()).getValue();
|
||||
}catch(Exception ex){
|
||||
log.error("could not get sunrise: " + ex.getMessage(),ex);
|
||||
}finally{
|
||||
dataset.getLock().leaveCriticalSection();
|
||||
w.close();
|
||||
}
|
||||
}
|
||||
|
||||
return sunrise;
|
||||
|
||||
// if (sunrise != null) {
|
||||
// return sunrise;
|
||||
// } else {
|
||||
// constructProperty(ind, VitroVocabulary.SUNRISE);
|
||||
// ind.getOntModel().enterCriticalSection(Lock.READ);
|
||||
// try {
|
||||
// sunrise = webappDaoFactory.getJenaBaseDao()
|
||||
// .getPropertyDateTimeValue(
|
||||
// ind,webappDaoFactory.getJenaBaseDao().SUNRISE);
|
||||
// return sunrise;
|
||||
// } finally {
|
||||
// ind.getOntModel().leaveCriticalSection();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public Date getSunset() {
|
||||
if (sunset != null) {
|
||||
return sunset;
|
||||
} else {
|
||||
constructProperty(ind, VitroVocabulary.SUNSET);
|
||||
ind.getOntModel().enterCriticalSection(Lock.READ);
|
||||
try {
|
||||
sunset = webappDaoFactory.getJenaBaseDao()
|
||||
.getPropertyDateTimeValue(
|
||||
ind,webappDaoFactory.getJenaBaseDao().SUNSET);
|
||||
return sunset;
|
||||
} finally {
|
||||
|
||||
ind.getOntModel().leaveCriticalSection();
|
||||
public Date getSunset() {
|
||||
|
||||
if( this.sunset == null ){
|
||||
String[] graphVars = { "?g" };
|
||||
String getPropertyValue =
|
||||
"SELECT ?value" +
|
||||
"WHERE { GRAPH ?g { <" + individualURI + "> " +
|
||||
"<"+webappDaoFactory.getJenaBaseDao().SUNSET+"> " +
|
||||
"?value} \n" +
|
||||
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
||||
"}";
|
||||
DatasetWrapper w = getDatasetWrapper();
|
||||
Dataset dataset = w.getDataset();
|
||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||
try{
|
||||
sunset =(Date)
|
||||
((Literal)QueryExecutionFactory.create(QueryFactory.create(getPropertyValue), dataset)
|
||||
.execSelect()).getValue();
|
||||
}catch(Exception ex){
|
||||
log.error("could not get sunset: " + ex.getMessage(),ex);
|
||||
}finally{
|
||||
dataset.getLock().leaveCriticalSection();
|
||||
w.close();
|
||||
}
|
||||
}
|
||||
|
||||
return sunset;
|
||||
|
||||
// if (sunset != null) {
|
||||
// return sunset;
|
||||
// } else {
|
||||
// constructProperty(ind, VitroVocabulary.SUNSET);
|
||||
// ind.getOntModel().enterCriticalSection(Lock.READ);
|
||||
// try {
|
||||
// sunset = webappDaoFactory.getJenaBaseDao()
|
||||
// .getPropertyDateTimeValue(
|
||||
// ind,webappDaoFactory.getJenaBaseDao().SUNSET);
|
||||
// return sunset;
|
||||
// } finally {
|
||||
//
|
||||
// ind.getOntModel().leaveCriticalSection();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public Date getTimekey() {
|
||||
|
@ -691,6 +745,35 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
|||
return this.imageInfo.getThumbnail().getBytestreamAliasUrl();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasThumb(){
|
||||
if( _hasThumb != null ){
|
||||
return _hasThumb;
|
||||
}else{
|
||||
String[] graphVars = { "?g" };
|
||||
String ask =
|
||||
"ASK { GRAPH ?g " +
|
||||
" { <" + individualURI + "> <http://vitro.mannlib.cornell.edu/ns/vitro/public#mainImage> ?mainImage . \n" +
|
||||
" ?mainImage <http://vitro.mannlib.cornell.edu/ns/vitro/public#thumbnailImage> ?thumbImage . }\n" +
|
||||
WebappDaoFactorySDB.getFilterBlock(graphVars, datasetMode) +
|
||||
"}";
|
||||
DatasetWrapper w = getDatasetWrapper();
|
||||
Dataset dataset = w.getDataset();
|
||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
||||
try{
|
||||
_hasThumb = QueryExecutionFactory.create(QueryFactory.create(ask), dataset).execAsk();
|
||||
}catch(Exception ex){
|
||||
_hasThumb = false;
|
||||
log.error(ex,ex);
|
||||
}finally{
|
||||
dataset.getLock().leaveCriticalSection();
|
||||
w.close();
|
||||
}
|
||||
return _hasThumb;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getAnchor() {
|
||||
if (this.anchor != null) {
|
||||
return anchor;
|
||||
|
|
|
@ -221,7 +221,7 @@ public class Entity2LuceneDoc implements Obj2DocIface{
|
|||
|
||||
try{
|
||||
value = null;
|
||||
if( ent.getThumbUrl() != null )
|
||||
if( ent.hasThumb() )
|
||||
doc.add(new Field(term.THUMBNAIL, "1", Field.Store.YES, Field.Index.NOT_ANALYZED));
|
||||
else
|
||||
doc.add(new Field(term.THUMBNAIL, "0", Field.Store.YES, Field.Index.NOT_ANALYZED));
|
||||
|
@ -238,7 +238,7 @@ public class Entity2LuceneDoc implements Obj2DocIface{
|
|||
doPortalFlags(ent, doc);
|
||||
|
||||
//do flag 2 legacy, only used at Cornell
|
||||
doFlag2( ent, doc );
|
||||
//doFlag2( ent, doc );
|
||||
|
||||
//ALLTEXT, all of the 'full text'
|
||||
String t=null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue