nastra commented on code in PR #5268:
URL: https://github.com/apache/iceberg/pull/5268#discussion_r930821585
##########
api/src/main/java/org/apache/iceberg/metrics/MetricsContext.java:
##########
@@ -126,15 +126,15 @@ public Timer timer(String name, TimeUnit unit) {
@Override
public <T extends Number> Counter<T> counter(String name, Class<T> type,
Unit unit) {
- return new Counter<T>() {
- @Override
- public void increment() {
- }
-
- @Override
- public void increment(T amount) {
- }
- };
+ if (Integer.class.equals(type)) {
Review Comment:
this is particuarly for the case where one would use `ScanMetrics NOOP = new
ScanMetrics(MetricsContext.nullMetrics())`, which would then use
`MetricsContext.nullMetrics()`. I don't think we'd want any access of
`.value()` to throw an exception when `MetricsContext.nullMetrics()` is used,
so we need NOOP counters for those (we can't make a generic NOOP counter, as
`.value()` needs to return `0` for `Integer.class` and `0L` for `Long.class`).
The below test verifies that exact behavior
https://github.com/apache/iceberg/blob/3ed173b87909c221d66a6b09d70c8f8d4b562e51/api/src/test/java/org/apache/iceberg/metrics/TestScanReport.java#L60-L81
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]