rdblue commented on a change in pull request #3273:
URL: https://github.com/apache/iceberg/pull/3273#discussion_r732195289



##########
File path: data/src/main/java/org/apache/iceberg/data/TableMigrationUtil.java
##########
@@ -91,7 +93,12 @@ private TableMigrationUtil() {
       return Arrays.stream(fs.listStatus(partition, HIDDEN_PATH_FILTER))
           .filter(FileStatus::isFile)
           .map(stat -> {
-            Metrics metrics = new Metrics(-1L, null, null, null);
+            InputFile inFile = 
HadoopInputFile.fromLocation(stat.getPath().toString(), conf);
+            long length = inFile.getLength();
+
+            // Seeking to the end will count all the rows.
+            long rowCount = AvroIO.findStartingRowPos(inFile::newStream, 
length);

Review comment:
       The `findStartingRowPos` method handles `EOFException` so I think you 
could implement this using `AvroIO.findStartingRowPos(..., Long.MAX_VALUE)`. 
Then you wouldn't need to call to S3 to find the file length.
   
   That's how I'd implement the util method:
   ```java
   public class Avro {
     ...
     public long rowCount(InputFile file) {
       return AvroIO.findStartingRowPos(file::newStream, Long.MAX_VALUE);
     }
   }
   ```




-- 
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