catch rwi ranking div by zero exception

during rwi search result processing worddistance calculation is effected 
by concurrent update (normalization) of min/max ranking parameter for
wordpositions. On update of min/max the exception is raised in distance calc
and now catched. 
This concurrent update and change of ranking results is needed for speed
but should be further checked for optimization
pull/88/head
reger 8 years ago
parent 47af33a04c
commit 4c67ed3f8d

@ -28,6 +28,7 @@ package net.yacy.kelondro.rwi;
import java.util.Collection;
import java.util.Iterator;
import net.yacy.cora.util.ConcurrentLog;
public abstract class AbstractReference implements Reference {
@ -128,7 +129,15 @@ public abstract class AbstractReference implements Reference {
}
// despite first line checks for size < 2 Arithmetic exception div by zero occured (1.91/9278 2016-10-19)
// added d == 0 condition as protection for this (which was in all above tests the case)
return d == 0 ? 0 : d / (positions().size() - 1);
try {
return d == 0 ? 0 : d / (positions().size() - 1);
} catch (ArithmeticException ex) {
// TODO: in peer to peer normalization of rwi queue modifies concurrently positions resulting in div by 0 exception
// with effect of above check position() < 2 is false but now true, it also results in changing ranking results until normalization is finished
// see related/causing code ReferenceOrder.normalizewith() and WordReferenceVars.max()/WordReferenceVars.min() -> refacturing of posintext, distance, min, max needed
ConcurrentLog.fine("AbstractReference", "word distance calculation:" + ex.getMessage());
return 0;
}
}
@Override

Loading…
Cancel
Save