Github user ravipesala commented on a diff in the pull request: https://github.com/apache/carbondata/pull/1642#discussion_r157333858 --- Diff: processing/src/main/java/org/apache/carbondata/processing/util/CarbonLoaderUtil.java --- @@ -329,6 +329,47 @@ public static String readCurrentTime() { return date; } + public static void readAndUpdateLoadProgressInTableMeta(CarbonLoadModel model, + boolean insertOverwrite) throws IOException, InterruptedException { + LoadMetadataDetails newLoadMetaEntry = new LoadMetadataDetails(); + SegmentStatus status = SegmentStatus.INSERT_IN_PROGRESS; + if (insertOverwrite) { + status = SegmentStatus.INSERT_OVERWRITE_IN_PROGRESS; + } + + // reading the start time of data load. + long loadStartTime = CarbonUpdateUtil.readCurrentTime(); + model.setFactTimeStamp(loadStartTime); + CarbonLoaderUtil + .populateNewLoadMetaEntry(newLoadMetaEntry, status, model.getFactTimeStamp(), false); + boolean entryAdded = + CarbonLoaderUtil.recordNewLoadMetadata(newLoadMetaEntry, model, true, insertOverwrite); + if (!entryAdded) { + throw new IOException("Failed to add entry in table status for " + model.getTableName()); + } + } + + /** + * This method will update the load failure entry in the table status file + */ + public static void updateTableStatusForFailure(CarbonLoadModel model) + throws IOException, InterruptedException { + // in case if failure the load status should be "Marked for delete" so that it will be taken + // care during clean up + SegmentStatus loadStatus = SegmentStatus.MARKED_FOR_DELETE; + // always the last entry in the load metadata details will be the current load entry + LoadMetadataDetails loadMetaEntry = + model.getLoadMetadataDetails().get(model.getLoadMetadataDetails().size() - 1); + CarbonLoaderUtil + .populateNewLoadMetaEntry(loadMetaEntry, loadStatus, model.getFactTimeStamp(), true); + boolean updationStatus = --- End diff -- ok
---