use of com.google.common.util.concurrent.AtomicDouble in project aic-praise by aic-sri-international.
the class AbstractUAI_to_HOGMv1_Translator method calculateCompressedEntries.
private static double calculateCompressedEntries(Expression compressedTableExpression) {
AtomicDouble count = new AtomicDouble(0);
visitCompressedTableEntries(compressedTableExpression, count);
return count.doubleValue();
}
use of com.google.common.util.concurrent.AtomicDouble in project aic-praise by aic-sri-international.
the class UAIMARSolver method calculateCompressedEntries.
private static double calculateCompressedEntries(Expression compressedTableExpression) {
AtomicDouble count = new AtomicDouble(0);
visitCompressedTableEntries(compressedTableExpression, count);
return count.doubleValue();
}
use of com.google.common.util.concurrent.AtomicDouble in project cdap by caskdata.
the class LogSamplers method exponentialLimit.
/**
* Returns a {@link LogSampler} that accepts once on every N calls, with N exponentially increased from
* an initial value to a max value.
*/
public static LogSampler exponentialLimit(final int initialCount, final int maxCount, final double multiplier) {
Preconditions.checkArgument(initialCount > 0, "Initial count must be >= 0");
Preconditions.checkArgument(maxCount > 0, "Max count must be >= 0");
Preconditions.checkArgument(multiplier >= 1.0d, "Multiplier must be >= 1.0");
final AtomicDouble modular = new AtomicDouble(initialCount);
return new CountBasedLogSampler() {
@Override
protected boolean accept(String message, int logLevel, long callCount) {
double mod = modular.get();
if (((callCount - 1) % Math.ceil(mod)) == 0) {
modular.compareAndSet(mod, Math.min(mod * multiplier, maxCount));
return true;
}
return false;
}
};
}
Aggregations