|
4 | 4 | import com.clickhouse.client.api.data_formats.ClickHouseBinaryFormatReader; |
5 | 5 | import com.clickhouse.client.api.data_formats.RowBinaryWithNamesAndTypesFormatReader; |
6 | 6 | import com.clickhouse.client.api.data_formats.internal.BinaryReaderBackedRecord; |
| 7 | +import com.clickhouse.client.api.metrics.OperationMetrics; |
| 8 | +import com.clickhouse.client.api.metrics.ServerMetrics; |
7 | 9 | import com.clickhouse.data.ClickHouseFormat; |
8 | 10 |
|
9 | 11 | import java.util.Iterator; |
@@ -69,4 +71,61 @@ boolean isEmpty() { |
69 | 71 | Stream<GenericRecord> stream() { |
70 | 72 | return StreamSupport.stream(spliterator(), false); |
71 | 73 | } |
| 74 | + |
| 75 | + /** |
| 76 | + * Returns the metrics of this operation. |
| 77 | + * |
| 78 | + * @return metrics of this operation |
| 79 | + */ |
| 80 | + public OperationMetrics getMetrics() { |
| 81 | + return response.getMetrics(); |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Alias for {@link ServerMetrics#NUM_ROWS_READ} |
| 86 | + * @return number of rows read by server from the storage |
| 87 | + */ |
| 88 | + public long getReadRows() { |
| 89 | + return response.getMetrics().getMetric(ServerMetrics.NUM_ROWS_READ).getLong(); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * Alias for {@link ServerMetrics#NUM_BYTES_READ} |
| 94 | + * @return number of bytes read by server from the storage |
| 95 | + */ |
| 96 | + public long getReadBytes() { |
| 97 | + return response.getMetrics().getMetric(ServerMetrics.NUM_BYTES_READ).getLong(); |
| 98 | + } |
| 99 | + |
| 100 | + /** |
| 101 | + * Alias for {@link ServerMetrics#NUM_ROWS_WRITTEN} |
| 102 | + * @return number of rows written by server to the storage |
| 103 | + */ |
| 104 | + public long getWrittenRows() { |
| 105 | + return response.getMetrics().getMetric(ServerMetrics.NUM_ROWS_WRITTEN).getLong(); |
| 106 | + } |
| 107 | + |
| 108 | + /** |
| 109 | + * Alias for {@link ServerMetrics#NUM_BYTES_WRITTEN} |
| 110 | + * @return number of bytes written by server to the storage |
| 111 | + */ |
| 112 | + public long getWrittenBytes() { |
| 113 | + return response.getMetrics().getMetric(ServerMetrics.NUM_BYTES_WRITTEN).getLong(); |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * Alias for {@link ServerMetrics#ELAPSED_TIME} |
| 118 | + * @return elapsed time in nanoseconds |
| 119 | + */ |
| 120 | + public long getServerTime() { |
| 121 | + return response.getMetrics().getMetric(ServerMetrics.ELAPSED_TIME).getLong(); |
| 122 | + } |
| 123 | + |
| 124 | + /** |
| 125 | + * Alias for {@link ServerMetrics#RESULT_ROWS} |
| 126 | + * @return number of returned rows |
| 127 | + */ |
| 128 | + public long getResultRows() { |
| 129 | + return response.getMetrics().getMetric(ServerMetrics.RESULT_ROWS).getLong(); |
| 130 | + } |
72 | 131 | } |
0 commit comments