Skip to content

Commit

Permalink
Min/Max for all Distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
ETHenzlere committed Oct 30, 2023
1 parent 9acfc19 commit 36174c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion data/templated/example.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<type>DISTRIBUTION</type>
</types>
<values>
<value>uniform,100</value>
<value>uniform,0,100</value>
</values>
</template>
<template name="GetCustNull">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public PreparedStatement getStatement(Connection conn, List<Object> params) thro
} else if (paramsTypes[i].equalsIgnoreCase("DISTRIBUTION")) {
String distType = params.get(i).toString();
String min, max;
int minI, maxI;
int val;
switch (distType) {
case "zipf":
Expand All @@ -84,38 +85,37 @@ public PreparedStatement getStatement(Connection conn, List<Object> params) thro
stmt.setInt(i + 1, zipf.nextInt());
break;
case "uniform":
max = params.get(i + 1).toString();
val = rng.nextInt(Integer.parseInt(max));
minI = Integer.parseInt(params.get(i + 1).toString());
maxI = Integer.parseInt(params.get(i + 2).toString());
val = rng.nextInt(maxI - minI) + minI;
stmt.setInt(i + 1, val);
break;
case "binomial":
int minI = Integer.parseInt(params.get(i + 1).toString());
int maxI = Integer.parseInt(params.get(i + 2).toString());
minI = Integer.parseInt(params.get(i + 1).toString());
maxI = Integer.parseInt(params.get(i + 2).toString());
do {
val = (int) (minI + Math.abs(rng.nextGaussian()) * maxI);
} while (val > maxI || val < minI);

stmt.setInt(i + 1, val);
break;
case "scrambled":
min = params.get(i + 1).toString();
max = params.get(i + 2).toString();
ScrambledZipfianGenerator scramZipf = new ScrambledZipfianGenerator(Integer.parseInt(min),
Integer.parseInt(max));
minI = Integer.parseInt(params.get(i + 1).toString());
maxI = Integer.parseInt(params.get(i + 2).toString());
ScrambledZipfianGenerator scramZipf = new ScrambledZipfianGenerator(minI,
maxI);
stmt.setInt(i + 1, scramZipf.nextInt());
break;
case "string":
max = params.get(i + 1).toString();
String randText = TextGenerator.randomStr(rng, Integer.parseInt(max));
maxI = Integer.parseInt(params.get(i + 1).toString());
String randText = TextGenerator.randomStr(rng, maxI);
stmt.setString(i + 1, randText);
break;
default:
throw new RuntimeException(
"No suitable distribution found. Currently supported are 'zipf' | 'normal' | 'uniform' | 'string' ");
"No suitable distribution found. Currently supported are 'zipf' | 'scrambled' | 'normal' | 'uniform' | 'string' ");
}

System.out.println(stmt.toString());

} else {
try {
// TODO: add support for nullable other types
Expand Down

0 comments on commit 36174c0

Please sign in to comment.