Github user KanakaKumar commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2804#discussion_r231059908 --- Diff: store/sdk/src/main/java/org/apache/carbondata/sdk/file/CarbonSchemaReader.java --- @@ -61,14 +65,122 @@ public static Schema readSchemaInSchemaFile(String schemaFilePath) throws IOExce return new Schema(schemaList); } + /** + * get carbondata/carbonindex file in path + * + * @param path carbon file path + * @return CarbonFile array + */ + private static CarbonFile[] getCarbonFile(String path, final String extension) + throws IOException { + String dataFilePath = path; + if (!(dataFilePath.contains(extension))) { + CarbonFile[] carbonFiles = FileFactory + .getCarbonFile(path) + .listFiles(new CarbonFileFilter() { + @Override + public boolean accept(CarbonFile file) { + if (file == null) { + return false; + } + return file.getName().endsWith(extension); + } + }); + if (carbonFiles == null || carbonFiles.length < 1) { + throw new IOException("Carbon file not exists."); + } + return carbonFiles; + } + return null; --- End diff -- We can stick to one contract from the method. Either return the list or throw exception. Generally listing APIs should not return null, if this case is not expected, we can throw exception.
---