nastra commented on code in PR #5780:
URL: https://github.com/apache/iceberg/pull/5780#discussion_r974933721
##########
core/src/test/java/org/apache/iceberg/metrics/TestScanMetricsResultParser.java:
##########
@@ -45,86 +45,54 @@ public void nullMetrics() {
@Test
public void missingFields() {
Assertions.assertThat(ScanMetricsResultParser.fromJson("{}"))
- .isEqualTo(new ScanMetricsResult(null, null, null, null, null, null,
null, null, null));
-
- TimerResult totalPlanningDuration = new TimerResult(TimeUnit.HOURS,
Duration.ofHours(10), 3L);
- CounterResult resultDataFiles = new CounterResult(Unit.COUNT, 5L);
- CounterResult resultDeleteFiles = new CounterResult(Unit.COUNT, 5L);
- CounterResult totalDataManifests = new CounterResult(Unit.COUNT, 5L);
- CounterResult totalDeleteManifests = new CounterResult(Unit.COUNT, 0L);
- CounterResult scannedDataManifests = new CounterResult(Unit.COUNT, 5L);
- CounterResult skippedDataManifests = new CounterResult(Unit.COUNT, 5L);
- CounterResult totalFileSizeInBytes = new CounterResult(Unit.BYTES, 1069L);
+ .isEqualTo(ImmutableScanMetricsResult.builder().build());
+ ImmutableScanMetricsResult scanMetricsResult =
Review Comment:
it's actually not a Builder instance here but the actual ScanMetricsResult
instance and we're making a copy of it and then just update a single metric:
```
ImmutableScanMetricsResult scanMetricsResult =
ImmutableScanMetricsResult.builder()
.totalPlanningDuration(TimerResult.of(TimeUnit.HOURS,
Duration.ofHours(10), 3L))
.build();
// copy whatever was already set and then only configure result-data-files
scanMetricsResult =
scanMetricsResult.withResultDataFiles(CounterResult.of(Unit.COUNT, 5L));
```
We could also have used `scanMetricsResult =
ImmutableScanMetricsResult.copyOf(scanMetricsResult).withResultDataFiles(CounterResult.of(Unit.COUNT,
5L))` which is slightly longer but a bit more explicit and indicates that
we're making a copy here
--
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]