diff --git a/data/templated/example.xml b/data/templated/example.xml
index 4051b8a7b..e4c428b14 100644
--- a/data/templated/example.xml
+++ b/data/templated/example.xml
@@ -9,12 +9,12 @@
INTEGER
- 3
- 4
+
+
- 5
- 6
+
+
@@ -33,8 +33,8 @@
INTEGER
+ 1
- 8
@@ -53,8 +53,8 @@
FLOAT
- 10
- 10.49
+
+ 10.50
@@ -64,19 +64,28 @@
- FLOAT
+ INTEGER
- 2.1
+ 2
- ?]]>
+
- FLOAT
+ TIMESTAMP
- 255.0
+
+
+
+
+
+
+
+
+
+
@@ -97,9 +106,9 @@
111
- 2022-10-10 11:30:30
- 1.0
- Test
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/oltpbenchmark/api/templates/ObjectFactory.java b/src/main/java/com/oltpbenchmark/api/templates/ObjectFactory.java
index 3fa4c965d..36634ae2b 100644
--- a/src/main/java/com/oltpbenchmark/api/templates/ObjectFactory.java
+++ b/src/main/java/com/oltpbenchmark/api/templates/ObjectFactory.java
@@ -17,10 +17,10 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
-// Implementation, vJAXB 2.1.10
-// See http://java.sun.com/xml/jaxb
+// Implementation, v2.3.0.1
+// See https://javaee.github.io/jaxb-v2/
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.12.28 at 11:42:38 PM EST
+// Generated on: 2023.11.16 at 08:29:59 AM UTC
//
package com.oltpbenchmark.api.templates;
@@ -32,7 +32,7 @@
/**
* This object contains factory methods for each Java content interface and Java element interface
- * generated in the com.oltpbenchmark.api.templates package.
+ * generated in the main.java.com.oltpbenchmark.api.templates package.
*
*
An ObjectFactory allows you to programatically construct new instances of the Java
* representation for XML content. The Java representation of XML content can consist of schema
@@ -46,10 +46,15 @@ public class ObjectFactory {
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes
- * for package: com.oltpbenchmark.api.templates
+ * for package: main.java.com.oltpbenchmark.api.templates
*/
public ObjectFactory() {}
+ /** Create an instance of {@link TemplatesType } */
+ public TemplatesType createTemplatesType() {
+ return new TemplatesType();
+ }
+
/** Create an instance of {@link TemplateType } */
public TemplateType createTemplateType() {
return new TemplateType();
@@ -65,9 +70,19 @@ public ValuesType createValuesType() {
return new ValuesType();
}
- /** Create an instance of {@link JAXBElement }{@code <}{@link TemplatesType }{@code >}} */
+ /** Create an instance of {@link ValueType } */
+ public ValueType createValueType() {
+ return new ValueType();
+ }
+
+ /**
+ * Create an instance of {@link JAXBElement }{@code <}{@link TemplatesType }{@code >}
+ *
+ * @param value Java instance representing xml element's value.
+ * @return the new instance of {@link JAXBElement }{@code <}{@link TemplatesType }{@code >}
+ */
@XmlElementDecl(namespace = "", name = "templates")
- public JAXBElement createDialects(TemplatesType value) {
- return new JAXBElement<>(_Templates_QNAME, TemplatesType.class, null, value);
+ public JAXBElement createTemplates(TemplatesType value) {
+ return new JAXBElement(_Templates_QNAME, TemplatesType.class, null, value);
}
}
diff --git a/src/main/java/com/oltpbenchmark/api/templates/TemplateType.java b/src/main/java/com/oltpbenchmark/api/templates/TemplateType.java
index 427180c28..d5c59d276 100644
--- a/src/main/java/com/oltpbenchmark/api/templates/TemplateType.java
+++ b/src/main/java/com/oltpbenchmark/api/templates/TemplateType.java
@@ -17,10 +17,10 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
-// Implementation, vJAXB 2.1.10
-// See http://java.sun.com/xml/jaxb
+// Implementation, v2.3.0.1
+// See https://javaee.github.io/jaxb-v2/
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.12.28 at 11:42:38 PM EST
+// Generated on: 2023.11.16 at 08:29:59 AM UTC
//
package com.oltpbenchmark.api.templates;
@@ -30,21 +30,23 @@
import java.util.List;
/**
- * Java class for dialectType complex type.
+ * Java class for templateType complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@@ -53,9 +55,6 @@
propOrder = {"query", "types", "values"})
public class TemplateType {
- @XmlAttribute(required = true)
- protected String name;
-
@XmlElement(required = true)
protected String query;
@@ -65,24 +64,63 @@ public class TemplateType {
@XmlElement(required = true)
protected List values;
- /** Gets the value of the query property. */
+ @XmlAttribute(name = "name", required = true)
+ protected String name;
+
+ /**
+ * Gets the value of the query property.
+ *
+ * @return possible object is {@link String }
+ */
public String getQuery() {
return this.query;
}
- /** Gets the value of the types property. */
+ /**
+ * Sets the value of the query property.
+ *
+ * @param value allowed object is {@link String }
+ */
+ public void setQuery(String value) {
+ this.query = value;
+ }
+
+ /**
+ * Gets the value of the types property.
+ *
+ * @return possible object is {@link TypesType }
+ */
public TypesType getTypes() {
return this.types;
}
/**
- * Gets the value of the types property.
+ * Sets the value of the types property.
+ *
+ * @param value allowed object is {@link TypesType }
+ */
+ public void setTypes(TypesType value) {
+ this.types = value;
+ }
+
+ /**
+ * Gets the value of the values property.
+ *
+ *
This accessor method returns a reference to the live list, not a snapshot. Therefore any
+ * modification you make to the returned list will be present inside the JAXB object. This is why
+ * there is not a set method for the values property.
+ *
+ *
For example, to add a new item, do as follows:
+ *
+ *
+ * getValues().add(newItem);
+ *
*
*
Objects of the following type(s) are allowed in the list {@link ValuesType }
*/
- public List getValues() {
+ public List getValuesList() {
if (this.values == null) {
- this.values = new ArrayList<>();
+ this.values = new ArrayList();
}
return this.values;
}
@@ -93,6 +131,15 @@ public List getValues() {
* @return possible object is {@link String }
*/
public String getName() {
- return name;
+ return this.name;
+ }
+
+ /**
+ * Sets the value of the name property.
+ *
+ * @param value allowed object is {@link String }
+ */
+ public void setName(String value) {
+ this.name = value;
}
}
diff --git a/src/main/java/com/oltpbenchmark/api/templates/TemplatesType.java b/src/main/java/com/oltpbenchmark/api/templates/TemplatesType.java
index 4773c4986..cb8ad6d28 100644
--- a/src/main/java/com/oltpbenchmark/api/templates/TemplatesType.java
+++ b/src/main/java/com/oltpbenchmark/api/templates/TemplatesType.java
@@ -17,36 +17,33 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
-// Implementation, vJAXB 2.1.10
-// See http://java.sun.com/xml/jaxb
+// Implementation, v2.3.0.1
+// See https://javaee.github.io/jaxb-v2/
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.12.28 at 11:42:38 PM EST
+// Generated on: 2023.11.16 at 08:29:59 AM UTC
//
package com.oltpbenchmark.api.templates;
-import jakarta.xml.bind.annotation.XmlAccessType;
-import jakarta.xml.bind.annotation.XmlAccessorType;
-import jakarta.xml.bind.annotation.XmlElement;
-import jakarta.xml.bind.annotation.XmlType;
+import jakarta.xml.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
- * Java class for dialectsType complex type.
+ * Java class for templatesType complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@@ -59,13 +56,23 @@ public class TemplatesType {
protected List template;
/**
- * Gets the value of the dialect property.
+ * Gets the value of the template property.
+ *
+ *
This accessor method returns a reference to the live list, not a snapshot. Therefore any
+ * modification you make to the returned list will be present inside the JAXB object. This is why
+ * there is not a set method for the template property.
+ *
+ *
For example, to add a new item, do as follows:
+ *
+ *
+ * getTemplate().add(newItem);
+ *
*
*
Objects of the following type(s) are allowed in the list {@link TemplateType }
*/
public List getTemplateList() {
if (this.template == null) {
- this.template = new ArrayList<>();
+ this.template = new ArrayList();
}
return this.template;
}
diff --git a/src/main/java/com/oltpbenchmark/api/templates/TypesType.java b/src/main/java/com/oltpbenchmark/api/templates/TypesType.java
index 6fec026c2..8c43e4b8e 100644
--- a/src/main/java/com/oltpbenchmark/api/templates/TypesType.java
+++ b/src/main/java/com/oltpbenchmark/api/templates/TypesType.java
@@ -17,10 +17,10 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
-// Implementation, vJAXB 2.1.10
-// See http://java.sun.com/xml/jaxb
+// Implementation, v2.3.0.1
+// See https://javaee.github.io/jaxb-v2/
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.12.28 at 11:42:38 PM EST
+// Generated on: 2023.11.16 at 08:29:59 AM UTC
//
package com.oltpbenchmark.api.templates;
@@ -30,20 +30,20 @@
import java.util.List;
/**
- * Java class for dialectType complex type.
+ * Java class for typesType complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@@ -58,6 +58,16 @@ public class TypesType {
/**
* Gets the value of the type property.
*
+ *
This accessor method returns a reference to the live list, not a snapshot. Therefore any
+ * modification you make to the returned list will be present inside the JAXB object. This is why
+ * there is not a set method for the type property.
+ *
+ *
For example, to add a new item, do as follows:
+ *
+ *
+ * getType().add(newItem);
+ *
+ *
*
Objects of the following type(s) are allowed in the list {@link String }
*/
public List getTypeList() {
diff --git a/src/main/java/com/oltpbenchmark/api/templates/ValueType.java b/src/main/java/com/oltpbenchmark/api/templates/ValueType.java
new file mode 100644
index 000000000..07a2fa9ca
--- /dev/null
+++ b/src/main/java/com/oltpbenchmark/api/templates/ValueType.java
@@ -0,0 +1,140 @@
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
+// Implementation, v2.3.0.1
+// See https://javaee.github.io/jaxb-v2/
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2023.11.16 at 08:29:59 AM UTC
+//
+
+package com.oltpbenchmark.api.templates;
+
+import jakarta.xml.bind.annotation.*;
+
+/**
+ * Java class for valueType complex type.
+ *
+ *
The following schema fragment specifies the expected content contained within this class.
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(
+ name = "valueType",
+ propOrder = {"value"})
+public class ValueType {
+
+ @XmlValue protected String value;
+
+ @XmlAttribute(name = "dist")
+ protected String dist;
+
+ @XmlAttribute(name = "min")
+ protected String min;
+
+ @XmlAttribute(name = "max")
+ protected String max;
+
+ @XmlAttribute(name = "seed")
+ protected String seed;
+
+ /**
+ * Gets the value of the value property.
+ *
+ * @return possible object is {@link String }
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Sets the value of the value property.
+ *
+ * @param value allowed object is {@link String }
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Gets the value of the dist property.
+ *
+ * @return possible object is {@link String }
+ */
+ public String getDist() {
+ return dist;
+ }
+
+ /**
+ * Sets the value of the dist property.
+ *
+ * @param value allowed object is {@link String }
+ */
+ public void setDist(String value) {
+ this.dist = value;
+ }
+
+ /**
+ * Gets the value of the min property.
+ *
+ * @return possible object is {@link String }
+ */
+ public String getMin() {
+ return min;
+ }
+
+ /**
+ * Sets the value of the min property.
+ *
+ * @param value allowed object is {@link String }
+ */
+ public void setMin(String value) {
+ this.min = value;
+ }
+
+ /**
+ * Gets the value of the max property.
+ *
+ * @return possible object is {@link String }
+ */
+ public String getMax() {
+ return max;
+ }
+
+ /**
+ * Sets the value of the max property.
+ *
+ * @param value allowed object is {@link String }
+ */
+ public void setMax(String value) {
+ this.max = value;
+ }
+
+ /**
+ * Gets the value of the seed property.
+ *
+ * @return possible object is {@link String }
+ */
+ public String getSeed() {
+ return seed;
+ }
+
+ /**
+ * Sets the value of the seed property.
+ *
+ * @param value allowed object is {@link String }
+ */
+ public void setSeed(String value) {
+ this.seed = value;
+ }
+}
diff --git a/src/main/java/com/oltpbenchmark/api/templates/ValuesType.java b/src/main/java/com/oltpbenchmark/api/templates/ValuesType.java
index 6711ff53a..ee9bf4138 100644
--- a/src/main/java/com/oltpbenchmark/api/templates/ValuesType.java
+++ b/src/main/java/com/oltpbenchmark/api/templates/ValuesType.java
@@ -17,10 +17,10 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
-// Implementation, vJAXB 2.1.10
-// See http://java.sun.com/xml/jaxb
+// Implementation, v2.3.0.1
+// See https://javaee.github.io/jaxb-v2/
// Any modifications to this file will be lost upon recompilation of the source schema.
-// Generated on: 2011.12.28 at 11:42:38 PM EST
+// Generated on: 2023.11.16 at 08:29:59 AM UTC
//
package com.oltpbenchmark.api.templates;
@@ -30,20 +30,20 @@
import java.util.List;
/**
- * Java class for dialectType complex type.
+ * Java class for valuesType complex type.
*
*
The following schema fragment specifies the expected content contained within this class.
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@@ -53,16 +53,26 @@
public class ValuesType {
@XmlElement(required = true)
- protected List value;
+ protected List value;
/**
* Gets the value of the value property.
*
- *
Objects of the following type(s) are allowed in the list {@link String }
+ *
This accessor method returns a reference to the live list, not a snapshot. Therefore any
+ * modification you make to the returned list will be present inside the JAXB object. This is why
+ * there is not a set method for the value property.
+ *
+ *
For example, to add a new item, do as follows:
+ *
+ *
+ * getValue().add(newItem);
+ *
+ *
+ *
Objects of the following type(s) are allowed in the list {@link ValueType }
*/
- public List getValueList() {
+ public List getValueList() {
if (this.value == null) {
- this.value = new ArrayList<>();
+ this.value = new ArrayList();
}
return this.value;
}
diff --git a/src/main/java/com/oltpbenchmark/benchmarks/templated/README.md b/src/main/java/com/oltpbenchmark/benchmarks/templated/README.md
index 38d919f69..865775349 100644
--- a/src/main/java/com/oltpbenchmark/benchmarks/templated/README.md
+++ b/src/main/java/com/oltpbenchmark/benchmarks/templated/README.md
@@ -34,7 +34,8 @@ The file path for the XML template has to be defined in the workload configurati
An example configuration can be found in [`config/sqlserver/sample_template_config.xml`](../../../../../../../config/sqlserver/sample_templated_config.xml).
-> Since the templated benchmark is meant to flexibly support a myriad of different database schemas, it doesn't *currently* support the `init` and `load` phases.
+> Since the templated benchmark is meant to flexibly support a myriad of different database schemas, it doesn't _currently_ support the `init` and `load` phases.
+
The example can be executed if a loaded TPC-C instance is used as JDBC endpoint.
@@ -54,3 +55,106 @@ java -jar benchbase.jar -b templated -c config/sqlserver/sample_templated_config
```
> For additional examples, please refer to the build pipeline definition in the [`maven.yml`](../../../../../../../.github/workflows/maven.yml#L423) Github Actions workflow file.
+
+### Value selection
+
+
+The values are selected in **Round-Robin** fashion, giving the following access pattern for query 'Q1':
+
+`V1 --> V2 --> V1 --> V2 ...`
+
+```xml
+
+
+
+
+ Type1
+
+
+ V1
+
+
+ V2
+
+
+
+```
+
+For now, more fine-grained control of the access pattern can be achieved by building a new query for each value and adjusting the weight of each query in the config file.
+
+## Value Distributions
+
+In order to support more variety in templated queries, it is possible to use a whole distribution of values instead of a single static value in a templated query
+
+Each time the query is run, a different value will substitute the `?`.
+
+```xml
+
+
+
+
+ INTEGER
+
+
+
+
+
+
+
+
+
+
+```
+
+The distributions are dependent on the type of the value. Currently, the following type-distributions pairs are supported:
+| Type | uniform | binomial | zipfian | scrambled |
+| ---------------- | :-----: | :------: | :-----: | :---------------: |
+| INTEGER | X | X | X | X |
+| FLOAT / REAL | X | X | - | - |
+| BIGINT | X | X | X | X |
+| VARCHAR | X | - | - | - |
+| TIMESTAMP | X | X | X | X |
+| DATE | X | X | X | X |
+| TIME | X | X | X | X |
+
+The following properties can be set for templated distributions:
+
+| Property | description | required | default |
+| ----- | ---------------------------------------------- | :------: | :-----: |
+| dist | The distribution of the values | Yes | - |
+| min | The minimum value the generator can produce | Yes | - |
+| max | The maximum value the generator can produce | Yes | - |
+| seed | A seed for the generator to ensure consistency | No | 0 |
+
+
+### Timestamps, Dates and Time
+
+For `Timestamp`, `Date`, and `Time` types, the min and max values can be given as a Long value or string.
+- The Long value is interpreted as the milliseconds since January 1, 1970, 00:00:00 GMT/UTC.
+
+- The string value is interpreted as UTC timezone and must have the following format: (yyyy-MM-dd HH:mm:ss)
+
+#### Example
+```xml
+
+
+
+
+```
+To get the current UNIX time in milliseconds, use the following bash command:
+```bash
+date +%s%3N
+```
+or use a web services like [www.currentmillis.com](www.currentmillis.com)
+
+
diff --git a/src/main/java/com/oltpbenchmark/benchmarks/templated/TemplatedBenchmark.java b/src/main/java/com/oltpbenchmark/benchmarks/templated/TemplatedBenchmark.java
index c92ccf767..38ae2c533 100644
--- a/src/main/java/com/oltpbenchmark/benchmarks/templated/TemplatedBenchmark.java
+++ b/src/main/java/com/oltpbenchmark/benchmarks/templated/TemplatedBenchmark.java
@@ -25,18 +25,19 @@
import com.oltpbenchmark.api.Worker;
import com.oltpbenchmark.api.templates.TemplateType;
import com.oltpbenchmark.api.templates.TemplatesType;
+import com.oltpbenchmark.api.templates.ValueType;
import com.oltpbenchmark.api.templates.ValuesType;
import com.oltpbenchmark.benchmarks.templated.procedures.GenericQuery;
import com.oltpbenchmark.benchmarks.templated.procedures.GenericQuery.QueryTemplateInfo;
import com.oltpbenchmark.benchmarks.templated.util.GenericQueryOperation;
+import com.oltpbenchmark.benchmarks.templated.util.TemplatedValue;
import com.oltpbenchmark.benchmarks.templated.util.TraceTransactionGenerator;
-import com.opencsv.CSVParser;
-import com.opencsv.CSVParserBuilder;
import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.Unmarshaller;
import java.io.FileInputStream;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -120,12 +121,25 @@ protected List> makeWorkersImpl() {
// list of params.
List list = new ArrayList<>();
String[] paramsTypes = info.getParamsTypes();
- CSVParser parser = new CSVParserBuilder().withQuoteChar('\'').build();
- for (String binding : info.getParamsValues()) {
- Object[] params = parser.parseLine(binding);
- assert paramsTypes.length == params.length;
+
+ TemplatedValue[] params = info.getParamsValues();
+ int paramsLen = params.length;
+ int typesLen = paramsTypes.length;
+
+ assert (paramsLen % typesLen) == 0;
+
+ if (paramsLen == typesLen) {
list.add(new GenericQueryOperation(params));
+ } else {
+ int numSplits = paramsLen / typesLen;
+ for (int j = 0; j < numSplits; j += 1) {
+ TemplatedValue[] subset =
+ Arrays.copyOfRange(params, j * typesLen, j * typesLen + typesLen);
+ assert subset.length == typesLen;
+ list.add(new GenericQueryOperation(subset));
+ }
}
+
generators.put(proc.getClass(), new TraceTransactionGenerator(list));
}
@@ -138,6 +152,7 @@ protected List> makeWorkersImpl() {
} catch (Exception e) {
throw new IllegalStateException("Unable to create workers", e);
}
+
return workers;
}
@@ -169,11 +184,31 @@ private CustomClassLoader loadQueryTemplates(String file) {
for (TemplateType template : templates.getTemplateList()) {
ImmutableParsedQueryTemplate.Builder b = ImmutableParsedQueryTemplate.builder();
+ List templateTypes = template.getTypes().getTypeList();
+
b.name(template.getName());
b.query(template.getQuery());
- b.paramsTypes(template.getTypes().getTypeList());
- for (ValuesType paramValue : template.getValues()) {
- b.addParamsValues(String.join(",", paramValue.getValueList()));
+ b.paramsTypes(templateTypes);
+
+ for (ValuesType paramValue : template.getValuesList()) {
+ int typeIndex = 0;
+ for (ValueType value : paramValue.getValueList()) {
+ /* Lightweight constructor used if no distribution is present */
+ if (value.getDist() == null
+ || value.getDist().length() < 1
+ || value.getDist().equals("null")) {
+ b.addParamsValues(new TemplatedValue(value.getValue()));
+ } else {
+ b.addParamsValues(
+ new TemplatedValue(
+ value.getDist(),
+ value.getMin(),
+ value.getMax(),
+ value.getSeed(),
+ templateTypes.get(typeIndex)));
+ }
+ typeIndex++;
+ }
}
ParsedQueryTemplate qt = b.build();
@@ -181,26 +216,28 @@ private CustomClassLoader loadQueryTemplates(String file) {
final String s =
"""
package %s ;
+ import %s ;
public final class %s extends %s {
@Override
public %s getQueryTemplateInfo() {
return ImmutableQueryTemplateInfo.builder()
.query(new %s(\"%s\"))
.paramsTypes(new String[] {%s})
- .paramsValues(new String[] {%s})
+ .paramsValues(new TemplatedValue[] {%s})
.build();
}
}
"""
.formatted(
GenericQuery.class.getPackageName(),
+ TemplatedValue.class.getCanonicalName(),
qt.getName(),
GenericQuery.class.getCanonicalName(),
QueryTemplateInfo.class.getCanonicalName(),
SQLStmt.class.getCanonicalName(),
StringEscapeUtils.escapeJava(qt.getQuery()),
getParamsString(qt.getParamsTypes()),
- getParamsString(qt.getParamsValues()));
+ buildTemplatedValueString(qt.getParamsValues()));
LOG.debug("Class definition for query template {}:\n {}", qt.getName(), s);
final String qualifiedClassName = GenericQuery.class.getPackageName() + "." + qt.getName();
final ISimpleCompiler compiler = compilerFactory.newSimpleCompiler();
@@ -224,6 +261,44 @@ private String getParamsString(List params) {
return result.isEmpty() ? "" : result.substring(0, result.length() - 1);
}
+ private String buildTemplatedValueString(List params) {
+ String result = "";
+ for (TemplatedValue param : params) {
+ if (param.getDistribution() != null) {
+ result +=
+ "new TemplatedValue("
+ + "\""
+ + param.getDistribution()
+ + "\""
+ + ","
+ + "\""
+ + param.getMin()
+ + "\""
+ + ","
+ + "\""
+ + param.getMax()
+ + "\""
+ + ","
+ + "\""
+ + param.getSeed()
+ + "\""
+ + ","
+ + "\""
+ + param.getValueType()
+ + "\""
+ + "),";
+ } else {
+ result +=
+ "new TemplatedValue("
+ + "\""
+ + StringEscapeUtils.escapeJava(param.getValue())
+ + "\""
+ + "),";
+ }
+ }
+ return result.isEmpty() ? "" : result.substring(0, result.length() - 1);
+ }
+
private static class CustomClassLoader extends ClassLoader {
private final Map> classes = new HashMap<>();
@@ -271,7 +346,7 @@ default List getParamsTypes() {
/** Potential query parameter values. */
@Value.Default
- default List getParamsValues() {
+ default List getParamsValues() {
return List.of();
}
}
diff --git a/src/main/java/com/oltpbenchmark/benchmarks/templated/procedures/GenericQuery.java b/src/main/java/com/oltpbenchmark/benchmarks/templated/procedures/GenericQuery.java
index e4ab9a2b1..9c5ea67d0 100644
--- a/src/main/java/com/oltpbenchmark/benchmarks/templated/procedures/GenericQuery.java
+++ b/src/main/java/com/oltpbenchmark/benchmarks/templated/procedures/GenericQuery.java
@@ -18,10 +18,16 @@
import com.oltpbenchmark.api.Procedure;
import com.oltpbenchmark.api.SQLStmt;
+import com.oltpbenchmark.benchmarks.templated.util.TemplatedValue;
+import com.oltpbenchmark.benchmarks.templated.util.ValueGenerator;
+import com.oltpbenchmark.util.JDBCSupportedType;
import java.sql.Connection;
+import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
import java.sql.Types;
import java.util.List;
import org.immutables.value.Value;
@@ -33,7 +39,7 @@ public abstract class GenericQuery extends Procedure {
protected static final Logger LOG = LoggerFactory.getLogger(GenericQuery.class);
/** Execution method with parameters. */
- public void run(Connection conn, List