Repository navigation
feat: populate client_stats in AppendRowsRequest - #14614
agrawal-siddharth wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds the population of ClientStats with the request send timestamp (sendTimeMillis) on append requests in ConnectionWorker, along with a corresponding unit test to verify this behavior. The review feedback suggests avoiding unconditionally setting ClientStats on the request builder when it is empty (i.e., when the timestamp is null), as setting an empty Protobuf message causes hasClientStats() to return true, leading to unnecessary serialization overhead. It is recommended to check if the returned ClientStats is equal to the default instance before setting it.
| } | ||
| firstRequestForTableOrSchemaSwitch = false; | ||
|
|
||
| originalRequestBuilder.setClientStats(createClientStats(wrapper)); |
There was a problem hiding this comment.
If createClientStats returns an empty ClientStats (when requestSendTimeStamp is null), calling setClientStats unconditionally will still set an empty ClientStats message on the builder. In Protobuf, setting an empty message field causes hasClientStats() to return true, which adds unnecessary serialization overhead and can mislead the backend. Since we prefer returning empty objects instead of null to minimize null pointer risks, we should check if the returned ClientStats is empty (i.e., equals ClientStats.getDefaultInstance()) before setting it on the builder.
| originalRequestBuilder.setClientStats(createClientStats(wrapper)); | |
| ClientStats clientStats = createClientStats(wrapper); | |
| if (!clientStats.equals(ClientStats.getDefaultInstance())) { | |
| originalRequestBuilder.setClientStats(clientStats); | |
| } |
References
- Prefer returning empty objects (such as an empty ErrorDetails or empty collections) instead of null to minimize null pointer risks, and document this behavior in Javadocs (e.g., how to pair it with state checks like isDone()).
c50f1fc to
190f1e6
Compare
190f1e6 to
feb4187
Compare
feb4187 to
5fe9a7c
Compare
No description provided.