ajantha-bhat commented on a change in pull request #3819:
URL:
https://github.com/apache/carbondata/pull/3819#discussion_r481809933##########
File path: sdk/sdk/src/main/java/org/apache/carbondata/sdk/file/CSVCarbonWriter.java
##########
@@ -72,6 +88,75 @@ public void write(Object object) throws IOException {
}
}
+ private CsvParser buildCsvParser(Configuration conf) {
+ CsvParserSettings settings = CSVInputFormat.extractCsvParserSettings(conf);
+ return new CsvParser(settings);
+ }
+
+ @Override
+ public void validateAndSetDataFiles(CarbonFile[] dataFiles) throws IOException {
+ if (dataFiles == null || dataFiles.length == 0) {
+ throw new RuntimeException("data files can't be empty.");
+ }
+ DataInputStream csvInputStream = null;
+ CsvParser csvParser = this.buildCsvParser(this.configuration);
+ for (CarbonFile dataFile : dataFiles) {
+ try {
+ csvInputStream = FileFactory.getDataInputStream(dataFile.getPath(),
+ -1, this.configuration);
+ csvParser.beginParsing(csvInputStream);
+ } catch (IllegalArgumentException ex) {
+ if (ex.getCause() instanceof FileNotFoundException) {
+ throw new FileNotFoundException("File " + dataFile +
+ " not found to build carbon writer.");
+ }
+ throw ex;
+ } finally {
+ if (csvInputStream != null) {
+ csvInputStream.close();
+ }
+ }
+ }
+ this.dataFiles = dataFiles;
+ }
+
+ /**
+ * Load data of all or selected csv files at given location iteratively.
+ *
+ * @throws IOException
+ */
+ @Override
+ public void write() throws IOException {
Review comment:
New methods added has to be added in sdk-guide.md file.
Also better to give link to test case or example on how to use
----------------------------------------------------------------
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]