Skip to content

Commit cc2cfa5

Browse files
ETHenzlerebpkroth
andauthored
Feat: Support for Distributions in Templated Workloads (#385)
PR adds support for various Numerical Distributions in templated benchmarks - Uniform - Binomial - Zipfian - Scrambled The distributions work not only for integers, but also different types such as timestamps, long, float A table of supported combinations can be found in the templated benchmarks readme. | Type | uniform | binomial | zipfian | scrambled (zipfian) | |---|:---:|:---:|:---:|:---:| | INTEGER | X | X | X | X | | FLOAT / REAL | X | X|- | - | | BIGINT | X | X | X | X | | VARCHAR / STRING | X | -| -| -| | TIMESTAMP | X | X |X |X | | DATE | X | X| X| X| | TIME | X |X | X| X| Usage example: ```xml <templates> <template name="MyTemplate"> <query><![CDATA[SELECT * FROM MyTable WHERE id = ?]]></query> <types> <type>INTEGER</type> </types> <values> <value dist="uniform" min="0" max="1000" seed="1"/> </values> <values> <value dist="zipf" min="1" max="1000" seed="2"/> </values> </template> <!-- ... --> <templates> ``` This PR is not a breaking change - One can still use a static value in the templated queries. `<value>10</value>` In the future, I could see a breaking change that adds the datatype directly to the values so the TemplatedValue can do the type handling directly. `<value dist="uniform" type="integer">`. This would make type checking easier and remove the need to store the original min/max values as strings for all datatypes. --------- Co-authored-by: Brian Kroth <bpkroth@users.noreply.github.com>
1 parent 9837d67 commit cc2cfa5

File tree

15 files changed

+971
-124
lines changed

15 files changed

+971
-124
lines changed

data/templated/example.xml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
<type>INTEGER</type>
1010
</types>
1111
<values>
12-
<value>3</value>
13-
<value>4</value>
12+
<value dist="uniform" min="1" max="3"/>
13+
<value dist="zipfian" min="1" max="2"/>
1414
</values>
1515
<values>
16-
<value>5</value>
17-
<value>6</value>
16+
<value dist="scrambled" min="0" max="4" seed="999"/>
17+
<value dist="normal" min="1" max="3" seed="1"/>
1818
</values>
1919
</template>
2020
<template name="GetCust">
@@ -33,8 +33,8 @@
3333
<type>INTEGER</type>
3434
</types>
3535
<values>
36+
<value>1</value>
3637
<value />
37-
<value>8</value>
3838
</values>
3939
</template>
4040
<template name="GetWarehouse">
@@ -53,8 +53,8 @@
5353
<type>FLOAT</type>
5454
</types>
5555
<values>
56-
<value>10</value>
57-
<value>10.49</value>
56+
<value dist="normal" min="10" max="12.5"/>
57+
<value dist="uniform" min="15.1" max="100.22"/>
5858
</values>
5959
<values>
6060
<value>10.50</value>
@@ -64,19 +64,28 @@
6464
<template name="UpdateItemPrice">
6565
<query><![CDATA[UPDATE item SET i_price = i_price + 1 WHERE i_price < ?]]></query>
6666
<types>
67-
<type>FLOAT</type>
67+
<type>INTEGER</type>
6868
</types>
6969
<values>
70-
<value>2.1</value>
70+
<value dist="zipfian" min="10" max="40">2</value>
7171
</values>
7272
</template>
7373
<template name="DeleteItem">
74-
<query><![CDATA[DELETE FROM item WHERE i_price > ?]]></query>
74+
<query><![CDATA[DELETE FROM oorder WHERE o_entry_d < ?]]></query>
7575
<types>
76-
<type>FLOAT</type>
76+
<type>TIMESTAMP</type>
7777
</types>
7878
<values>
79-
<value>255.0</value>
79+
<value dist="uniform" min="1000" max="300000"></value>
80+
</values>
81+
<values>
82+
<value dist="normal" min="1000" max="300000"></value>
83+
</values>
84+
<values>
85+
<value dist="zipfian" min="1000" max="300000"></value>
86+
</values>
87+
<values>
88+
<value dist="scrambled" min="1000" max="300000"></value>
8089
</values>
8190
</template>
8291
<template name="InsertItem">
@@ -97,9 +106,9 @@
97106
<value>1</value>
98107
<value>1</value>
99108
<value>1</value>
100-
<value>2022-10-10 11:30:30</value>
101-
<value>1.0</value>
102-
<value>Test</value>
109+
<value dist="uniform" min="1999-12-12 01:01:55" max="2000-12-12 04:04:44"/>
110+
<value dist="normal" min="0.5" max="12.5"/>
111+
<value dist="uniform" min="0" max="23"/>
103112
</values>
104113
</template>
105114
</templates>

src/main/java/com/oltpbenchmark/api/templates/ObjectFactory.java

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
//
1919
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
20-
// Implementation, vJAXB 2.1.10
21-
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
20+
// Implementation, v2.3.0.1
21+
// See <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
2222
// Any modifications to this file will be lost upon recompilation of the source schema.
23-
// Generated on: 2011.12.28 at 11:42:38 PM EST
23+
// Generated on: 2023.11.16 at 08:29:59 AM UTC
2424
//
2525

2626
package com.oltpbenchmark.api.templates;
@@ -32,7 +32,7 @@
3232

3333
/**
3434
* This object contains factory methods for each Java content interface and Java element interface
35-
* generated in the com.oltpbenchmark.api.templates package.
35+
* generated in the main.java.com.oltpbenchmark.api.templates package.
3636
*
3737
* <p>An ObjectFactory allows you to programatically construct new instances of the Java
3838
* representation for XML content. The Java representation of XML content can consist of schema
@@ -46,10 +46,15 @@ public class ObjectFactory {
4646

4747
/**
4848
* Create a new ObjectFactory that can be used to create new instances of schema derived classes
49-
* for package: com.oltpbenchmark.api.templates
49+
* for package: main.java.com.oltpbenchmark.api.templates
5050
*/
5151
public ObjectFactory() {}
5252

53+
/** Create an instance of {@link TemplatesType } */
54+
public TemplatesType createTemplatesType() {
55+
return new TemplatesType();
56+
}
57+
5358
/** Create an instance of {@link TemplateType } */
5459
public TemplateType createTemplateType() {
5560
return new TemplateType();
@@ -65,9 +70,19 @@ public ValuesType createValuesType() {
6570
return new ValuesType();
6671
}
6772

68-
/** Create an instance of {@link JAXBElement }{@code <}{@link TemplatesType }{@code >}} */
73+
/** Create an instance of {@link ValueType } */
74+
public ValueType createValueType() {
75+
return new ValueType();
76+
}
77+
78+
/**
79+
* Create an instance of {@link JAXBElement }{@code <}{@link TemplatesType }{@code >}
80+
*
81+
* @param value Java instance representing xml element's value.
82+
* @return the new instance of {@link JAXBElement }{@code <}{@link TemplatesType }{@code >}
83+
*/
6984
@XmlElementDecl(namespace = "", name = "templates")
70-
public JAXBElement<TemplatesType> createDialects(TemplatesType value) {
71-
return new JAXBElement<>(_Templates_QNAME, TemplatesType.class, null, value);
85+
public JAXBElement<TemplatesType> createTemplates(TemplatesType value) {
86+
return new JAXBElement<TemplatesType>(_Templates_QNAME, TemplatesType.class, null, value);
7287
}
7388
}

src/main/java/com/oltpbenchmark/api/templates/TemplateType.java

Lines changed: 70 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717

1818
//
1919
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
20-
// Implementation, vJAXB 2.1.10
21-
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
20+
// Implementation, v2.3.0.1
21+
// See <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
2222
// Any modifications to this file will be lost upon recompilation of the source schema.
23-
// Generated on: 2011.12.28 at 11:42:38 PM EST
23+
// Generated on: 2023.11.16 at 08:29:59 AM UTC
2424
//
2525

2626
package com.oltpbenchmark.api.templates;
@@ -30,21 +30,23 @@
3030
import java.util.List;
3131

3232
/**
33-
* Java class for dialectType complex type.
33+
* Java class for templateType complex type.
3434
*
3535
* <p>The following schema fragment specifies the expected content contained within this class.
3636
*
3737
* <pre>
38-
* &lt;complexType name="dialectType">
39-
* &lt;complexContent>
40-
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
41-
* &lt;sequence>
42-
* &lt;element name="procedure" type="{}procedureType" maxOccurs="unbounded"/>
43-
* &lt;/sequence>
44-
* &lt;attribute name="type" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
45-
* &lt;/restriction>
46-
* &lt;/complexContent>
47-
* &lt;/complexType>
38+
* &lt;complexType name="templateType"&gt;
39+
* &lt;complexContent&gt;
40+
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
41+
* &lt;sequence&gt;
42+
* &lt;element name="query" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
43+
* &lt;element name="types" type="{}typesType"/&gt;
44+
* &lt;element name="values" type="{}valuesType" maxOccurs="unbounded"/&gt;
45+
* &lt;/sequence&gt;
46+
* &lt;attribute name="name" use="required" type="{http://www.w3.org/2001/XMLSchema}string" /&gt;
47+
* &lt;/restriction&gt;
48+
* &lt;/complexContent&gt;
49+
* &lt;/complexType&gt;
4850
* </pre>
4951
*/
5052
@XmlAccessorType(XmlAccessType.FIELD)
@@ -53,9 +55,6 @@
5355
propOrder = {"query", "types", "values"})
5456
public class TemplateType {
5557

56-
@XmlAttribute(required = true)
57-
protected String name;
58-
5958
@XmlElement(required = true)
6059
protected String query;
6160

@@ -65,24 +64,63 @@ public class TemplateType {
6564
@XmlElement(required = true)
6665
protected List<ValuesType> values;
6766

68-
/** Gets the value of the query property. */
67+
@XmlAttribute(name = "name", required = true)
68+
protected String name;
69+
70+
/**
71+
* Gets the value of the query property.
72+
*
73+
* @return possible object is {@link String }
74+
*/
6975
public String getQuery() {
7076
return this.query;
7177
}
7278

73-
/** Gets the value of the types property. */
79+
/**
80+
* Sets the value of the query property.
81+
*
82+
* @param value allowed object is {@link String }
83+
*/
84+
public void setQuery(String value) {
85+
this.query = value;
86+
}
87+
88+
/**
89+
* Gets the value of the types property.
90+
*
91+
* @return possible object is {@link TypesType }
92+
*/
7493
public TypesType getTypes() {
7594
return this.types;
7695
}
7796

7897
/**
79-
* Gets the value of the types property.
98+
* Sets the value of the types property.
99+
*
100+
* @param value allowed object is {@link TypesType }
101+
*/
102+
public void setTypes(TypesType value) {
103+
this.types = value;
104+
}
105+
106+
/**
107+
* Gets the value of the values property.
108+
*
109+
* <p>This accessor method returns a reference to the live list, not a snapshot. Therefore any
110+
* modification you make to the returned list will be present inside the JAXB object. This is why
111+
* there is not a <CODE>set</CODE> method for the values property.
112+
*
113+
* <p>For example, to add a new item, do as follows:
114+
*
115+
* <pre>
116+
* getValues().add(newItem);
117+
* </pre>
80118
*
81119
* <p>Objects of the following type(s) are allowed in the list {@link ValuesType }
82120
*/
83-
public List<ValuesType> getValues() {
121+
public List<ValuesType> getValuesList() {
84122
if (this.values == null) {
85-
this.values = new ArrayList<>();
123+
this.values = new ArrayList<ValuesType>();
86124
}
87125
return this.values;
88126
}
@@ -93,6 +131,15 @@ public List<ValuesType> getValues() {
93131
* @return possible object is {@link String }
94132
*/
95133
public String getName() {
96-
return name;
134+
return this.name;
135+
}
136+
137+
/**
138+
* Sets the value of the name property.
139+
*
140+
* @param value allowed object is {@link String }
141+
*/
142+
public void setName(String value) {
143+
this.name = value;
97144
}
98145
}

src/main/java/com/oltpbenchmark/api/templates/TemplatesType.java

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,36 +17,33 @@
1717

1818
//
1919
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference
20-
// Implementation, vJAXB 2.1.10
21-
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
20+
// Implementation, v2.3.0.1
21+
// See <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
2222
// Any modifications to this file will be lost upon recompilation of the source schema.
23-
// Generated on: 2011.12.28 at 11:42:38 PM EST
23+
// Generated on: 2023.11.16 at 08:29:59 AM UTC
2424
//
2525

2626
package com.oltpbenchmark.api.templates;
2727

28-
import jakarta.xml.bind.annotation.XmlAccessType;
29-
import jakarta.xml.bind.annotation.XmlAccessorType;
30-
import jakarta.xml.bind.annotation.XmlElement;
31-
import jakarta.xml.bind.annotation.XmlType;
28+
import jakarta.xml.bind.annotation.*;
3229
import java.util.ArrayList;
3330
import java.util.List;
3431

3532
/**
36-
* Java class for dialectsType complex type.
33+
* Java class for templatesType complex type.
3734
*
3835
* <p>The following schema fragment specifies the expected content contained within this class.
3936
*
4037
* <pre>
41-
* &lt;complexType name="dialectsType">
42-
* &lt;complexContent>
43-
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
44-
* &lt;sequence>
45-
* &lt;element name="dialect" type="{}dialectType" maxOccurs="unbounded"/>
46-
* &lt;/sequence>
47-
* &lt;/restriction>
48-
* &lt;/complexContent>
49-
* &lt;/complexType>
38+
* &lt;complexType name="templatesType"&gt;
39+
* &lt;complexContent&gt;
40+
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
41+
* &lt;sequence&gt;
42+
* &lt;element name="template" type="{}templateType" maxOccurs="unbounded"/&gt;
43+
* &lt;/sequence&gt;
44+
* &lt;/restriction&gt;
45+
* &lt;/complexContent&gt;
46+
* &lt;/complexType&gt;
5047
* </pre>
5148
*/
5249
@XmlAccessorType(XmlAccessType.FIELD)
@@ -59,13 +56,23 @@ public class TemplatesType {
5956
protected List<TemplateType> template;
6057

6158
/**
62-
* Gets the value of the dialect property.
59+
* Gets the value of the template property.
60+
*
61+
* <p>This accessor method returns a reference to the live list, not a snapshot. Therefore any
62+
* modification you make to the returned list will be present inside the JAXB object. This is why
63+
* there is not a <CODE>set</CODE> method for the template property.
64+
*
65+
* <p>For example, to add a new item, do as follows:
66+
*
67+
* <pre>
68+
* getTemplate().add(newItem);
69+
* </pre>
6370
*
6471
* <p>Objects of the following type(s) are allowed in the list {@link TemplateType }
6572
*/
6673
public List<TemplateType> getTemplateList() {
6774
if (this.template == null) {
68-
this.template = new ArrayList<>();
75+
this.template = new ArrayList<TemplateType>();
6976
}
7077
return this.template;
7178
}

0 commit comments

Comments
 (0)