Skip to content

Commit b8379c2

Browse files
committed
Updated query tests to use blackhole.
1 parent 663ad50 commit b8379c2

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

client-v2/src/main/java/com/clickhouse/client/api/data_formats/internal/BinaryStreamReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ public <T> T readValue(ClickHouseColumn column, Class<?> typeHint) throws IOExce
127127
case UInt8:
128128
return (T) Short.valueOf(readUnsignedByte());
129129
case Int16:
130-
return (T) Short.valueOf(readShortLE());
130+
return (T) (Short)readShortLE();
131131
case UInt16:
132-
return (T) Integer.valueOf(readUnsignedShortLE());
132+
return (T) (Integer)readUnsignedShortLE();
133133
case Int32:
134-
return (T) Integer.valueOf(readIntLE());
134+
return (T) (Integer)readIntLE();
135135
case UInt32:
136136
return (T) (Long)(readUnsignedIntLE());
137137
case Int64:

client-v2/src/main/java/com/clickhouse/client/api/internal/ClickHouseLZ4InputStream.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ private boolean readFully(byte[] b, int off, int len) throws IOException {
9090
return true;
9191
}
9292

93+
private byte[] cachedBuff = null;
94+
9395
private int refill() throws IOException {
9496

9597
// read header
@@ -109,7 +111,9 @@ private int refill() throws IOException {
109111
int uncompressedSize = getInt32(headerBuff, 21);
110112

111113
int offset = 9;
112-
final byte[] block = new byte[compressedSizeWithHeader];
114+
final byte[] block = cachedBuff == null || cachedBuff.length <= uncompressedSize ?
115+
new byte[compressedSizeWithHeader] : cachedBuff;
116+
cachedBuff = block;
113117
block[0] = MAGIC;
114118
setInt32(block, 1, compressedSizeWithHeader);
115119
setInt32(block, 5, uncompressedSize);

performance/src/test/com/clickhouse/benchmark/BenchmarkRunner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public static void main(String[] args) throws Exception {
4747
// .addProfiler(JavaFlightRecorderProfiler.class)
4848
.warmupIterations(0)
4949
.warmupTime(TimeValue.seconds(10))
50-
.measurementIterations(10)
50+
.measurementIterations(1)
5151
.jvmArgs("-Xms8g", "-Xmx8g")
52-
.measurementTime(TimeValue.seconds(isCloud() ? 30 : 10))
52+
.measurementTime(TimeValue.seconds(isCloud() ? 30 : 120))
5353
.resultFormat(ResultFormatType.JSON)
5454
// .output(String.format("jmh-results-%s-%s.out", isCloud() ? "cloud" : "local", System.currentTimeMillis()))
5555
.result(String.format("jmh-results-%s-%s.json", isCloud() ? "cloud" : "local", System.currentTimeMillis()))

performance/src/test/com/clickhouse/benchmark/clients/QueryClient.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class QueryClient extends BenchmarkBase {
2121
private static final Logger LOGGER = LoggerFactory.getLogger(QueryClient.class);
2222

2323
@Benchmark
24-
public void queryV1(DataState dataState) {
24+
public void queryV1(DataState dataState, Blackhole blackhole) {
2525
try {
2626
try (ClickHouseResponse response = clientV1.read(getServer())
2727
.query(BenchmarkRunner.getSelectQuery(dataState.tableNameFilled))
@@ -30,7 +30,7 @@ public void queryV1(DataState dataState) {
3030
.executeAndWait()) {
3131
for (ClickHouseRecord record: response.records()) {//Compiler optimization avoidance
3232
for (int i = 0; i < dataState.dataSet.getSchema().getColumns().size(); i++) {
33-
isNotNull(record.getValue(i), false);
33+
blackhole.consume(record.getValue(i).asObject());
3434
}
3535
}
3636
}
@@ -46,7 +46,7 @@ public void queryV2(DataState dataState, Blackhole blackhole) {
4646
ClickHouseBinaryFormatReader reader = clientV2.newBinaryFormatReader(response);
4747
while (reader.next() != null) {//Compiler optimization avoidance
4848
for (int i = 1; i <= dataState.dataSet.getSchema().getColumns().size(); i++) {
49-
isNotNull(reader.readValue(1), false);
49+
blackhole.consume(reader.readValue(1));
5050
}
5151
}
5252
}

0 commit comments

Comments
 (0)