Skip to content

Commit 6ce0d38

Browse files
authored
Merge pull request #1250 from zhicwu/main
Update build instructions
2 parents 4a6940b + f979f2f commit 6ce0d38

File tree

1 file changed

+46
-11
lines changed

1 file changed

+46
-11
lines changed

README.md

+46-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Java libraries for connecting to ClickHouse and processing data in various forma
2525
| | [zstd](https://facebook.github.io/zstd/) | :white_check_mark: | supported since 0.4.0, works with ClickHouse 22.10+ |
2626
| Data Format | RowBinary | :white_check_mark: | `RowBinaryWithNamesAndTypes` for query and `RowBinary` for insertion |
2727
| | TabSeparated | :white_check_mark: | :warning: does not support as many data types as RowBinary |
28-
| Data Type | AggregatedFunction | :x: | :warning: limited to `groupBitmap`; 64bit bitmap was NOT working properly before 0.4.1 |
28+
| Data Type | AggregateFunction | :x: | :warning: limited to `groupBitmap`; 64bit bitmap was NOT working properly before 0.4.1 |
2929
| | Array(\*) | :white_check_mark: | |
3030
| | Bool | :white_check_mark: | |
3131
| | Date\* | :white_check_mark: | |
@@ -133,20 +133,11 @@ More examples can be found at [here](../../tree/main/examples/jdbc).
133133

134134
## Build with Maven
135135

136-
Use `mvn -Dj8 -DskipITs clean verify` to compile and generate packages if you're using JDK 8. To create a multi-release jar (see [JEP-238](https://openjdk.java.net/jeps/238)), please use JDK 11+ with `~/.m2/toolchains.xml` like below, and run `mvn -DskipITs clean verify` instead.
136+
Use `mvn -Dj8 -DskipITs clean verify` to compile and generate packages if you're using JDK 8. To create a multi-release jar (see [JEP-238](https://openjdk.java.net/jeps/238)), please use JDK 17+ with `~/.m2/toolchains.xml` like below, and run `mvn -DskipITs clean verify` instead.
137137

138138
```xml
139139
<?xml version="1.0" encoding="UTF8"?>
140140
<toolchains>
141-
<toolchain>
142-
<type>jdk</type>
143-
<provides>
144-
<version>11</version>
145-
</provides>
146-
<configuration>
147-
<jdkHome>/usr/lib/jvm/java-11-openjdk</jdkHome>
148-
</configuration>
149-
</toolchain>
150141
<toolchain>
151142
<type>jdk</type>
152143
<provides>
@@ -159,6 +150,50 @@ Use `mvn -Dj8 -DskipITs clean verify` to compile and generate packages if you're
159150
</toolchains>
160151
```
161152

153+
To create a native binary of JDBC driver for evaluation and testing:
154+
155+
- [install GraalVM](https://www.graalvm.org/latest/docs/getting-started/) and optionally [upx](https://upx.github.io/)
156+
157+
- make sure you have [native-image](https://www.graalvm.org/latest/docs/getting-started/#native-image) installed, and then build the native binary
158+
159+
```bash
160+
cd clickhouse-java
161+
mvn -DskipTests clean install
162+
cd clickhouse-jdbc
163+
mvn -DskipTests -Pnative clean package
164+
# only if you have upx installed
165+
upx -7 -k target/clickhouse-jdbc-bin
166+
```
167+
168+
- run native binary
169+
170+
```bash
171+
# print usage
172+
./target/clickhouse-jdbc-bin
173+
Usage: clickhouse-jdbc-bin [PROPERTIES] <URL> [QUERY] [FILE]
174+
...
175+
176+
# test database connection using JDBC driver
177+
./target/clickhouse-jdbc-bin -Dverbose=true 'jdbc:ch:http://localhost'
178+
Arguments:
179+
- url=jdbc:ch:http://localhost
180+
- query=select 500000000
181+
- file=jdbc.out
182+
183+
Options: action=read, batch=1000, samples=500000000, serde=true, type=, verbose=true
184+
Processed 1 rows in 85.56 ms (11.69 rows/s)
185+
186+
# test query performance using Java client
187+
./target/clickhouse-jdbc-bin -Dverbose=true -Dtype=uint64 'http://localhost'
188+
...
189+
Processed 500,000,000 rows in 52,491.38 ms (9,525,373.89 rows/s)
190+
191+
# test same query again using JVM for comparison - don't have GraalVM EE so JIT wins in my case
192+
java -Dverbose=true -Dtype=uint64 -jar target/clickhouse-jdbc-*-http.jar 'http://localhost'
193+
...
194+
Processed 500,000,000 rows in 25,267.89 ms (19,787,963.94 rows/s)
195+
```
196+
162197
## Testing
163198

164199
By default, [docker](https://docs.docker.com/engine/install/) is required to run integration test. Docker image(defaults to `clickhouse/clickhouse-server`) will be pulled from Internet, and containers will be created automatically by [testcontainers](https://www.testcontainers.org/) before testing. To test against specific version of ClickHouse, you can pass parameter like `-DclickhouseVersion=22.8` to Maven.

0 commit comments

Comments
 (0)