Skip to content

Commit 73d18ce

Browse files
authored
Merge pull request #890 from zhicwu/grpc-patch
Prepare patch release
2 parents 9140754 + 0e2b532 commit 73d18ce

File tree

119 files changed

+6305
-2028
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+6305
-2028
lines changed

.github/workflows/benchmark.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ jobs:
6060
run: |
6161
mvn --batch-mode --update-snapshots -q -DskipTests install
6262
cd clickhouse-benchmark
63-
java -DclickhouseVersion="21.8" -jar target/benchmarks.jar -rf text \
64-
-p client=clickhouse-http-jdbc1 -p client=clickhouse-grpc-jdbc -p type=object Basic
63+
java -DclickhouseVersion="22.3" -jar target/benchmarks.jar -rf text \
64+
-p client=clickhouse-http-jdbc -p client=clickhouse-grpc-jdbc -p type=object Basic
6565
echo "BENCHMARK_REPORT<<EOF" >> $GITHUB_ENV
6666
cat jmh-result.text >> $GITHUB_ENV
6767
echo "EOF" >> $GITHUB_ENV

.github/workflows/timezone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ jobs:
6464
mvn --batch-mode --update-snapshots \
6565
--projects clickhouse-jdbc \
6666
-DclickhouseTimezone=${{ matrix.serverTz }} \
67-
-DclickhouseVersion=21.8 \
67+
-DclickhouseVersion=22.3 \
6868
-Duser.timezone=${{ matrix.clientTz }} \
6969
--also-make clean verify

README.md

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,29 +21,32 @@ Note: in general, the new driver(v0.3.2) is a few times faster with less memory
2121

2222
## Features
2323

