format/src/main/java/com/github/sadikovi/riff/FileWriter.java
/**
   * Prepare writer. This method initializes stripes, statistics and counters.
   * @throws IOException
   */
Prepare writer. This method initializes stripes, statistics and counters.
Prepare writer . This method initializes stripes statistics and counters .
public void prepareWrite() throws IOException {
    if (writeFinished) throw new IOException("Writer reuse");
    if (writePrepared) return;
    LOG.debug("Prepare file writer {}", this);
    stripeId = 0;
    currentOffset = 0L;
    totalRecords = 0;
    stripes = new ArrayList<StripeInformation>();
    recordWriter = new IndexedRowWriter(td);
    LOG.debug("Initialized record writer {}", recordWriter);
    stripe = new StripeOutputBuffer(stripeId++);
    stripeStream = new OutStream(bufferSize, codec, stripe);
    stripeStats = createStatistics(td);
    stripeFilters = createColumnFilters(td, columnFilterEnabled, numRowsInStripe);
    stripeCurrentRecords = numRowsInStripe;
    LOG.debug("Initialize stripe outstream {}", stripeStream);
    FileHeader fileHeader = new FileHeader(td, fileProperties);
    fileHeader.setState(0, Riff.encodeCompressionCodec(codec));
    try {
      outputStream = fs.create(filePath, false, hdfsBufferSize);
      LOG.debug("Write file header");
      fileHeader.writeTo(outputStream);
    } catch (IOException ioe) {
      if (outputStream != null) {
        outputStream.close();
      }
      throw ioe;
    }
    writePrepared = true;
  }
public void prepareWrite ( ) throws IOException { if ( writeFinished ) throw new IOException ( "Writer reuse" ) ; if ( writePrepared ) return ; LOG . debug ( "Prepare file writer {}" , this ) ; stripeId = 0 ; currentOffset = 0L ; totalRecords = 0 ; stripes = new ArrayList < StripeInformation > ( ) ; recordWriter = new IndexedRowWriter ( td ) ; LOG . debug ( "Initialized record writer {}" , recordWriter ) ; stripe = new StripeOutputBuffer ( stripeId ++ ) ; stripeStream = new OutStream ( bufferSize , codec , stripe ) ; stripeStats = createStatistics ( td ) ; stripeFilters = createColumnFilters ( td , columnFilterEnabled , numRowsInStripe ) ; stripeCurrentRecords = numRowsInStripe ; LOG . debug ( "Initialize stripe outstream {}" , stripeStream ) ; FileHeader fileHeader = new FileHeader ( td , fileProperties ) ; fileHeader . setState ( 0 , Riff . encodeCompressionCodec ( codec ) ) ; try { outputStream = fs . create ( filePath , false , hdfsBufferSize ) ; LOG . debug ( "Write file header" ) ; fileHeader . writeTo ( outputStream ) ; } catch ( IOException ioe ) { if ( outputStream != null ) { outputStream . close ( ) ; } throw ioe ; } writePrepared = true ; }
Prepare writer.
Prepare writer .
// initialize stripe related parameters // create stream for riff file and write header information // mark as initialized