-
Notifications
You must be signed in to change notification settings - Fork 398
Expand file tree
/
Copy pathDBMSCommon.java
More file actions
42 lines (33 loc) · 1.09 KB
/
DBMSCommon.java
File metadata and controls
42 lines (33 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package sqlancer.common;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class DBMSCommon {
private static final Pattern SQLANCER_INDEX_PATTERN = Pattern.compile("^i\\d+");
private DBMSCommon() {
}
public static String createTableName(int nr) {
return String.format("t%d", nr);
}
public static String createColumnName(int nr) {
return String.format("c%d", nr);
}
public static String createIndexName(int nr) {
return String.format("i%d", nr);
}
public static boolean matchesIndexName(String indexName) {
Matcher matcher = SQLANCER_INDEX_PATTERN.matcher(indexName);
return matcher.matches();
}
public static int getMaxIndexInDoubleArrary(double... doubleArray) {
int maxIndex = 0;
double maxValue = 0.0;
for (int j = 0; j < doubleArray.length; j++) {
double curReward = doubleArray[j];
if (curReward > maxValue) {
maxIndex = j;
maxValue = curReward;
}
}
return maxIndex;
}
}