-
Notifications
You must be signed in to change notification settings - Fork 626
Expand file tree
/
Copy pathInsertResponse.java
More file actions
106 lines (91 loc) · 3.13 KB
/
Copy pathInsertResponse.java
File metadata and controls
106 lines (91 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package com.clickhouse.client.api.insert;
import com.clickhouse.client.api.http.ClickHouseHttpProto;
import com.clickhouse.client.api.metrics.OperationMetrics;
import com.clickhouse.client.api.metrics.ServerMetrics;
import com.clickhouse.client.api.transport.internal.TransportResponse;
import java.util.Map;
public class InsertResponse implements AutoCloseable {
private OperationMetrics operationMetrics;
private final Map<String, String> responseHeaders;
public InsertResponse(TransportResponse transportResponse, OperationMetrics metrics) {
this.operationMetrics = metrics;
this.responseHeaders = transportResponse.getHeaders();
}
@Override
public void close() {
}
/**
* Returns the metrics of this operation.
*
* @return metrics of this operation
*/
public OperationMetrics getMetrics() {
return operationMetrics;
}
/**
* Alias for {@link ServerMetrics#NUM_ROWS_READ}
* @return number of rows read by server from the storage
*/
public long getReadRows() {
return operationMetrics.getMetric(ServerMetrics.NUM_ROWS_READ).getLong();
}
/**
* Alias for {@link ServerMetrics#NUM_BYTES_READ}
* @return number of bytes read by server from the storage
*/
public long getReadBytes() {
return operationMetrics.getMetric(ServerMetrics.NUM_BYTES_READ).getLong();
}
/**
* Alias for {@link ServerMetrics#NUM_ROWS_WRITTEN}
* @return number of rows written by server to the storage
*/
public long getWrittenRows() {
return operationMetrics.getMetric(ServerMetrics.NUM_ROWS_WRITTEN).getLong();
}
/**
* Alias for {@link ServerMetrics#NUM_BYTES_WRITTEN}
* @return number of bytes written by server to the storage
*/
public long getWrittenBytes() {
return operationMetrics.getMetric(ServerMetrics.NUM_BYTES_WRITTEN).getLong();
}
/**
* Alias for {@link ServerMetrics#ELAPSED_TIME}
* @return elapsed time in nanoseconds
*/
public long getServerTime() {
return operationMetrics.getMetric(ServerMetrics.ELAPSED_TIME).getLong();
}
/**
* Alias for {@link ServerMetrics#RESULT_ROWS}
* @return number of returned rows
*/
public long getResultRows() {
return operationMetrics.getMetric(ServerMetrics.RESULT_ROWS).getLong();
}
/**
* Alias for {@link OperationMetrics#getQueryId()}
* @return number of returned bytes
*/
public String getQueryId() {
return operationMetrics.getQueryId();
}
/**
* Returns the value of {@code X-ClickHouse-Server-Display-Name} response header.
*
* @return server display name or {@code null} if not present
*/
public String getServerDisplayName() {
return responseHeaders.get(ClickHouseHttpProto.HEADER_SRV_DISPLAY_NAME);
}
/**
* Returns all collected response headers as an unmodifiable map.
* Only whitelisted ClickHouse headers are included.
*
* @return map of header name to header value
*/
public Map<String, String> getResponseHeaders() {
return responseHeaders;
}
}