public class ApproximateCountsUtils {
public static ApproximateCountsFilter createFilterFromDataInterface(DataInterface<Long> dataInterface, double fpp) {
int numOfValuesForBins = 10000;
BinComputer bc = new BinComputer(numOfValuesForBins);
CloseableIterator<KeyValue<Long>> it = dataInterface.iterator();
while (it.hasNext() && bc.getAllValues().size() < numOfValuesForBins) {
KeyValue<Long> next = it.next();
if (next.getValue() > 1) {
bc.addCount(next.getValue());
}
}
it.close();
double[] binBorders = bc.getEquiDenseBins(256 - 2);
List<Long>[] binnedValues = new List[binBorders.length + 1];
for (int i = 0; i < binnedValues.length; i++) {
binnedValues[i] = new ArrayList<>();
}
for (double value : bc.getAllValues()) {
int bin = NumUtils.getBin(binBorders, value);
binnedValues[bin].add(Math.round(value));
}
long[] averageValues = new long[binnedValues.length];
for (int i = 0; i < binnedValues.length; i++) {