public static List<LoadMetadataDetails> identifySegmentsToBeMerged(String storeLocation,CarbonLoadModel carbonLoadModel,int partitionCount,long compactionSize,List<LoadMetadataDetails> segments,CompactionType compactionType){
  List sortedSegments=new ArrayList(segments);
  sortSegments(sortedSegments);
  List<LoadMetadataDetails> listOfSegmentsAfterPreserve=checkPreserveSegmentsPropertyReturnRemaining(sortedSegments);
  List<LoadMetadataDetails> listOfSegmentsLoadedInSameDateInterval=identifySegmentsToBeMergedBasedOnLoadedDate(listOfSegmentsAfterPreserve);
  List<LoadMetadataDetails> listOfSegmentsToBeMerged;
  if (compactionType.equals(CompactionType.MAJOR_COMPACTION)) {
    listOfSegmentsToBeMerged=identifySegmentsToBeMergedBasedOnSize(compactionSize,listOfSegmentsLoadedInSameDateInterval,carbonLoadModel,partitionCount,storeLocation);
  }
 else {
    listOfSegmentsToBeMerged=identifySegmentsToBeMergedBasedOnSegCount(listOfSegmentsLoadedInSameDateInterval);
  }
  return listOfSegmentsToBeMerged;
}

public static List < LoadMetadataDetails > identifySegmentsToBeMerged ( String storeLocation , CarbonLoadModel carbonLoadModel , int partitionCount , long compactionSize , List < LoadMetadataDetails > segments , CompactionType compactionType ) { List sortedSegments = new ArrayList ( segments ) ; sortSegments ( sortedSegments ) ; List < LoadMetadataDetails > listOfSegmentsAfterPreserve = checkPreserveSegmentsPropertyReturnRemaining ( sortedSegments ) ; List < LoadMetadataDetails > listOfSegmentsLoadedInSameDateInterval = identifySegmentsToBeMergedBasedOnLoadedDate ( listOfSegmentsAfterPreserve ) ; List < LoadMetadataDetails > listOfSegmentsToBeMerged ; if ( compactionType . equals ( CompactionType . MAJOR_COMPACTION ) ) { listOfSegmentsToBeMerged = identifySegmentsToBeMergedBasedOnSize ( compactionSize , listOfSegmentsLoadedInSameDateInterval , carbonLoadModel , partitionCount , storeLocation ) ; } else { listOfSegmentsToBeMerged = identifySegmentsToBeMergedBasedOnSegCount ( listOfSegmentsLoadedInSameDateInterval ) ; } return listOfSegmentsToBeMerged ; }
to identify which all segments can be merged .
