core/src/main/java/org/apache/carbondata/core/statusmanager/SegmentStatusManager.java
/**
   * updates deletion status details for each load and returns invalidLoadIds
   *
   * @param loadIds
   * @param listOfLoadFolderDetailsArray
   * @param invalidLoadIds
   * @return invalidLoadIds
   */
updates deletion status details for each load and returns invalidLoadIds
@param loadIds
@param listOfLoadFolderDetailsArray
@param invalidLoadIds
@return invalidLoadIds
updates deletion status details for each load and returns invalidLoadIds @param loadIds @param listOfLoadFolderDetailsArray @param invalidLoadIds @return invalidLoadIds
private static List<String> updateDeletionStatus(AbsoluteTableIdentifier absoluteTableIdentifier,
      List<String> loadIds, LoadMetadataDetails[] listOfLoadFolderDetailsArray,
      List<String> invalidLoadIds) {
    SegmentStatus segmentStatus = null;
    for (String loadId : loadIds) {
      boolean loadFound = false;
      for (LoadMetadataDetails loadMetadata : listOfLoadFolderDetailsArray) {
        if (loadId.equalsIgnoreCase(loadMetadata.getLoadName())) {
          segmentStatus = loadMetadata.getSegmentStatus();
          if (SegmentStatus.COMPACTED == segmentStatus) {
            LOG.error("Cannot delete the Segment which is compacted. Segment is " + loadId);
            invalidLoadIds.add(loadId);
            return invalidLoadIds;
          } else if (SegmentStatus.INSERT_IN_PROGRESS == segmentStatus
              && isLoadInProgress(absoluteTableIdentifier, loadId)) {
            LOG.error("Cannot delete the segment " + loadId + " which is load in progress");
            invalidLoadIds.add(loadId);
            return invalidLoadIds;
          } else if (SegmentStatus.INSERT_OVERWRITE_IN_PROGRESS == segmentStatus
              && isLoadInProgress(absoluteTableIdentifier, loadId)) {
            LOG.error("Cannot delete the segment " + loadId + " which is load overwrite " +
                    "in progress");
            invalidLoadIds.add(loadId);
            return invalidLoadIds;
          } else if (SegmentStatus.STREAMING == segmentStatus) {
            LOG.error("Cannot delete the segment " + loadId + " which is streaming in progress");
            invalidLoadIds.add(loadId);
            return invalidLoadIds;
          } else if (SegmentStatus.MARKED_FOR_DELETE != segmentStatus) {
            loadFound = true;
            loadMetadata.setSegmentStatus(SegmentStatus.MARKED_FOR_DELETE);
            loadMetadata.setModificationOrdeletionTimesStamp(CarbonUpdateUtil.readCurrentTime());
            LOG.info("Segment ID " + loadId + " Marked for Delete");
          }
          break;
        }
      }
      if (!loadFound) {
        LOG.audit("Delete segment by ID is failed. No matching segment id found :" + loadId);
        invalidLoadIds.add(loadId);
        return invalidLoadIds;
      }
    }
    return invalidLoadIds;
  }
private static List < String > updateDeletionStatus ( AbsoluteTableIdentifier absoluteTableIdentifier , List < String > loadIds , LoadMetadataDetails [ ] listOfLoadFolderDetailsArray , List < String > invalidLoadIds ) { SegmentStatus segmentStatus = null ; for ( String loadId : loadIds ) { boolean loadFound = false ; for ( LoadMetadataDetails loadMetadata : listOfLoadFolderDetailsArray ) { if ( loadId . equalsIgnoreCase ( loadMetadata . getLoadName ( ) ) ) { segmentStatus = loadMetadata . getSegmentStatus ( ) ; if ( SegmentStatus . COMPACTED == segmentStatus ) { LOG . error ( "Cannot delete the Segment which is compacted. Segment is " + loadId ) ; invalidLoadIds . add ( loadId ) ; return invalidLoadIds ; } else if ( SegmentStatus . INSERT_IN_PROGRESS == segmentStatus && isLoadInProgress ( absoluteTableIdentifier , loadId ) ) { LOG . error ( "Cannot delete the segment " + loadId + " which is load in progress" ) ; invalidLoadIds . add ( loadId ) ; return invalidLoadIds ; } else if ( SegmentStatus . INSERT_OVERWRITE_IN_PROGRESS == segmentStatus && isLoadInProgress ( absoluteTableIdentifier , loadId ) ) { LOG . error ( "Cannot delete the segment " + loadId + " which is load overwrite " + "in progress" ) ; invalidLoadIds . add ( loadId ) ; return invalidLoadIds ; } else if ( SegmentStatus . STREAMING == segmentStatus ) { LOG . error ( "Cannot delete the segment " + loadId + " which is streaming in progress" ) ; invalidLoadIds . add ( loadId ) ; return invalidLoadIds ; } else if ( SegmentStatus . MARKED_FOR_DELETE != segmentStatus ) { loadFound = true ; loadMetadata . setSegmentStatus ( SegmentStatus . MARKED_FOR_DELETE ) ; loadMetadata . setModificationOrdeletionTimesStamp ( CarbonUpdateUtil . readCurrentTime ( ) ) ; LOG . info ( "Segment ID " + loadId + " Marked for Delete" ) ; } break ; } } if ( ! loadFound ) { LOG . audit ( "Delete segment by ID is failed. No matching segment id found :" + loadId ) ; invalidLoadIds . add ( loadId ) ; return invalidLoadIds ; } } return invalidLoadIds ; }
updates deletion status details for each load and returns invalidLoadIds
 @param loadIds
 @param listOfLoadFolderDetailsArray
 @param invalidLoadIds
 @return invalidLoadIds
updates deletion status details for each load and returns invalidLoadIds @param loadIds @param listOfLoadFolderDetailsArray @param invalidLoadIds @return invalidLoadIds
// For each load id loop through data and if the // load id is found then mark // the metadata as deleted. // if the segment is compacted then no need to delete that. // if the segment status is in progress then no need to delete that. // if the segment status is overwrite in progress, then no need to delete that. // if the segment status is streaming, the segment can't be deleted directly.