Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clickhouse-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<version>1.18.38</version>
</path>
<path>
<groupId>org.openjdk.jmh</groupId>
Expand Down
2 changes: 1 addition & 1 deletion client-v2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<version>1.18.38</version>
</path>
</annotationProcessorPaths>
<release>8</release>
Expand Down
4 changes: 2 additions & 2 deletions examples/client-v2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<version>1.18.38</version>
<scope>provided</scope>
</dependency>

Expand Down Expand Up @@ -148,7 +148,7 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<version>1.18.38</version>
</path>
</annotationProcessorPaths>
</configuration>
Expand Down
2 changes: 1 addition & 1 deletion performance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<version>1.18.38</version>
</path>
<path>
<groupId>org.openjdk.jmh</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@
import com.clickhouse.client.api.data_formats.ClickHouseBinaryFormatReader;
import com.clickhouse.client.api.query.QueryResponse;
import com.clickhouse.client.config.ClickHouseClientOption;
import com.clickhouse.data.ClickHouseColumn;
import com.clickhouse.data.ClickHouseFormat;
import com.clickhouse.data.ClickHouseRecord;
import com.clickhouse.data.ClickHouseValue;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

import static com.clickhouse.benchmark.TestEnvironment.getServer;

@State(Scope.Benchmark)
Expand Down Expand Up @@ -45,12 +49,55 @@ public void queryV2(DataState dataState, Blackhole blackhole) {
ClickHouseBinaryFormatReader reader = clientV2.newBinaryFormatReader(response);
while (reader.next() != null) {//Compiler optimization avoidance
for (int i = 1; i <= dataState.dataSet.getSchema().getColumns().size(); i++) {
blackhole.consume(reader.readValue(1));
blackhole.consume(reader.readValue(i));
}
}
}
} catch (Exception e) {
LOGGER.error("Error: ", e);
}
}

@Benchmark
public void queryV1WithTypes(DataState dataState, Blackhole blackhole) throws Exception {
try (ClickHouseResponse response = clientV1.read(getServer())
.query(BenchmarkBase.getSelectQuery(dataState.tableNameFilled))
.format(ClickHouseFormat.RowBinaryWithNamesAndTypes)
.option(ClickHouseClientOption.ASYNC, false)
.executeAndWait()) {
List<ClickHouseColumn> columns = dataState.dataSet.getSchema().getColumns();
for (ClickHouseRecord record: response.records()) {//Compiler optimization avoidance
for (int i = 0; i < columns.size(); i++) {
ClickHouseValue value = record.getValue(i);
ClickHouseColumn column = columns.get(i);
switch (column.getDataType()) {
case Int64: blackhole.consume(value.asLong()); break;
case Float64: blackhole.consume(value.asDouble()); break;
case String: blackhole.consume(value.asString()); break;
default: throw new IllegalStateException();
}
}
}
}
}

@Benchmark
public void queryV2WithTypes(DataState dataState, Blackhole blackhole) throws Exception {
try(QueryResponse response = clientV2.query(BenchmarkBase.getSelectQuery(dataState.tableNameFilled)).get()) {
ClickHouseBinaryFormatReader reader = clientV2.newBinaryFormatReader(response);
List<ClickHouseColumn> columns = dataState.dataSet.getSchema().getColumns();
while (reader.next() != null) {//Compiler optimization avoidance
for (int i = 1; i <= columns.size(); i++) {
blackhole.consume(reader.readValue(i));
ClickHouseColumn column = columns.get(i - 1);
switch (column.getDataType()) {
case Int64: blackhole.consume(reader.getLong(i)); break;
case Float64: blackhole.consume(reader.getDouble(i)); break;
case String: blackhole.consume(reader.getString(i)); break;
default: throw new IllegalStateException();
}
}
}
}
}
}
Loading