Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable Open range for object size in uniform and histogram #165

Merged
merged 2 commits into from
Mar 5, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.commons.lang.math.RandomUtils;

import com.intel.cosbench.config.ConfigException;
import com.intel.cosbench.driver.generator.RangeIntGenerator.TestThread;

/**
*
Expand Down Expand Up @@ -101,13 +102,22 @@ private static HistogramIntGenerator tryParse(String pattern) {
String[] args = StringUtils.split(pattern, ',');
ArrayList<Bucket> bucketsList = new ArrayList<Bucket>();
for (String arg : args) {
int v1 = StringUtils.indexOf(arg, '|');
int v2 = StringUtils.lastIndexOf(arg, '|');
boolean isOpenRange = ((v2 - v1) == 1) ? true : false;
String[] values = StringUtils.split(arg, '|');
if (values.length != 3) {
int lower,upper,weight;
if (isOpenRange) {
lower = Integer.parseInt(values[0]);
upper = UniformIntGenerator.getMAXupper();
weight = Integer.parseInt(values[1]);
} else if (values.length != 3) {
throw new IllegalArgumentException();
} else {
lower = Integer.parseInt(values[0]);
upper = Integer.parseInt(values[1]);
weight = Integer.parseInt(values[2]);
}
int lower = Integer.parseInt(values[0]);
int upper = Integer.parseInt(values[1]);
int weight = Integer.parseInt(values[2]);
bucketsList.add(new Bucket(lower, upper, weight));
}
if (bucketsList.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class UniformIntGenerator implements IntGenerator {

private int lower;
private int upper;
private static int MAXupper = Integer.MAX_VALUE;

public UniformIntGenerator(int lower, int upper) {
if (lower <= 0 || upper <= 0 || lower > upper)
Expand Down Expand Up @@ -74,8 +75,12 @@ private static UniformIntGenerator tryParse(String pattern) {
pattern = StringUtils.substringBetween(pattern, "(", ")");
String[] args = StringUtils.split(pattern, ',');
int lower = Integer.parseInt(args[0]);
int upper = Integer.parseInt(args[1]);
int upper = (args.length == 2) ? Integer.parseInt(args[1]) : MAXupper;
return new UniformIntGenerator(lower, upper);
}

public static int getMAXupper () {
return MAXupper;
}

}