Skip to content

Commit 95b4807

Browse files
authored
Merge pull request #829 from zhicwu/patch4-release
Prepare 0.3.2-patch4 release
2 parents 1f83b42 + cd2dc12 commit 95b4807

46 files changed

Lines changed: 1668 additions & 1010 deletions

File tree

Some content is hidden

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

.github/workflows/benchmark.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ on:
44
pull_request_target:
55
branches:
66
- master
7-
- develop
87
types:
98
- opened
109
- synchronize

.github/workflows/build.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,14 @@ jobs:
3434
matrix:
3535
# most recent LTS releases as well as latest stable builds
3636
clickhouse: ["21.3", "21.8", "latest"]
37+
protocol: ["http", "grpc"]
38+
exclude:
39+
- clickhouse: "21.3"
40+
protocol: grpc
41+
- clickhouse: "21.8"
42+
protocol: grpc
3743
fail-fast: false
38-
name: Build against ClickHouse ${{ matrix.clickhouse }}
44+
name: Build against ClickHouse ${{ matrix.clickhouse }} (${{ matrix.protocol }})
3945
steps:
4046
- name: Check out Git repository
4147
uses: actions/checkout@v2
@@ -82,4 +88,4 @@ jobs:
8288
${{ runner.os }}-build-
8389
- name: Build
8490
run: |
85-
mvn --batch-mode --update-snapshots -Drelease -DclickhouseVersion=${{ matrix.clickhouse }} verify
91+
mvn --batch-mode --update-snapshots -Drelease -DclickhouseVersion=${{ matrix.clickhouse }} -Dprotocol=${{ matrix.protocol }} verify