24-
| Category | Feature | Supported | Remark |
25-
| ------------- | ------------------------------------------------------------ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------- |
26-
| Protocol | [HTTP](https://clickhouse.com/docs/en/interfaces/http/) | :white_check_mark: | recommended, defaults to `java.net.HttpURLConnection` and can be changed to `java.net.http.HttpClient`(faster but less stable) |
27-
| | [gRPC](https://clickhouse.com/docs/en/interfaces/grpc/) | :white_check_mark: | experimental, still missing some features like LZ4 compression |
28-
| | [TCP/Native](https://clickhouse.com/docs/en/interfaces/tcp/) | :x: | will be available in 0.3.3 |
29-
| Compatibility | Server < 20.7 | :x: | use 0.3.1-patch(or 0.2.6 if you're stuck with JDK 7) |
30-
| | Server >= 20.7 | :white_check_mark: | use 0.3.2 or above. All [active releases](https://github.com/ClickHouse/ClickHouse/pulls?q=is%3Aopen+is%3Apr+label%3Arelease) are supported. |
31-
| Data Type | AggregatedFunction | :x: | limited to `groupBitmap` |
32-
| | Array(\*) | :white_check_mark: | |
33-
| | Date\* | :white_check_mark: | |
34-
| | DateTime\* | :white_check_mark: | |
35-
| | Decimal\* | :white_check_mark: | `SET output_format_decimal_trailing_zeros=1` in 21.9+ for consistency |
36-
| | Enum\* | :white_check_mark: | can be treated as both string and integer |
37-
| | Geo Types | :white_check_mark: | |
38-
| | Int\*, UInt\* | :white_check_mark: | UInt64 is mapped to `long` |
39-
| | IPv\* | :white_check_mark: | |
40-
| | \*String | :white_check_mark: | |
41-
| | Map(\*) | :white_check_mark: | |
42-
| | Nested(\*) | :white_check_mark: | |
43-
| | Tuple(\*) | :white_check_mark: | |
44-
| | UUID | :white_check_mark: | |
45-
| Format | RowBinary | :white_check_mark: | `RowBinaryWithNamesAndTypes` for query and `RowBinary` for insertion |
46-
| | TabSeparated | :white_check_mark: | Does not support as many data types as RowBinary |
24+
| Category | Feature | Supported | Remark |
25+
| ------------- | ------------------------------------------------------------ | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
26+
| Protocol | [HTTP](https://clickhouse.com/docs/en/interfaces/http/) | :white_check_mark: | recommended, defaults to `java.net.HttpURLConnection` and can be changed to `java.net.http.HttpClient`(faster but less stable) |
27+
| | [gRPC](https://clickhouse.com/docs/en/interfaces/grpc/) | :white_check_mark: | still experimental, known to has [issue](https://github.com/ClickHouse/ClickHouse/issues/28671#issuecomment-1087049993) when using LZ4 compression |
28+
| | [TCP/Native](https://clickhouse.com/docs/en/interfaces/tcp/) | :x: | will be available in 0.3.3 |
29+
| Compatibility | Server < 20.7 | :x: | use 0.3.1-patch(or 0.2.6 if you're stuck with JDK 7) |
30+
| | Server >= 20.7 | :white_check_mark: | use 0.3.2 or above. All [active releases](https://github.com/ClickHouse/ClickHouse/pulls?q=is%3Aopen+is%3Apr+label%3Arelease) are supported. |
31+
| Data Type | AggregatedFunction | :x: | limited to `groupBitmap` |
32+
| | Array(\*) | :white_check_mark: | |
33+
| | Bool | :white_check_mark: | |
34+
| | Date\* | :white_check_mark: | |
35+
| | DateTime\* | :white_check_mark: | |
36+
| | Decimal\* | :white_check_mark: | `SET output_format_decimal_trailing_zeros=1` in 21.9+ for consistency |
37+
| | Enum\* | :white_check_mark: | can be treated as both string and integer |
38+
| | Geo Types | :white_check_mark: | Point, Ring, Polygon, and MultiPolygon |
39+
| | Int\*, UInt\* | :white_check_mark: | UInt64 is mapped to `long` |
40+
| | IPv\* | :white_check_mark: | |
41+
| | Map(\*) | :white_check_mark: | |
42+
| | Nested(\*) | :white_check_mark: | |
43+
| | Object('JSON') | :white_check_mark: | |
44+
| | SimpleAggregateFunction | :white_check_mark: | |
45+
| | \*String | :white_check_mark: | |
46+
| | Tuple(\*) | :white_check_mark: | |
47+
| | UUID | :white_check_mark: | |
48+
| Format | RowBinary | :white_check_mark: | `RowBinaryWithNamesAndTypes` for query and `RowBinary` for insertion |
49+
| | TabSeparated | :white_check_mark: | Does not support as many data types as RowBinary |
4750

4851
## Configuration
4952

@@ -112,7 +115,7 @@ Note: in general, the new driver(v0.3.2) is a few times faster with less memory
112115
<groupId>com.clickhouse</groupId>
113116
<!-- or clickhouse-grpc-client if you prefer gRPC -->
114117
<artifactId>clickhouse-http-client</artifactId>
115-
<version>0.3.3</version>
118+
<version>0.3.2-patch8</version>
116119
</dependency>
117120
```
118121

@@ -129,11 +132,11 @@ try (ClickHouseClient client = ClickHouseClient.newInstance(preferredProtocol);
129132
ClickHouseResponse response = client.connect(server)
130133
.format(preferredFormat)
131134
.query("select * from numbers(:limit)")
132-
.params(1000).execute().get()) {
135+
.params(1000).executeAndWait()) {
133136
// or resp.stream() if you prefer stream API
134-
for (ClickHouseRecord record : response.records()) {
135-
int num = record.getValue(0).asInteger();
136-
String str = record.getValue(0).asString();
137+
for (ClickHouseRecord r : response.records()) {
138+
int num = r.getValue(0).asInteger();
139+
String str = r.getValue(0).asString();
137140
}
138141

139142
ClickHouseResponseSummary summary = response.getSummary();
@@ -148,7 +151,7 @@ try (ClickHouseClient client = ClickHouseClient.newInstance(preferredProtocol);
148151
<!-- will stop using ru.yandex.clickhouse starting from 0.4.0 -->
149152
<groupId>com.clickhouse</groupId>
150153
<artifactId>clickhouse-jdbc</artifactId>
151-
<version>0.3.3</version>
154+
<version>0.3.2-patch8</version>
152155
<!-- below is only needed when all you want is a shaded jar -->
153156
<classifier>http</classifier>
154157
<exclusions>
@@ -209,7 +212,7 @@ cd clickhouse-benchmark
209212
mvn -Drelease clean package
210213
# single thread mode
211214
java -DdbHost=localhost -jar target/benchmarks.jar -t 1 \
212-
-p client=clickhouse-http-jdbc1 -p connection=reuse \
215+
-p client=clickhouse-jdbc -p connection=reuse \
213216
-p statement=prepared Query.selectInt8
214217
```
215218

@@ -225,6 +228,7 @@ In the case you prefer to test against an existing server, please follow instruc
225228
- add below two configuration files to the existing server and expose all ports for external access
226229
- [ports.xml](../../blob/master/clickhouse-client/src/test/resources/containers/clickhouse-server/config.d/ports.xml) - enable all ports
227230
- and [users.xml](../../blob/master/clickhouse-client/src/test/resources/containers/clickhouse-server/users.d/users.xml) - accounts used for integration test
231+
Note: you may need to change root element from `clickhouse` to `yandex` when testing old version of ClickHouse.
228232
- put `test.properties` under either `~/.clickhouse` or `src/test/resources` of your project, with content like below:
229233
```properties
230234
clickhouseServer=x.x.x.x

clickhouse-benchmark/src/main/java/com/clickhouse/benchmark/BaseState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public BaseState() {
3232
}
3333

3434
protected int getRandomNumber(int bound) {
35-
return random.nextInt(bound);
35+
return bound < 1 ? 0 : random.nextInt(bound);
3636
}
3737

3838
protected void consume(Blackhole blackhole, Callable<?> task) throws InterruptedException {

clickhouse-benchmark/src/main/java/com/clickhouse/benchmark/ServerState.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ public void doSetup() throws Exception {
7373
imageTag = ":" + imageTag;
7474
}
7575

76-
final String imageNameWithTag = "yandex/clickhouse-server" + imageTag;
76+
final String imageNameWithTag = "clickhouse/clickhouse-server" + imageTag;
7777

7878
container = new GenericContainer<>(new ImageFromDockerfile().withDockerfileFromBuilder(builder -> builder
7979
.from(imageNameWithTag)
80-
.run("echo '<yandex><listen_host>0.0.0.0</listen_host><http_port>8123</http_port>"
80+
.run("echo '<clickhouse><listen_host>0.0.0.0</listen_host><http_port>8123</http_port>"
8181
+ "<tcp_port>9000</tcp_port><mysql_port>9004</mysql_port>"
8282
+ "<postgresql_port>9005</postgresql_port>"
8383
+ "<interserver_http_port>9009</interserver_http_port>"
84-
+ "<grpc_port>9100</grpc_port></yandex>' > /etc/clickhouse-server/config.d/custom.xml")))
84+
+ "<grpc_port>9100</grpc_port></clickhouse>' > /etc/clickhouse-server/config.d/custom.xml")))
8585
.withExposedPorts(Constants.GRPC_PORT, Constants.HTTP_PORT, Constants.MYSQL_PORT,
8686

8787
Constants.NATIVE_PORT)

clickhouse-benchmark/src/main/java/com/clickhouse/benchmark/client/ClientState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private ClickHouseClient createClient() {
5757

5858
ClickHouseClientBuilder builder = ClickHouseClient.builder();
5959
if (bufferSize != null && !bufferSize.isEmpty()) {
60-
builder.option(ClickHouseClientOption.MAX_BUFFER_SIZE, Integer.parseInt(bufferSize));
60+
builder.option(ClickHouseClientOption.BUFFER_SIZE, Integer.parseInt(bufferSize));
6161
}
6262
if (compression != null && !compression.isEmpty()) {
6363
// builder.option(ClickHouseClientOption.COMPRESSION,

clickhouse-benchmark/src/main/java/com/clickhouse/benchmark/jdbc/DriverState.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.sql.SQLException;
66
import java.sql.Statement;
77
import java.util.Properties;
8-
import java.util.UUID;
98

109
import org.openjdk.jmh.annotations.Level;
1110
import org.openjdk.jmh.annotations.Param;
@@ -20,7 +19,7 @@
2019

2120
@State(Scope.Thread)
2221
public class DriverState extends BaseState {
23-
@Param(value = { "clickhouse4j", "clickhouse-http-jdbc", "clickhouse-grpc-jdbc", "clickhouse-jdbc",
22+
@Param(value = { "clickhouse-jdbc", "clickhouse-grpc-jdbc", "clickhouse-legacy-jdbc", "clickhouse4j",
2423
"clickhouse-native-jdbc", "mariadb-java-client", "mysql-connector-java", "postgresql-jdbc" })
2524
private String client;
2625

@@ -54,7 +53,11 @@ public void doSetup(ServerState serverState) throws Exception {
5453
serverState.getPassword(), compression, additional);
5554
// ClickHouseDefines.WRITE_COMPRESS = false;
5655
// ClickHouseDefines.READ_DECOMPRESS = Boolean.parseBoolean(compression);
57-
conn = driver.connect(url, new Properties());
56+
Properties props = new Properties();
57+
if (jdbcDriver.getClassName().startsWith("com.clickhouse.jdbc.")) {
58+
props.setProperty("format", System.getProperty("format", "RowBinaryWithNamesAndTypes"));
59+
}
60+
conn = driver.connect(url, props);
5861

5962
try (Statement s = conn.createStatement()) {
6063
// s.execute("drop table if exists system.test_insert");

0 commit comments

Comments
 (0)