protected long writeDataToFile(NodeHolder nodeHolder,FileChannel channel) throws CarbonDataWriterException {
  byte[][] compressedIndex=nodeHolder.getCompressedIndex();
  byte[][] compressedIndexMap=nodeHolder.getCompressedIndexMap();
  byte[][] compressedDataIndex=nodeHolder.getCompressedDataIndex();
  int indexBlockSize=0;
  int index=0;
  for (int i=0; i < nodeHolder.getKeyBlockIndexLength().length; i++) {
    indexBlockSize+=nodeHolder.getKeyBlockIndexLength()[index++] + CarbonCommonConstants.INT_SIZE_IN_BYTE;
  }
  for (int i=0; i < nodeHolder.getDataIndexMapLength().length; i++) {
    indexBlockSize+=nodeHolder.getDataIndexMapLength()[i];
  }
  ByteBuffer byteBuffer=ByteBuffer.allocate(nodeHolder.getKeyArray().length + nodeHolder.getDataArray().length + indexBlockSize);
  long offset=0;
  try {
    offset=channel.size();
    byteBuffer.put(nodeHolder.getKeyArray());
    byteBuffer.put(nodeHolder.getDataArray());
    ByteBuffer buffer1=null;
    for (int i=0; i < compressedIndex.length; i++) {
      buffer1=ByteBuffer.allocate(nodeHolder.getKeyBlockIndexLength()[i]);
      buffer1.putInt(compressedIndex[i].length);
      buffer1.put(compressedIndex[i]);
      if (compressedIndexMap[i].length > 0) {
        buffer1.put(compressedIndexMap[i]);
      }
      buffer1.rewind();
      byteBuffer.put(buffer1.array());
    }
    for (int i=0; i < compressedDataIndex.length; i++) {
      byteBuffer.put(compressedDataIndex[i]);
    }
    byteBuffer.flip();
    channel.write(byteBuffer);
  }
 catch (  IOException exception) {
    throw new CarbonDataWriterException("Problem in writing carbon file: ",exception);
  }
  return offset;
}

protected long writeDataToFile ( NodeHolder nodeHolder , FileChannel channel ) throws CarbonDataWriterException { byte [ ] [ ] compressedIndex = nodeHolder . getCompressedIndex ( ) ; byte [ ] [ ] compressedIndexMap = nodeHolder . getCompressedIndexMap ( ) ; byte [ ] [ ] compressedDataIndex = nodeHolder . getCompressedDataIndex ( ) ; int indexBlockSize = 0 ; int index = 0 ; for ( int i = 0 ; i < nodeHolder . getKeyBlockIndexLength ( ) . length ; i ++ ) { indexBlockSize += nodeHolder . getKeyBlockIndexLength ( ) [ index ++ ] + CarbonCommonConstants . INT_SIZE_IN_BYTE ; } for ( int i = 0 ; i < nodeHolder . getDataIndexMapLength ( ) . length ; i ++ ) { indexBlockSize += nodeHolder . getDataIndexMapLength ( ) [ i ] ; } ByteBuffer byteBuffer = ByteBuffer . allocate ( nodeHolder . getKeyArray ( ) . length + nodeHolder . getDataArray ( ) . length + indexBlockSize ) ; long offset = 0 ; try { offset = channel . size ( ) ; byteBuffer . put ( nodeHolder . getKeyArray ( ) ) ; byteBuffer . put ( nodeHolder . getDataArray ( ) ) ; ByteBuffer buffer1 = null ; for ( int i = 0 ; i < compressedIndex . length ; i ++ ) { buffer1 = ByteBuffer . allocate ( nodeHolder . getKeyBlockIndexLength ( ) [ i ] ) ; buffer1 . putInt ( compressedIndex [ i ] . length ) ; buffer1 . put ( compressedIndex [ i ] ) ; if ( compressedIndexMap [ i ] . length > 0 ) { buffer1 . put ( compressedIndexMap [ i ] ) ; } buffer1 . rewind ( ) ; byteBuffer . put ( buffer1 . array ( ) ) ; } for ( int i = 0 ; i < compressedDataIndex . length ; i ++ ) { byteBuffer . put ( compressedDataIndex [ i ] ) ; } byteBuffer . flip ( ) ; channel . write ( byteBuffer ) ; } catch ( IOException exception ) { throw new CarbonDataWriterException ( "Problem in writing carbon file: " , exception ) ; } return offset ; }
this method is responsible for writing blocklet to the data file