.github/workflows/timezone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
serverTz: ["Asia/Chongqing", "America/Los_Angeles", "Etc/UTC", "Europe/Berlin", "Europe/Moscow"]
3535
clientTz: ["Asia/Chongqing", "America/Los_Angeles", "Etc/UTC", "Europe/Berlin", "Europe/Moscow"]
3636
fail-fast: false
37-
name: "Test TimeZones - Server: ${{ matrix.serverTz }}, Client: ${{ matrix.clientTz }}"
37+
name: "TimeZone(C/S): ${{ matrix.clientTz }} vs. ${{ matrix.serverTz }}"
3838
steps:
3939
- name: Check out Git repository
4040
uses: actions/checkout@v2

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Java 8 or higher is required in order to use Java client([clickhouse-client](htt
9999
<groupId>com.clickhouse</groupId>
100100
<!-- or clickhouse-grpc-client if you prefer gRPC -->
101101
<artifactId>clickhouse-http-client</artifactId>
102-
<version>0.3.2-patch3</version>
102+
<version>0.3.2-patch4</version>
103103
</dependency>
104104
```
105105

@@ -135,7 +135,7 @@ try (ClickHouseClient client = ClickHouseClient.newInstance(preferredProtocol);
135135
<!-- will stop using ru.yandex.clickhouse starting from 0.4.0 -->
136136
<groupId>com.clickhouse</groupId>
137137
<artifactId>clickhouse-jdbc</artifactId>
138-
<version>0.3.2-patch3</version>
138+
<version>0.3.2-patch4</version>
139139
<!-- below is only needed when all you want is a shaded jar -->
140140
<classifier>http</classifier>
141141
<exclusions>

clickhouse-benchmark/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
<properties>
1919
<clickhouse4j-driver.version>1.4.4</clickhouse4j-driver.version>
20-
<native-driver.version>2.6.3</native-driver.version>
20+
<native-driver.version>2.6.4</native-driver.version>
2121
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
22-
<jmh.version>1.33</jmh.version>
22+
<jmh.version>1.34</jmh.version>
2323
<shade.name>benchmarks</shade.name>
2424
</properties>
2525

clickhouse-client/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Async Java client for ClickHouse. `clickhouse-client` is an abstract module, so
99
<dependency>
1010
<groupId>com.clickhouse</groupId>
1111
<artifactId>clickhouse-http-client</artifactId>
12-
<version>0.3.2-patch3</version>
12+
<version>0.3.2-patch4</version>
1313
</dependency>
1414
```
1515

clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseClient.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ static <T> CompletableFuture<T> submit(Callable<T> task) {
7676
return (boolean) ClickHouseDefaults.ASYNC.getEffectiveDefaultValue() ? CompletableFuture.supplyAsync(() -> {
7777
try {
7878
return task.call();
79+
} catch (ClickHouseException e) {
80+
throw new CompletionException(e);
7981
} catch (CompletionException e) {
8082
throw e;
8183
} catch (Exception e) {
@@ -88,6 +90,8 @@ static <T> CompletableFuture<T> submit(Callable<T> task) {
8890
throw new CompletionException(cause);
8991
}
9092
}, getExecutorService()) : CompletableFuture.completedFuture(task.call());
93+
} catch (ClickHouseException e) {
94+
throw new CompletionException(e);
9195
} catch (CompletionException e) {
9296
throw e;
9397
} catch (Exception e) {
@@ -463,17 +467,17 @@ static CompletableFuture<List<ClickHouseResponseSummary>> send(ClickHouseNode se
463467
*/
464468
static CompletableFuture<List<ClickHouseResponseSummary>> send(ClickHouseNode server, String sql,
465469
ClickHouseValue[] templates, Object[]... params) {
466-
int len = templates == null ? 0 : templates.length;
467-
int size = params == null ? 0 : params.length;
468-
if (templates == null || templates.length == 0 || params == null || params.length == 0) {
470+
int len = templates != null ? templates.length : 0;
471+
int size = params != null ? params.length : 0;
472+
if (len == 0 || size == 0) {
469473
throw new IllegalArgumentException("Non-empty templates and parameters are required");
470474
}
471475

472476
// in case the protocol is ANY
473477
final ClickHouseNode theServer = ClickHouseCluster.probe(server);
474478

475479
return submit(() -> {
476-
List<ClickHouseResponseSummary> list = new ArrayList<>(params.length);
480+
List<ClickHouseResponseSummary> list = new ArrayList<>(size);
477481

478482
// set async to false so that we don't have to create additional thread
479483
try (ClickHouseClient client = ClickHouseClient.builder()
@@ -484,13 +488,13 @@ static CompletableFuture<List<ClickHouseResponseSummary>> send(ClickHouseNode se
484488
for (int i = 0; i < size; i++) {
485489
Object[] o = params[i];
486490
String[] arr = new String[len];
487-
for (int j = 0, slen = o == null ? 0 : o.length; j < slen; j++) {
488-
if (j < len) {
489-
arr[j] = ClickHouseValues.NULL_EXPR;
490-
} else {
491-
ClickHouseValue v = templates[j];
491+
for (int j = 0, olen = o == null ? 0 : o.length; j < len; j++) {
492+
ClickHouseValue v = templates[j];
493+
if (j < olen) {
492494
arr[j] = v != null ? v.update(o[j]).toSqlExpression()
493495
: ClickHouseValues.convertToSqlExpression(o[j]);
496+
} else {
497+
arr[j] = v != null ? v.resetToNullOrEmpty().toSqlExpression() : ClickHouseValues.NULL_EXPR;
494498
}
495499
}
496500
try (ClickHouseResponse resp = request.params(arr).execute().get()) {

clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseCluster.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.io.Serializable;
66
import java.net.InetSocketAddress;
77
import java.net.Socket;
8+
import java.nio.charset.StandardCharsets;
89
import java.util.ArrayList;
910
import java.util.Arrays;
1011
import java.util.Collection;
@@ -176,7 +177,7 @@ public static ClickHouseNode probe(ClickHouseNode node, int timeout) {
176177
client.connect(address, timeout);
177178
client.setSoTimeout(timeout);
178179
OutputStream out = client.getOutputStream();
179-
out.write("GET /ping HTTP/1.1\r\n\r\n".getBytes());
180+
out.write("GET /ping HTTP/1.1\r\n\r\n".getBytes(StandardCharsets.US_ASCII));
180181
out.flush();
181182
byte[] buf = new byte[12]; // HTTP/1.x xxx
182183
if (client.getInputStream().read(buf) == buf.length) {

clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ public SelfT use(String database) {
12131213
checkSealed();
12141214

12151215
Object oldValue = options.put(ClickHouseClientOption.DATABASE,
1216-
ClickHouseChecker.nonBlank(database, "database"));
1216+
ClickHouseChecker.nonNull(database, "database"));
12171217
if (oldValue == null || !oldValue.equals(database)) {
12181218
resetCache();
12191219
}

clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseUtils.java

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.util.concurrent.LinkedBlockingQueue;
3131
import java.util.concurrent.TimeUnit;
3232
import java.util.concurrent.ThreadPoolExecutor;
33+
import java.util.function.Consumer;
3334
import java.util.function.Supplier;
3435
import java.util.function.UnaryOperator;
3536

@@ -1066,6 +1067,91 @@ public static int readEnumValues(String args, int startIndex, int len, Map<Strin
10661067
return len;
10671068
}
10681069

1070+
public static List<String> readValueArray(String args, int startIndex, int len) {
1071+
List<String> list = new LinkedList<>();
1072+
readValueArray(args, startIndex, len, list::add);
1073+
return list.isEmpty() ? Collections.emptyList() : Collections.unmodifiableList(list);
1074+
}
1075+
1076+
public static int readValueArray(String args, int startIndex, int len, Consumer<String> func) {
1077+
char closeBracket = ']';
1078+
StringBuilder builder = new StringBuilder();
1079+
for (int i = startIndex; i < len; i++) {
1080+
char ch = args.charAt(i);
1081+
if (ch == '[') {
1082+
startIndex = i + 1;
1083+
break;
1084+
} else if (Character.isWhitespace(ch)) {
1085+
continue;
1086+
} else if (i + 1 < len) {
1087+
char nextCh = args.charAt(i + 1);
1088+
if (ch == '-' && nextCh == '-') {
1089+
i = skipSingleLineComment(args, i + 2, len) - 1;
1090+
} else if (ch == '/' && nextCh == '*') {
1091+
i = skipMultiLineComment(args, i + 2, len) - 1;
1092+
} else {
1093+
startIndex = i;
1094+
break;
1095+
}
1096+
} else {
1097+
startIndex = i;
1098+
break;
1099+
}
1100+
}
1101+
1102+
boolean hasNext = false;
1103+
for (int i = startIndex; i < len; i++) {
1104+
char ch = args.charAt(i);
1105+
if (Character.isWhitespace(ch)) {
1106+
continue;
1107+
} else if (ch == '\'') { // string
1108+
hasNext = false;
1109+
int endIndex = readNameOrQuotedString(args, i, len, builder);
1110+
func.accept(unescape(args.substring(i, endIndex)));
1111+
builder.setLength(0);
1112+
i = endIndex + 1;
1113+
} else if (ch == '[') { // array
1114+
hasNext = false;
1115+
int endIndex = skipContentsUntil(args, i + 1, len, ']');
1116+
func.accept(args.substring(i, endIndex));
1117+
builder.setLength(0);
1118+
i = endIndex;
1119+
} else if (ch == '(') { // tuple
1120+
hasNext = false;
1121+
int endIndex = skipContentsUntil(args, i + 1, len, ')');
1122+
func.accept(args.substring(i, endIndex));
1123+
builder.setLength(0);
1124+
i = endIndex;
1125+
} else if (ch == closeBracket) {
1126+
len = i + 1;
1127+
break;
1128+
} else if (ch == ',') {
1129+
hasNext = true;
1130+
String str = builder.toString();
1131+
func.accept(str.isEmpty() || ClickHouseValues.NULL_EXPR.equalsIgnoreCase(str) ? null : str);
1132+
builder.setLength(0);
1133+
} else if (i + 1 < len) {
1134+
char nextCh = args.charAt(i + 1);
1135+
if (ch == '-' && nextCh == '-') {
1136+
i = skipSingleLineComment(args, i + 2, len) - 1;
1137+
} else if (ch == '/' && nextCh == '*') {
1138+
i = skipMultiLineComment(args, i + 2, len) - 1;
1139+
} else {
1140+
builder.append(ch);
1141+
}
1142+
} else {
1143+
builder.append(ch);
1144+
}
1145+
}
1146+
1147+
if (hasNext || builder.length() > 0) {
1148+
String str = builder.toString();
1149+
func.accept(str.isEmpty() || ClickHouseValues.NULL_EXPR.equalsIgnoreCase(str) ? null : str);
1150+
}
1151+
1152+
return len;
1153+
}
1154+
10691155
public static int readParameters(String args, int startIndex, int len, List<String> params) {
10701156
char closeBracket = ')'; // startIndex points to the openning bracket
10711157
Deque<Character> stack = new ArrayDeque<>();

0 commit comments

Comments
 (0)