processing/src/main/java/org/apache/carbondata/processing/loading/sort/unsafe/merger/UnsafeIntermediateFileMerger.java
/**
   * Below method will be used to write data to file
   *
   * @throws CarbonSortKeyAndGroupByException problem while writing
   */
Below method will be used to write data to file
@throws CarbonSortKeyAndGroupByException problem while writing
Below method will be used to write data to file @throws CarbonSortKeyAndGroupByException problem while writing
private void writeDataToFile(Object[] row) throws CarbonSortKeyAndGroupByException, IOException {
    int dimCount = 0;
    int size = 0;
    for (; dimCount < isNoDictionaryDimensionColumn.length; dimCount++) {
      if (isNoDictionaryDimensionColumn[dimCount]) {
        byte[] col = (byte[]) row[dimCount];
        rowData.putShort((short) col.length);
        size += 2;
        rowData.put(col);
        size += col.length;
      } else {
        rowData.putInt((int) row[dimCount]);
        size += 4;
      }
    }
    int dimensionSize = dimCnt + complexCnt;
    for (; dimCount < dimensionSize; dimCount++) {
      byte[] col = (byte[]) row[dimCount];
      rowData.putShort((short)col.length);
      size += 2;
      rowData.put(col);
      size += col.length;
    }
    Arrays.fill(nullSetWords, 0);
    int nullSetSize = nullSetWords.length * 8;
    int nullLoc = size;
    size += nullSetSize;
    for (int mesCount = 0; mesCount < measureCnt; mesCount++) {
      Object value = row[mesCount + dimensionSize];
      if (null != value) {
        DataType dataType = measureDataTypes[mesCount];
        if (dataType == DataTypes.SHORT) {
          rowData.putShort(size, (Short) value);
          size += 2;
        } else if (dataType == DataTypes.INT) {
          rowData.putInt(size, (Integer) value);
          size += 4;
        } else if (dataType == DataTypes.LONG) {
          rowData.putLong(size, (Long) value);
          size += 8;
        } else if (dataType == DataTypes.DOUBLE) {
          rowData.putDouble(size, (Double) value);
          size += 8;
        } else if (DataTypes.isDecimal(dataType)) {
          byte[] bigDecimalInBytes = DataTypeUtil.bigDecimalToByte(((BigDecimal) value));
          rowData.putShort(size, (short) bigDecimalInBytes.length);
          size += 2;
          for (int i = 0; i < bigDecimalInBytes.length; i++) {
            rowData.put(size++, bigDecimalInBytes[i]);
          }
        }
        UnsafeCarbonRowPage.set(nullSetWords, mesCount);
      } else {
        UnsafeCarbonRowPage.unset(nullSetWords, mesCount);
      }
    }
    for (int i = 0; i < nullSetWords.length; i++) {
      rowData.putLong(nullLoc, nullSetWords[i]);
      nullLoc += 8;
    }
    byte[] rowBytes = new byte[size];
    rowData.position(0);
    rowData.get(rowBytes);
    stream.write(rowBytes);
    rowData.clear();
  }
private void writeDataToFile ( Object [ ] row ) throws CarbonSortKeyAndGroupByException , IOException { int dimCount = 0 ; int size = 0 ; for ( ; dimCount < isNoDictionaryDimensionColumn . length ; dimCount ++ ) { if ( isNoDictionaryDimensionColumn [ dimCount ] ) { byte [ ] col = ( byte [ ] ) row [ dimCount ] ; rowData . putShort ( ( short ) col . length ) ; size += 2 ; rowData . put ( col ) ; size += col . length ; } else { rowData . putInt ( ( int ) row [ dimCount ] ) ; size += 4 ; } } int dimensionSize = dimCnt + complexCnt ; for ( ; dimCount < dimensionSize ; dimCount ++ ) { byte [ ] col = ( byte [ ] ) row [ dimCount ] ; rowData . putShort ( ( short ) col . length ) ; size += 2 ; rowData . put ( col ) ; size += col . length ; } Arrays . fill ( nullSetWords , 0 ) ; int nullSetSize = nullSetWords . length * 8 ; int nullLoc = size ; size += nullSetSize ; for ( int mesCount = 0 ; mesCount < measureCnt ; mesCount ++ ) { Object value = row [ mesCount + dimensionSize ] ; if ( null != value ) { DataType dataType = measureDataTypes [ mesCount ] ; if ( dataType == DataTypes . SHORT ) { rowData . putShort ( size , ( Short ) value ) ; size += 2 ; } else if ( dataType == DataTypes . INT ) { rowData . putInt ( size , ( Integer ) value ) ; size += 4 ; } else if ( dataType == DataTypes . LONG ) { rowData . putLong ( size , ( Long ) value ) ; size += 8 ; } else if ( dataType == DataTypes . DOUBLE ) { rowData . putDouble ( size , ( Double ) value ) ; size += 8 ; } else if ( DataTypes . isDecimal ( dataType ) ) { byte [ ] bigDecimalInBytes = DataTypeUtil . bigDecimalToByte ( ( ( BigDecimal ) value ) ) ; rowData . putShort ( size , ( short ) bigDecimalInBytes . length ) ; size += 2 ; for ( int i = 0 ; i < bigDecimalInBytes . length ; i ++ ) { rowData . put ( size ++ , bigDecimalInBytes [ i ] ) ; } } UnsafeCarbonRowPage . set ( nullSetWords , mesCount ) ; } else { UnsafeCarbonRowPage . unset ( nullSetWords , mesCount ) ; } } for ( int i = 0 ; i < nullSetWords . length ; i ++ ) { rowData . putLong ( nullLoc , nullSetWords [ i ] ) ; nullLoc += 8 ; } byte [ ] rowBytes = new byte [ size ] ; rowData . position ( 0 ) ; rowData . get ( rowBytes ) ; stream . write ( rowBytes ) ; rowData . clear ( ) ; }
Below method will be used to write data to file
 @throws CarbonSortKeyAndGroupByException problem while writing
Below method will be used to write data to file @throws CarbonSortKeyAndGroupByException problem while writing
// write complex dimensions here.