processing/src/main/java/org/apache/carbondata/processing/store/writer/v3/CarbonFactDataWriterImplV3.java
/**
   * Write the collect blocklet data (blockletDataHolder) to file
   */
Write the collect blocklet data (blockletDataHolder) to file
Write the collect blocklet data ( blockletDataHolder ) to file
private void writeBlockletToFile() {
    List<EncodedTablePage> encodedTablePageList = blockletDataHolder.getEncodedTablePages();
    int numDimensions = encodedTablePageList.get(0).getNumDimensions();
    int numMeasures = encodedTablePageList.get(0).getNumMeasures();
    byte[][] dataChunkBytes = new byte[numDimensions + numMeasures][];
    long metadataSize = fillDataChunk(encodedTablePageList, dataChunkBytes);
    long blockletSize = blockletDataHolder.getSize() + metadataSize;
    createNewFileIfReachThreshold(blockletSize);
    try {
      if (fileChannel.size() == 0) {
        writeHeaderToFile(fileChannel);
      }
      writeBlockletToFile(fileChannel, dataChunkBytes);
      if (listener != null) {
        listener.onBlockletEnd(blockletId++);
      }
      pageId = 0;
    } catch (IOException e) {
      LOGGER.error(e, "Problem while writing file");
      throw new CarbonDataWriterException("Problem while writing file", e);
    }
    blockletDataHolder.clear();
  }
private void writeBlockletToFile ( ) { List < EncodedTablePage > encodedTablePageList = blockletDataHolder . getEncodedTablePages ( ) ; int numDimensions = encodedTablePageList . get ( 0 ) . getNumDimensions ( ) ; int numMeasures = encodedTablePageList . get ( 0 ) . getNumMeasures ( ) ; byte [ ] [ ] dataChunkBytes = new byte [ numDimensions + numMeasures ] [ ] ; long metadataSize = fillDataChunk ( encodedTablePageList , dataChunkBytes ) ; long blockletSize = blockletDataHolder . getSize ( ) + metadataSize ; createNewFileIfReachThreshold ( blockletSize ) ; try { if ( fileChannel . size ( ) == 0 ) { writeHeaderToFile ( fileChannel ) ; } writeBlockletToFile ( fileChannel , dataChunkBytes ) ; if ( listener != null ) { listener . onBlockletEnd ( blockletId ++ ) ; } pageId = 0 ; } catch ( IOException e ) { LOGGER . error ( e , "Problem while writing file" ) ; throw new CarbonDataWriterException ( "Problem while writing file" , e ) ; } blockletDataHolder . clear ( ) ; }
Write the collect blocklet data (blockletDataHolder) to file
Write the collect blocklet data ( blockletDataHolder ) to file
// get the list of all encoded table page // get data chunks for all the column // calculate the total size of data to be written // to check if data size will exceed the block size then create a new file // write data to file // write the header if file is empty // clear the data holder