Don't let us create a percentiler with an insane range, and carp if
we expand to one. I'm half tempted to also try and cap the range to something less broken, but the bug I had that caused insanity involved recording a value of infinity, and there's not a hell of a lot I can do to sanely recover in that case (other than throw it away, I suppose). So let's yell a little bit and keep from hosing us quite as much as I was when I wound up with crazy stuff persisted to my ratings table. git-svn-id: svn+ssh://src.earth.threerings.net/vilya/trunk@761 c613c5cb-e716-0410-b11b-feb51c14d237
This commit is contained in:
@@ -79,6 +79,14 @@ public class Percentiler
|
|||||||
_min = in.asIntBuffer().get();
|
_min = in.asIntBuffer().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Un-break percentilers that have been stored with bogus data
|
||||||
|
if (_max < _min) {
|
||||||
|
log.warning("Percentiler initialized with bogus range. Coping.",
|
||||||
|
"min", _min, "max", _max);
|
||||||
|
|
||||||
|
_max = _min + 1;
|
||||||
|
}
|
||||||
|
|
||||||
// compute our percentiles
|
// compute our percentiles
|
||||||
recomputePercentiles();
|
recomputePercentiles();
|
||||||
}
|
}
|
||||||
@@ -107,17 +115,27 @@ public class Percentiler
|
|||||||
// if this value is outside our bounds, we need to redistribute our buckets
|
// if this value is outside our bounds, we need to redistribute our buckets
|
||||||
if (value < _min || value > _max) {
|
if (value < _min || value > _max) {
|
||||||
if (_fixedRange) {
|
if (_fixedRange) {
|
||||||
log.warning("Recording value outside of initially fixed range", "min", _min,
|
log.warning("Recording value outside of initially fixed range",
|
||||||
"max", _max, "value", value);
|
"min", _min, "max", _max, "value", value);
|
||||||
_fixedRange = false;
|
_fixedRange = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// expand by 20% in the direction of either our new minimum or new maximum
|
// expand by 20% in the direction of either our new minimum or new maximum
|
||||||
int newmin = (value < _min) ? (_max - (int)Math.ceil((_max - value) * 1.2f)) : _min;
|
int newmin = (value < _min) ? (_max - (int)Math.ceil((_max - value) * 1.2f)) : _min;
|
||||||
int newmax = (value > _max) ? (_min + (int)Math.ceil((value - _min) * 1.2f)) : _max;
|
int newmax = (value > _max) ? (_min + (int)Math.ceil((value - _min) * 1.2f)) : _max;
|
||||||
|
|
||||||
|
if (newmin > _min || newmax < _max) {
|
||||||
|
log.warning("Grew our range in crazy ways?!",
|
||||||
|
"value", value, "total", _total,
|
||||||
|
"new", ("" + newmin + ":" + newmax),
|
||||||
|
"old", ("" + _min + ":" + _max));
|
||||||
|
}
|
||||||
|
|
||||||
if (logNewMax) {
|
if (logNewMax) {
|
||||||
log.info("Resizing [total=" + _total + ", new=" + newmin + ":" + newmax +
|
log.info("Resizing",
|
||||||
", old=" + _min + ":" + _max + "].");
|
"value", value, "total", _total,
|
||||||
|
"new", ("" + newmin + ":" + newmax),
|
||||||
|
"old", ("" + _min + ":" + _max));
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a new counts array and map the old array to the new
|
// create a new counts array and map the old array to the new
|
||||||
|
|||||||
Reference in New Issue
Block a user