use of com.yahoo.sketches.ResizeFactor in project sketches-core by DataSketches.
the class HeapQuickSelectSketch method reset.
@Override
public final void reset() {
final ResizeFactor rf = getResizeFactor();
final int lgArrLongsSM = Util.startingSubMultiple(lgNomLongs_ + 1, rf, MIN_LG_ARR_LONGS);
if (lgArrLongsSM == lgArrLongs_) {
final int arrLongs = cache_.length;
assert (1 << lgArrLongs_) == arrLongs;
java.util.Arrays.fill(cache_, 0L);
} else {
cache_ = new long[1 << lgArrLongsSM];
lgArrLongs_ = lgArrLongsSM;
}
hashTableThreshold_ = setHashTableThreshold(lgNomLongs_, lgArrLongs_);
empty_ = true;
curCount_ = 0;
thetaLong_ = (long) (getP() * MAX_THETA_LONG_AS_DOUBLE);
}
use of com.yahoo.sketches.ResizeFactor in project sketches-core by DataSketches.
the class HeapQuickSelectSketch method resizeCache.
//Must resize. Changes lgArrLongs_ and cache_. theta and count don't change.
// Used by hashUpdate()
private final void resizeCache() {
final ResizeFactor rf = getResizeFactor();
final int lgTgtLongs = lgNomLongs_ + 1;
final int lgDeltaLongs = lgTgtLongs - lgArrLongs_;
//rf_.lg() could be 0
final int lgResizeFactor = max(min(rf.lg(), lgDeltaLongs), 1);
// new tgt size
lgArrLongs_ += lgResizeFactor;
final long[] tgtArr = new long[1 << lgArrLongs_];
final int newCount = HashOperations.hashArrayInsert(cache_, tgtArr, lgArrLongs_, thetaLong_);
//Assumes no dirty values.
assert newCount == curCount_;
curCount_ = newCount;
cache_ = tgtArr;
hashTableThreshold_ = setHashTableThreshold(lgNomLongs_, lgArrLongs_);
}
Aggregations