Posted by
GitBox on
URL: http://apache-carbondata-dev-mailing-list-archive.168.s1.nabble.com/GitHub-carbondata-ShreelekhyaG-opened-a-new-pull-request-3988-WIP-Clean-index-files-when-clean-filesd-tp102150p107740.html
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:
[hidden email]