processing/src/main/java/org/apache/carbondata/processing/sort/sortdata/SortDataRows.java
/**
   * This method will be used to add new row
   *
   * @param rowBatch new rowBatch
   * @throws CarbonSortKeyAndGroupByException problem while writing
   */
This method will be used to add new row
@param rowBatch new rowBatch
@throws CarbonSortKeyAndGroupByException problem while writing
This method will be used to add new row @param rowBatch new rowBatch @throws CarbonSortKeyAndGroupByException problem while writing
public void addRowBatch(Object[][] rowBatch, int size) throws CarbonSortKeyAndGroupByException {
    synchronized (addRowsLock) {
      int sizeLeft = 0;
      if (entryCount + size >= sortBufferSize) {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug("************ Writing to temp file ********** ");
        }
        intermediateFileMerger.startMergingIfPossible();
        Object[][] recordHolderListLocal = recordHolderList;
        sizeLeft = sortBufferSize - entryCount ;
        if (sizeLeft > 0) {
          System.arraycopy(rowBatch, 0, recordHolderListLocal, entryCount, sizeLeft);
        }
        try {
          semaphore.acquire();
          dataSorterAndWriterExecutorService
              .execute(new DataSorterAndWriter(recordHolderListLocal));
        } catch (Exception e) {
          LOGGER.error(
              "exception occurred while trying to acquire a semaphore lock: " + e.getMessage());
          throw new CarbonSortKeyAndGroupByException(e);
        }
        this.recordHolderList = new Object[this.sortBufferSize][];
        this.entryCount = 0;
        size = size - sizeLeft;
        if (size == 0) {
          return;
        }
      }
      System.arraycopy(rowBatch, sizeLeft, recordHolderList, entryCount, size);
      entryCount += size;
    }
  }
public void addRowBatch ( Object [ ] [ ] rowBatch , int size ) throws CarbonSortKeyAndGroupByException { synchronized ( addRowsLock ) { int sizeLeft = 0 ; if ( entryCount + size >= sortBufferSize ) { if ( LOGGER . isDebugEnabled ( ) ) { LOGGER . debug ( "************ Writing to temp file ********** " ) ; } intermediateFileMerger . startMergingIfPossible ( ) ; Object [ ] [ ] recordHolderListLocal = recordHolderList ; sizeLeft = sortBufferSize - entryCount ; if ( sizeLeft > 0 ) { System . arraycopy ( rowBatch , 0 , recordHolderListLocal , entryCount , sizeLeft ) ; } try { semaphore . acquire ( ) ; dataSorterAndWriterExecutorService . execute ( new DataSorterAndWriter ( recordHolderListLocal ) ) ; } catch ( Exception e ) { LOGGER . error ( "exception occurred while trying to acquire a semaphore lock: " + e . getMessage ( ) ) ; throw new CarbonSortKeyAndGroupByException ( e ) ; } this . recordHolderList = new Object [ this . sortBufferSize ] [ ] ; this . entryCount = 0 ; size = size - sizeLeft ; if ( size == 0 ) { return ; } } System . arraycopy ( rowBatch , sizeLeft , recordHolderList , entryCount , size ) ; entryCount += size ; } }
This method will be used to add new row
 @param rowBatch new rowBatch
 @throws CarbonSortKeyAndGroupByException problem while writing
This method will be used to add new row @param rowBatch new rowBatch @throws CarbonSortKeyAndGroupByException problem while writing
// if record holder list size is equal to sort buffer size then it will // sort the list and then write current list data to file // create the new holder Array