Fixing divide by zero error in IndexBuilder NIHVIVO-1974

Fixing odd return of moniker that was causing cast exception.
Fixing ERROR message about temporary index build directory.
This commit is contained in:
bdc34 2011-02-01 20:30:10 +00:00
parent 4e18504ca0
commit e8667d3a8e
3 changed files with 35 additions and 27 deletions

View file

@ -333,12 +333,15 @@ public class IndexBuilder {
if( (count % 100 ) == 0 && count > 0 ){ if( (count % 100 ) == 0 && count > 0 ){
long dt = (System.currentTimeMillis() - starttime); long dt = (System.currentTimeMillis() - starttime);
log.debug("individuals indexed: " + count + " in " + dt + " msec " + log.debug("individuals indexed: " + count + " in " + dt + " msec " +
" time pre individual = " + (dt / count) + " msec"); " time pre individual = " + (dt / count) + " msec" );
} }
} }
} }
log.info("individuals indexed: " + count + " in " + (System.currentTimeMillis() - starttime) + " msec" +
" time per individual = " + (System.currentTimeMillis() - starttime)/ count + " msec") ; log.info(
"individuals indexed: " + count + " in " + (System.currentTimeMillis() - starttime) + " msec" +
(count!=0?(" time per individual = " + (System.currentTimeMillis() - starttime)/ count + " msec"):"")
);
} }
/** /**

View file

@ -119,7 +119,7 @@ public class Entity2LuceneDoc implements Obj2DocIface{
//log.debug("Skipping individual without rdfs:label " + ent.getURI()); //log.debug("Skipping individual without rdfs:label " + ent.getURI());
//return null; //return null;
log.debug("Using local name for individual with rdfs:label " + ent.getURI()); log.debug("Using local name for individual with rdfs:label " + ent.getURI());
return ent.getLocalName(); value = ent.getLocalName();
} }
Field name =new Field(term.NAME, value, Field name =new Field(term.NAME, value,
Field.Store.YES, Field.Index.ANALYZED); Field.Store.YES, Field.Index.ANALYZED);

View file

@ -203,28 +203,29 @@ public class LuceneIndexer implements IndexerIface {
if( urisIndexed.contains(ind.getURI()) ){ if( urisIndexed.contains(ind.getURI()) ){
log.debug("already indexed " + ind.getURI() ); log.debug("already indexed " + ind.getURI() );
return; return;
}else }else{
urisIndexed.add(ind.getURI()); urisIndexed.add(ind.getURI());
log.debug("indexing " + ind.getURI());
Iterator<Obj2DocIface> it = getObj2DocList().iterator(); Iterator<Obj2DocIface> it = getObj2DocList().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Obj2DocIface obj2doc = (Obj2DocIface) it.next(); Obj2DocIface obj2doc = (Obj2DocIface) it.next();
if (obj2doc.canTranslate(ind)) { if (obj2doc.canTranslate(ind)) {
Document d = (Document) obj2doc.translate(ind); Document d = (Document) obj2doc.translate(ind);
if( d != null){ if( d != null){
if( !newDoc ){ if( !newDoc ){
writer.updateDocument((Term)obj2doc.getIndexId(ind), d); writer.updateDocument((Term)obj2doc.getIndexId(ind), d);
log.debug("updated " + ind.getName() + " " + ind.getURI()); log.debug("updated " + ind.getName() + " " + ind.getURI());
}else{ }else{
writer.addDocument(d); writer.addDocument(d);
log.debug("added " + ind.getName() + " " + ind.getURI()); log.debug("added " + ind.getName() + " " + ind.getURI());
} }
}else{ }else{
log.debug("could not translate, removing from index " + ind.getURI()); log.debug("could not translate, removing from index " + ind.getURI());
writer.deleteDocuments((Term)obj2doc.getIndexId(ind)); writer.deleteDocuments((Term)obj2doc.getIndexId(ind));
}
} }
} }
} }
} catch (IOException ex) { } catch (IOException ex) {
throw new IndexingException(ex.getMessage()); throw new IndexingException(ex.getMessage());
} }
@ -238,7 +239,7 @@ public class LuceneIndexer implements IndexerIface {
if( writer == null ) if( writer == null )
throw new IndexingException("LuceneIndexer: cannot delete from " + throw new IndexingException("LuceneIndexer: cannot delete from " +
"index, IndexWriter is null."); "index, IndexWriter is null.");
try { try {
Iterator<Obj2DocIface> it = getObj2DocList().iterator(); Iterator<Obj2DocIface> it = getObj2DocList().iterator();
while (it.hasNext()) { while (it.hasNext()) {
Obj2DocIface obj2doc = (Obj2DocIface) it.next(); Obj2DocIface obj2doc = (Obj2DocIface) it.next();
@ -280,10 +281,14 @@ public class LuceneIndexer implements IndexerIface {
File offLineDir = new File(currentOffLineDir); File offLineDir = new File(currentOffLineDir);
File liveDir = new File(liveIndexDir); File liveDir = new File(liveIndexDir);
boolean success = offLineDir.renameTo( liveDir ); boolean success = offLineDir.renameTo( liveDir );
if( ! success ) if( ! success ){
log.error("could not move off line index at " log.error("could not move off line index at "
+ offLineDir.getAbsolutePath() + " to live index directory " + offLineDir.getAbsolutePath() + " to live index directory "
+ liveDir.getAbsolutePath()); + liveDir.getAbsolutePath());
}else{
deleteDir(new File(currentOffLineDir));
currentOffLineDir = null;
}
} }
private synchronized String getOffLineBuildDir(){ private synchronized String getOffLineBuildDir(){
@ -334,7 +339,7 @@ public class LuceneIndexer implements IndexerIface {
"be null but it isn't"); "be null but it isn't");
if( this.currentOffLineDir != null) if( this.currentOffLineDir != null)
log.error("it is expected that the current" + log.error("it is expected that the current" +
"OffLineDir would be null but it is " + currentOffLineDir); "OffLineDir would be null but it is " + currentOffLineDir);
if( indexing ) if( indexing )
log.error("indexing should not be set to true just yet"); log.error("indexing should not be set to true just yet");
} }