ajantha-bhat commented on a change in pull request #4068:
URL: https://github.com/apache/carbondata/pull/4068#discussion_r551240783



##########
File path: 
sdk/sdk/src/main/java/org/apache/carbondata/sdk/file/CarbonReaderBuilder.java
##########
@@ -427,6 +436,50 @@ private CarbonFileInputFormat prepareFileInputFormat(Job 
job, boolean enableBloc
     }
   }
 
+  private <T> void totalRowCountInSplits(Job job, List<InputSplit> splits,
+      List<Long> rowCountInSplit) throws IOException, InterruptedException {
+    long sum = 0;
+    boolean isIUDTable = false;
+    // Check if update or delete happened on the table.
+    if (!StringUtils.isEmpty(this.tablePath)) {
+      CarbonFile[] fileList = FileFactory.getCarbonFile(this.tablePath,
+          this.hadoopConf).listFiles();
+      for (CarbonFile file : fileList) {
+        if 
(file.getPath().endsWith(CarbonCommonConstants.DELETE_DELTA_FILE_EXT)) {
+          isIUDTable = true;
+          break;
+        }
+      }
+    }
+    // if filter exists or IUD happened then read the total number of rows 
after
+    // building carbon reader else get the row count from the details info of 
each splits.
+    if (this.filterExpression != null || isIUDTable) {
+      for (InputSplit split : splits) {
+        List<RecordReader<Void, T>> readers = new ArrayList<>();
+        CarbonFileInputFormat format = this.prepareFileInputFormat(job, false, 
true);
+        RecordReader reader = this.getRecordReader(job, format, readers, 
split);
+        readers.add(reader);
+        CarbonReader carbonReader = new CarbonReader<>(readers);

Review comment:
       please close the reader in the finallay block, else there will be 
resource leak




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to