rdblue commented on code in PR #5268:
URL: https://github.com/apache/iceberg/pull/5268#discussion_r922370524


##########
core/src/main/java/org/apache/iceberg/ManifestGroup.java:
##########
@@ -163,20 +171,26 @@ public CloseableIterable<FileScanTask> planFiles() {
     });
 
     DeleteFileIndex deleteFiles = deleteIndexBuilder.build();
-
     boolean dropStats = ManifestReader.dropStats(dataFilter, columns);
     if (!deleteFiles.isEmpty()) {
       select(ManifestReader.withStatsColumns(columns));
     }
 
     Iterable<CloseableIterable<FileScanTask>> tasks = entries((manifest, 
entries) -> {
+      scanMetrics.addedDataFiles().increment(manifest.addedFilesCount());
+      scanMetrics.deletedDataFiles().increment(manifest.deletedFilesCount());
+      scanMetrics.totalDataManifestsReadCount().increment();
       int specId = manifest.partitionSpecId();
       PartitionSpec spec = specsById.get(specId);
       String schemaString = SchemaParser.toJson(spec.schema());
       String specString = PartitionSpecParser.toJson(spec);
       ResidualEvaluator residuals = residualCache.get(specId);
-      return CloseableIterable.transform(entries, e -> new BaseFileScanTask(
-          e.file().copy(!dropStats), deleteFiles.forEntry(e), schemaString, 
specString, residuals));
+      return CloseableIterable.transform(entries, e -> {
+        scanMetrics.matchingDataFilesCount().increment();
+        
scanMetrics.totalFileSizeInBytes().increment(e.file().fileSizeInBytes());

Review Comment:
   I think a more reliable place to gather these by wrapping the iterator 
returned by `planFiles`. That way you don't have to worry about future changes 
to code futher filtering the iterator that you're wrapping here.



##########
core/src/main/java/org/apache/iceberg/ManifestGroup.java:
##########
@@ -163,20 +171,26 @@ public CloseableIterable<FileScanTask> planFiles() {
     });
 
     DeleteFileIndex deleteFiles = deleteIndexBuilder.build();
-
     boolean dropStats = ManifestReader.dropStats(dataFilter, columns);
     if (!deleteFiles.isEmpty()) {
       select(ManifestReader.withStatsColumns(columns));
     }
 
     Iterable<CloseableIterable<FileScanTask>> tasks = entries((manifest, 
entries) -> {
+      scanMetrics.addedDataFiles().increment(manifest.addedFilesCount());
+      scanMetrics.deletedDataFiles().increment(manifest.deletedFilesCount());
+      scanMetrics.totalDataManifestsReadCount().increment();
       int specId = manifest.partitionSpecId();
       PartitionSpec spec = specsById.get(specId);
       String schemaString = SchemaParser.toJson(spec.schema());
       String specString = PartitionSpecParser.toJson(spec);
       ResidualEvaluator residuals = residualCache.get(specId);
-      return CloseableIterable.transform(entries, e -> new BaseFileScanTask(
-          e.file().copy(!dropStats), deleteFiles.forEntry(e), schemaString, 
specString, residuals));
+      return CloseableIterable.transform(entries, e -> {
+        scanMetrics.matchingDataFilesCount().increment();
+        
scanMetrics.totalFileSizeInBytes().increment(e.file().fileSizeInBytes());

Review Comment:
   I think a more reliable place to gather these by wrapping the iterator 
returned by `planFiles`. That way you don't have to worry about future changes 
to code further filtering the iterator that you're wrapping 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]

Reply via email to