You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@carbondata.apache.org by GitBox <gi...@apache.org> on 2021/04/21 08:00:18 UTC

[GitHub] [carbondata] Indhumathi27 commented on a change in pull request #3988: [CARBONDATA-4037] Improve the table status and segment file writing

Indhumathi27 commented on a change in pull request #3988:
URL: https://github.com/apache/carbondata/pull/3988#discussion_r617290441



##########
File path: core/src/main/java/org/apache/carbondata/core/util/CarbonTestUtil.java
##########
@@ -161,6 +166,50 @@ public static Boolean checkForLocalDictionary(
     return isLocalDictionaryGenerated;
   }
 
+  public static int getSegmentFileCount(String tableName) throws IOException {
+    CarbonTable carbonTable = CarbonMetadata.getInstance().getCarbonTable(tableName);
+    CarbonFile segmentsFolder = FileFactory
+        .getCarbonFile(CarbonTablePath.getSegmentFilesLocation(carbonTable.getTablePath()));
+    assert (segmentsFolder.isFileExist());
+    return segmentsFolder.listFiles(true).size();
+  }
+
+  public static int getIndexFileCount(String tableName,
+      String segment, String extension) throws IOException {
+    if (extension == null) {
+      extension = CarbonTablePath.INDEX_FILE_EXT;
+    }
+    CarbonTable table = CarbonMetadata.getInstance().getCarbonTable(tableName);
+    String path = CarbonTablePath
+        .getSegmentPath(table.getAbsoluteTableIdentifier().getTablePath(), segment);
+    CarbonFile[] carbonFiles;

Review comment:
       Can optimize as below:
   ```suggestion
        List<CarbonFile> carbonFiles;
       boolean recursive = false;
       if (table.isHivePartitionTable()) {
         path = table.getAbsoluteTableIdentifier().getTablePath();
         recursive = true;
       }
       carbonFiles = FileFactory.getCarbonFile(path).listFiles(recursive,
           file -> file.getName().endsWith(CarbonTablePath.INDEX_FILE_EXT) || file.getName()
               .endsWith(CarbonTablePath.MERGE_INDEX_FILE_EXT));
       CarbonFile[] validIndexFiles = (CarbonFile[]) SegmentFileStore
           .getValidCarbonIndexFiles(carbonFiles.toArray(new CarbonFile[carbonFiles.size()]));
   ```




-- 
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:
users@infra.apache.org