-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into nenadnoveljic/pg-prepared
- Loading branch information
Showing
172 changed files
with
4,663 additions
and
1,360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
plugins { | ||
id("me.champeau.jmh") | ||
} | ||
|
||
apply(from = "$rootDir/gradle/java.gradle") | ||
|
||
jmh { | ||
version = "1.28" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# This is a Gradle generated file for dependency locking. | ||
# Manual edits can break the build and are not advised. | ||
# This file is expected to be part of source control. | ||
ch.qos.logback:logback-classic:1.2.3=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
ch.qos.logback:logback-core:1.2.3=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
com.beust:jcommander:1.78=jmhRuntimeClasspath,testRuntimeClasspath | ||
com.github.javaparser:javaparser-core:3.25.1=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
com.github.spotbugs:spotbugs-annotations:4.2.0=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
com.github.spotbugs:spotbugs-annotations:4.7.3=spotbugs | ||
com.github.spotbugs:spotbugs:4.7.3=spotbugs | ||
com.google.code.findbugs:jsr305:3.0.2=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath | ||
com.google.code.gson:gson:2.9.1=spotbugs | ||
com.thoughtworks.qdox:qdox:1.12.1=jmhRuntimeClasspath,testRuntimeClasspath | ||
commons-codec:commons-codec:1.15=spotbugs | ||
de.thetaphi:forbiddenapis:3.1=compileClasspath,jmhCompileClasspath | ||
info.picocli:picocli:4.6.3=jmhRuntimeClasspath,testRuntimeClasspath | ||
jaxen:jaxen:1.2.0=spotbugs | ||
jline:jline:2.14.6=jmhRuntimeClasspath,testRuntimeClasspath | ||
junit:junit:4.13.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
net.jcip:jcip-annotations:1.0=compileClasspath,jmhCompileClasspath,jmhRuntimeClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath | ||
net.sf.jopt-simple:jopt-simple:5.0.4=jmh,jmhCompileClasspath,jmhRuntimeClasspath | ||
net.sf.saxon:Saxon-HE:11.4=spotbugs | ||
org.apache.ant:ant-antlr:1.10.12=jmhRuntimeClasspath,testRuntimeClasspath | ||
org.apache.ant:ant-antlr:1.9.15=codenarc | ||
org.apache.ant:ant-junit:1.10.12=jmhRuntimeClasspath,testRuntimeClasspath | ||
org.apache.ant:ant-junit:1.9.15=codenarc | ||
org.apache.ant:ant-launcher:1.10.12=jmhRuntimeClasspath,testRuntimeClasspath | ||
org.apache.ant:ant:1.10.12=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.apache.bcel:bcel:6.5.0=spotbugs | ||
org.apache.commons:commons-lang3:3.12.0=pitest,spotbugs | ||
org.apache.commons:commons-math3:3.2=jmh,jmhCompileClasspath,jmhRuntimeClasspath | ||
org.apache.commons:commons-text:1.10.0=pitest,spotbugs | ||
org.apache.httpcomponents.client5:httpclient5:5.1.3=spotbugs | ||
org.apache.httpcomponents.core5:httpcore5-h2:5.1.3=spotbugs | ||
org.apache.httpcomponents.core5:httpcore5:5.1.3=spotbugs | ||
org.apache.logging.log4j:log4j-api:2.19.0=spotbugs | ||
org.apache.logging.log4j:log4j-core:2.19.0=spotbugs | ||
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath | ||
org.codehaus.groovy:groovy-all:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-ant:2.5.14=codenarc | ||
org.codehaus.groovy:groovy-ant:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-astbuilder:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-cli-picocli:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-console:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-datetime:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-docgenerator:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-groovydoc:2.5.14=codenarc | ||
org.codehaus.groovy:groovy-groovydoc:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-groovysh:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-jmx:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-json:2.5.14=codenarc | ||
org.codehaus.groovy:groovy-json:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-jsr223:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-macro:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-nio:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-servlet:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-sql:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-swing:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-templates:2.5.14=codenarc | ||
org.codehaus.groovy:groovy-templates:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-test-junit5:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-test:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-testng:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy-xml:2.5.14=codenarc | ||
org.codehaus.groovy:groovy-xml:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codehaus.groovy:groovy:2.5.14=codenarc | ||
org.codehaus.groovy:groovy:3.0.17=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.codenarc:CodeNarc:2.2.0=codenarc | ||
org.dom4j:dom4j:2.1.3=spotbugs | ||
org.gmetrics:GMetrics:1.1=codenarc | ||
org.hamcrest:hamcrest-core:1.3=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.hamcrest:hamcrest:2.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.jacoco:org.jacoco.agent:0.8.5=jacocoAgent,jacocoAnt | ||
org.jacoco:org.jacoco.ant:0.8.5=jacocoAnt | ||
org.jacoco:org.jacoco.core:0.8.5=jacocoAnt | ||
org.jacoco:org.jacoco.report:0.8.5=jacocoAnt | ||
org.junit.jupiter:junit-jupiter-api:5.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.junit.jupiter:junit-jupiter-engine:5.9.2=jmhRuntimeClasspath,testRuntimeClasspath | ||
org.junit.jupiter:junit-jupiter-params:5.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.junit.jupiter:junit-jupiter:5.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.junit.platform:junit-platform-commons:1.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.junit.platform:junit-platform-engine:1.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.junit.platform:junit-platform-launcher:1.9.2=jmhRuntimeClasspath,testRuntimeClasspath | ||
org.junit:junit-bom:5.9.1=spotbugs | ||
org.junit:junit-bom:5.9.2=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.objenesis:objenesis:3.3=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.openjdk.jmh:jmh-core:1.36=jmh,jmhCompileClasspath,jmhRuntimeClasspath | ||
org.openjdk.jmh:jmh-generator-asm:1.36=jmh,jmhCompileClasspath,jmhRuntimeClasspath | ||
org.openjdk.jmh:jmh-generator-bytecode:1.36=jmh,jmhCompileClasspath,jmhRuntimeClasspath | ||
org.openjdk.jmh:jmh-generator-reflection:1.36=jmh,jmhCompileClasspath,jmhRuntimeClasspath | ||
org.opentest4j:opentest4j:1.2.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.ow2.asm:asm-analysis:7.2=jacocoAnt | ||
org.ow2.asm:asm-analysis:9.4=spotbugs | ||
org.ow2.asm:asm-commons:7.2=jacocoAnt | ||
org.ow2.asm:asm-commons:9.4=spotbugs | ||
org.ow2.asm:asm-tree:7.2=jacocoAnt | ||
org.ow2.asm:asm-tree:9.4=spotbugs | ||
org.ow2.asm:asm-util:9.4=spotbugs | ||
org.ow2.asm:asm:7.2=jacocoAnt | ||
org.ow2.asm:asm:9.0=jmh,jmhCompileClasspath,jmhRuntimeClasspath | ||
org.ow2.asm:asm:9.4=spotbugs | ||
org.pitest:pitest-command-line:1.9.11=pitest | ||
org.pitest:pitest-entry:1.9.11=pitest | ||
org.pitest:pitest:1.9.11=pitest | ||
org.slf4j:jcl-over-slf4j:1.7.30=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.slf4j:jul-to-slf4j:1.7.30=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.slf4j:log4j-over-slf4j:1.7.30=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.slf4j:slf4j-api:1.7.30=testCompileClasspath | ||
org.slf4j:slf4j-api:1.7.32=jmhRuntimeClasspath,testRuntimeClasspath | ||
org.slf4j:slf4j-api:2.0.0=spotbugs,spotbugsSlf4j | ||
org.slf4j:slf4j-simple:2.0.0=spotbugsSlf4j | ||
org.spockframework:spock-core:2.2-groovy-3.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.spockframework:spock-junit4:2.2-groovy-3.0=jmhRuntimeClasspath,testCompileClasspath,testRuntimeClasspath | ||
org.testng:testng:7.5=jmhRuntimeClasspath,testRuntimeClasspath | ||
org.webjars:jquery:3.5.1=jmhRuntimeClasspath,testRuntimeClasspath | ||
org.xmlresolver:xmlresolver:4.4.3=spotbugs | ||
xml-apis:xml-apis:1.4.01=spotbugs | ||
empty=annotationProcessor,jmhAnnotationProcessor,runtimeClasspath,spotbugsPlugins,testAnnotationProcessor |
106 changes: 106 additions & 0 deletions
106
components/json/src/jmh/java/datadog/json/JsonWriterBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package datadog.json; | ||
|
||
import static java.util.concurrent.TimeUnit.MICROSECONDS; | ||
import static org.openjdk.jmh.annotations.Mode.AverageTime; | ||
|
||
import org.openjdk.jmh.annotations.Benchmark; | ||
import org.openjdk.jmh.annotations.BenchmarkMode; | ||
import org.openjdk.jmh.annotations.Fork; | ||
import org.openjdk.jmh.annotations.OutputTimeUnit; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
@BenchmarkMode(AverageTime) | ||
@OutputTimeUnit(MICROSECONDS) | ||
@Fork(value = 1) | ||
@SuppressWarnings("unused") | ||
public class JsonWriterBenchmark { | ||
@Benchmark | ||
public void writeSimpleArray(Blackhole blackhole) { | ||
try (JsonWriter writer = new JsonWriter()) { | ||
writer | ||
.beginArray() | ||
.beginObject() | ||
.name("true") | ||
.value(true) | ||
.endObject() | ||
.beginObject() | ||
.name("false") | ||
.value(false) | ||
.endObject() | ||
.endArray(); | ||
blackhole.consume(writer.toString()); | ||
} | ||
} | ||
|
||
@Benchmark | ||
public void writeComplexArray(Blackhole blackhole) { | ||
try (JsonWriter writer = new JsonWriter()) { | ||
writer | ||
.beginArray() | ||
.value("first level") | ||
.beginArray() | ||
.value("second level") | ||
.beginArray() | ||
.value("third level") | ||
.beginObject() | ||
.name("key") | ||
.value("value") | ||
.endObject() | ||
.beginObject() | ||
.name("key") | ||
.value("value") | ||
.endObject() | ||
.endArray() // second level | ||
.beginObject() | ||
.name("key") | ||
.value("value") | ||
.endObject() | ||
.endArray() // first level | ||
.beginObject() | ||
.name("key") | ||
.value("value") | ||
.endObject() | ||
.value("last value") | ||
.endArray(); | ||
blackhole.consume(writer.toString()); | ||
} | ||
} | ||
|
||
@Benchmark | ||
public void writeComplexObject(Blackhole blackhole) { | ||
try (JsonWriter writer = new JsonWriter()) { | ||
writer | ||
.beginObject() | ||
.name("attrs") | ||
.beginObject() | ||
.name("attr1") | ||
.value("value1") | ||
.name("attr2") | ||
.value("value2") | ||
.endObject() | ||
.name("data") | ||
.beginArray() | ||
.beginObject() | ||
.name("x") | ||
.value(1) | ||
.name("y") | ||
.value(12.3) | ||
.endObject() | ||
.beginObject() | ||
.name("x") | ||
.value(2) | ||
.name("y") | ||
.value(4.56) | ||
.endObject() | ||
.beginObject() | ||
.name("x") | ||
.value(3) | ||
.name("y") | ||
.value(789) | ||
.endObject() | ||
.endArray() | ||
.endObject(); | ||
blackhole.consume(writer.toString()); | ||
} | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
components/json/src/main/java/datadog/json/JsonMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package datadog.json; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
|
||
/** Utility class for simple Java structure mapping into JSON strings. */ | ||
public final class JsonMapper { | ||
|
||
private JsonMapper() {} | ||
|
||
/** | ||
* Converts a {@link String} to a JSON string. | ||
* | ||
* @param string The string to convert. | ||
* @return The converted JSON string. | ||
*/ | ||
public static String toJson(String string) { | ||
if (string == null || string.isEmpty()) { | ||
return ""; | ||
} | ||
try (JsonWriter writer = new JsonWriter()) { | ||
writer.value(string); | ||
return writer.toString(); | ||
} | ||
} | ||
|
||
/** | ||
* Converts a {@link Map} to a JSON object. | ||
* | ||
* @param map The map to convert. | ||
* @return The converted JSON object as Java string. | ||
*/ | ||
public static String toJson(Map<String, ?> map) { | ||
if (map == null || map.isEmpty()) { | ||
return "{}"; | ||
} | ||
try (JsonWriter writer = new JsonWriter()) { | ||
writer.beginObject(); | ||
for (Map.Entry<String, ?> entry : map.entrySet()) { | ||
writer.name(entry.getKey()); | ||
Object value = entry.getValue(); | ||
if (value == null) { | ||
writer.nullValue(); | ||
} else if (value instanceof String) { | ||
writer.value((String) value); | ||
} else if (value instanceof Double) { | ||
writer.value((Double) value); | ||
} else if (value instanceof Float) { | ||
writer.value((Float) value); | ||
} else if (value instanceof Long) { | ||
writer.value((Long) value); | ||
} else if (value instanceof Integer) { | ||
writer.value((Integer) value); | ||
} else if (value instanceof Boolean) { | ||
writer.value((Boolean) value); | ||
} else { | ||
writer.value(value.toString()); | ||
} | ||
} | ||
writer.endObject(); | ||
return writer.toString(); | ||
} | ||
} | ||
|
||
/** | ||
* Converts a {@link Iterable<String>} to a JSON array. | ||
* | ||
* @param items The iterable to convert. | ||
* @return The converted JSON array as Java string. | ||
*/ | ||
@SuppressWarnings("DuplicatedCode") | ||
public static String toJson(Collection<String> items) { | ||
if (items == null || items.isEmpty()) { | ||
return "[]"; | ||
} | ||
try (JsonWriter writer = new JsonWriter()) { | ||
writer.beginArray(); | ||
for (String item : items) { | ||
writer.value(item); | ||
} | ||
writer.endArray(); | ||
return writer.toString(); | ||
} | ||
} | ||
|
||
/** | ||
* Converts a String array to a JSON array. | ||
* | ||
* @param items The array to convert. | ||
* @return The converted JSON array as Java string. | ||
*/ | ||
@SuppressWarnings("DuplicatedCode") | ||
public static String toJson(String[] items) { | ||
if (items == null) { | ||
return "[]"; | ||
} | ||
try (JsonWriter writer = new JsonWriter()) { | ||
writer.beginArray(); | ||
for (String item : items) { | ||
writer.value(item); | ||
} | ||
writer.endArray(); | ||
return writer.toString(); | ||
} | ||
} | ||
} |
Oops, something went wrong.