Skip to content

Commit 7745db4

Browse files
committed
fix query response
1 parent 4e3bf9f commit 7745db4

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

client-v2/src/main/java/com/clickhouse/client/api/Client.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ private Client(Set<String> endpoints, Map<String,String> configuration) {
118118
this.getterMethods = new HashMap<>();
119119
this.hasDefaults = new HashMap<>();
120120

121-
final int numThreads = Integer.parseInt(configuration.get(ClickHouseClientOption.MAX_THREADS_PER_CLIENT.getKey()));
122-
this.sharedOperationExecutor = Executors.newFixedThreadPool(numThreads, new DefaultThreadFactory("chc-operation"));
123-
LOG.debug("Query executor created with {} threads", numThreads);
121+
this.sharedOperationExecutor = Executors.newCachedThreadPool(new DefaultThreadFactory("chc-operation"));
124122
}
125123

126124
/**
@@ -458,9 +456,6 @@ public boolean ping() {
458456
* @return true if the server is alive, false otherwise
459457
*/
460458
public boolean ping(long timeout) {
461-
ValidationUtils.checkRange(timeout, TimeUnit.SECONDS.toMillis(1), TimeUnit.MINUTES.toMillis(10),
462-
"timeout");
463-
464459
try (ClickHouseClient client = ClientV1AdaptorHelper.createClient(configuration)) {
465460
return client.ping(getServerNode(), Math.toIntExact(timeout));
466461
}
@@ -851,9 +846,9 @@ public CompletableFuture<Records> queryRecords(String sqlQuery, QuerySettings se
851846
public List<GenericRecord> queryAll(String sqlQuery) {
852847
try {
853848
int operationTimeout = getOperationTimeout();
854-
QueryResponse response = operationTimeout == 0 ? query(sqlQuery).get() :
855-
query(sqlQuery).get(operationTimeout, TimeUnit.MILLISECONDS);
856-
try (response) {
849+
850+
try (QueryResponse response = operationTimeout == 0 ? query(sqlQuery).get() :
851+
query(sqlQuery).get(operationTimeout, TimeUnit.MILLISECONDS)) {
857852
List<GenericRecord> records = new ArrayList<>();
858853
if (response.getResultRows() > 0) {
859854
ClickHouseBinaryFormatReader reader = new RowBinaryWithNamesAndTypesFormatReader(response.getInputStream());

client-v2/src/main/java/com/clickhouse/client/api/query/QueryResponse.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public QueryResponse(ClickHouseClient client, ClickHouseResponse clickHouseRespo
4949
this.format = format;
5050
this.settings = settings;
5151
this.operationMetrics = new OperationMetrics(clientStatisticsHolder);
52+
this.operationMetrics.operationComplete(clickHouseResponse.getSummary());
5253
}
5354

5455
public ClickHouseInputStream getInputStream() {

0 commit comments

Comments
 (0)