RussellSpitzer commented on code in PR #4759:
URL: https://github.com/apache/iceberg/pull/4759#discussion_r902800613


##########
core/src/main/java/org/apache/iceberg/actions/SortStrategy.java:
##########
@@ -80,12 +118,55 @@ public RewriteStrategy options(Map<String, String> 
options) {
     return this;
   }
 
+  @Override
+  public Iterable<FileScanTask> selectFilesToRewrite(Iterable<FileScanTask> 
dataFiles) {
+    if (rewriteAll()) {
+      LOG.info("Table {} set to rewrite all data files", table().name());
+      return dataFiles;
+    } else {
+      // Remove files that are completely sorted.
+      // Example: File_A(1, 10), File_B(11, 25), File_C(15, 30), File_D(31, 40)
+      // Then only File_B and File_C are selected
+      Iterable<FileScanTask> selectedFiles = 
SortStrategyUtil.removeSortedFiles(dataFiles, sortOrder);
+      if (!haveGoodFileSizes(selectedFiles) || !areFilesSorted(selectedFiles)) 
{

Review Comment:
   for both of these clauses I would prefer using positive assertions rather 
than negations.
   
   In this case
   If !(x && y) or better yet if ( notX && notY) where the functions notX and 
notY themselves are the requirements.
   
   I'll mark this below but "haveGood" is not a very descriptive name



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