/**
* Copyright (C) 2009-2013 FoundationDB, LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.foundationdb.server.store.statistics.histograms;
import java.util.Arrays;
import java.util.List;
final class BucketTestUtils {
public static <T> Bucket<T> bucket(T value, long equals, long lessThans, long lessThanDistincts) {
Bucket<T> result = new Bucket<>();
result.init(value, 1);
for (int i = 1; i < equals; ++i) { // starting count from 1 since a new Bucket has equals of 1
result.addEquals();
}
result.addLessThans(lessThans);
result.addLessThanDistincts(lessThanDistincts);
return result;
}
public static class SingletonSplitter<T> implements Splitter<T> {
@Override
public int segments() {
return 1;
}
@Override
public List<? extends T> split(T input) {
oneElementList.set(0, input);
return oneElementList;
}
@SuppressWarnings("unchecked")
private List<T> oneElementList = Arrays.asList((T[])new Object[1]);
}
}