core/src/main/java/org/apache/carbondata/core/datastore/block/TableBlockInfo.java
/**
   * Below method will used to compare to TableBlockInfos object this will
   * used for sorting Comparison logic is: 1. compare segment id if segment id
   * is same 2. compare task id if task id is same 3. compare offsets of the
   * block
   */
Below method will used to compare to TableBlockInfos object this will
used for sorting Comparison logic is: 1. compare segment id if segment id
is same 2. compare task id if task id is same 3. compare offsets of the
block
Below method will used to compare to TableBlockInfos object this will used for sorting Comparison logic is : 1 . compare segment id if segment id is same 2 . compare task id if task id is same 3 . compare offsets of the block
@Override public int compareTo(Distributable other) {
    int compareResult = 0;
    double seg1 = Double.parseDouble(segmentId);
    double seg2 = Double.parseDouble(((TableBlockInfo) other).segmentId);
    if (seg1 - seg2 < 0) {
      return -1;
    }
    if (seg1 - seg2 > 0) {
      return 1;
    }
    if (CarbonTablePath.isCarbonDataFile(filePath)) {
      int compare = ByteUtil.compare(DataFileUtil.getTaskNo(filePath)
              .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET)),
          DataFileUtil.getTaskNo(((TableBlockInfo) other).filePath)
              .getBytes(Charset.forName(CarbonCommonConstants.DEFAULT_CHARSET)));
      if (compare != 0) {
        return compare;
      }
      int firstPartNo = Integer.parseInt(DataFileUtil.getPartNo(filePath));
      int SecondPartNo =
          Integer.parseInt(DataFileUtil.getPartNo(((TableBlockInfo) other).filePath));
      compareResult = firstPartNo - SecondPartNo;
    } else {
      compareResult = filePath.compareTo(((TableBlockInfo) other).getFilePath());
    }
    if (compareResult != 0) {
      return compareResult;
    }
    if (blockOffset + blockLength
        < ((TableBlockInfo) other).blockOffset + ((TableBlockInfo) other).blockLength) {
      return -1;
    } else if (blockOffset + blockLength
        > ((TableBlockInfo) other).blockOffset + ((TableBlockInfo) other).blockLength) {
      return 1;
    }
    int diffStartBlockLetNumber =
        blockletInfos.getStartBlockletNumber() - ((TableBlockInfo) other).blockletInfos
            .getStartBlockletNumber();
    if (diffStartBlockLetNumber < 0) {
      return -1;
    }
    if (diffStartBlockLetNumber > 0) {
      return 1;
    }
    return 0;
  }
@ Override public int compareTo ( Distributable other ) { int compareResult = 0 ; double seg1 = Double . parseDouble ( segmentId ) ; double seg2 = Double . parseDouble ( ( ( TableBlockInfo ) other ) . segmentId ) ; if ( seg1 - seg2 < 0 ) { return - 1 ; } if ( seg1 - seg2 > 0 ) { return 1 ; } if ( CarbonTablePath . isCarbonDataFile ( filePath ) ) { int compare = ByteUtil . compare ( DataFileUtil . getTaskNo ( filePath ) . getBytes ( Charset . forName ( CarbonCommonConstants . DEFAULT_CHARSET ) ) , DataFileUtil . getTaskNo ( ( ( TableBlockInfo ) other ) . filePath ) . getBytes ( Charset . forName ( CarbonCommonConstants . DEFAULT_CHARSET ) ) ) ; if ( compare != 0 ) { return compare ; } int firstPartNo = Integer . parseInt ( DataFileUtil . getPartNo ( filePath ) ) ; int SecondPartNo = Integer . parseInt ( DataFileUtil . getPartNo ( ( ( TableBlockInfo ) other ) . filePath ) ) ; compareResult = firstPartNo - SecondPartNo ; } else { compareResult = filePath . compareTo ( ( ( TableBlockInfo ) other ) . getFilePath ( ) ) ; } if ( compareResult != 0 ) { return compareResult ; } if ( blockOffset + blockLength < ( ( TableBlockInfo ) other ) . blockOffset + ( ( TableBlockInfo ) other ) . blockLength ) { return - 1 ; } else if ( blockOffset + blockLength > ( ( TableBlockInfo ) other ) . blockOffset + ( ( TableBlockInfo ) other ) . blockLength ) { return 1 ; } int diffStartBlockLetNumber = blockletInfos . getStartBlockletNumber ( ) - ( ( TableBlockInfo ) other ) . blockletInfos . getStartBlockletNumber ( ) ; if ( diffStartBlockLetNumber < 0 ) { return - 1 ; } if ( diffStartBlockLetNumber > 0 ) { return 1 ; } return 0 ; }
Below method will used to compare to TableBlockInfos object this will
 used for sorting Comparison logic is: 1. compare segment id if segment id
 is same 2. compare task id if task id is same 3. compare offsets of the
 block
Below method will used to compare to TableBlockInfos object this will used for sorting Comparison logic is : 1 . compare segment id if segment id is same 2 . compare task id if task id is same 3 . compare offsets of the block
// get the segment id // converr seg ID to double. // Comparing the time task id of the file to other // if both the task id of the file is same then we need to compare the // offset of // the file // compare the part no of both block info //compare result is not 0 then return // if part no is also same then compare the offset and length of the block //compare the startBlockLetNumber