format/src/main/java/com/github/sadikovi/riff/IndexedRowWriter.java
/**
   * Write content of internal row into output stream. This follows specification of [[IndexedRow]]
   * +-----------------------+----------------------------------+
   * | magic as is_null byte | optional null bit set as 8 bytes |
   * +-----------------------+----------------------------------+
   * ...
   * +------------------------+--------------+-----------------------+-------------+
   * | length of index region | index region | length of data region | data region |
   * +------------------------+--------------+-----------------------+-------------+
   * Each region is written similar to Spark SQL UnsafeRow: write fixed part first, where each
   * primitive type is written directly, variable type is written according to row converter,
   * usuallly metadata; write variable part of bytes back to back.
   * If value is null, bit is set and value is skipped.
   *
   * @param row row to write
   * @param out output stream to write to
   */
Write content of internal row into output stream.

@param row row to write
@param out output stream to write to
Write content of internal row into output stream . @param row row to write @param out output stream to write to
public void writeRow(InternalRow row, OutStream out) throws IOException {
    prepareWrite();
    long bitset = getNullSet(row);
    bufferIndexRegion(row);
    bufferDataRegion(row);
    if (bitset == 0) {
      out.write(IndexedRow.MAGIC1);
    } else {
      out.write(IndexedRow.MAGIC2);
      out.writeLong(bitset);
    }
    checkOverflow(this.indexFixedBuffer.bytesWritten(), this.indexVariableBuffer.bytesWritten());
    out.writeInt(this.indexFixedBuffer.bytesWritten() + this.indexVariableBuffer.bytesWritten());
    this.indexFixedBuffer.writeExternal(out);
    this.indexVariableBuffer.writeExternal(out);
    checkOverflow(this.dataFixedBuffer.bytesWritten(), this.dataVariableBuffer.bytesWritten());
    out.writeInt(this.dataFixedBuffer.bytesWritten() + this.dataVariableBuffer.bytesWritten());
    this.dataFixedBuffer.writeExternal(out);
    this.dataVariableBuffer.writeExternal(out);
  }
public void writeRow ( InternalRow row , OutStream out ) throws IOException { prepareWrite ( ) ; long bitset = getNullSet ( row ) ; bufferIndexRegion ( row ) ; bufferDataRegion ( row ) ; if ( bitset == 0 ) { out . write ( IndexedRow . MAGIC1 ) ; } else { out . write ( IndexedRow . MAGIC2 ) ; out . writeLong ( bitset ) ; } checkOverflow ( this . indexFixedBuffer . bytesWritten ( ) , this . indexVariableBuffer . bytesWritten ( ) ) ; out . writeInt ( this . indexFixedBuffer . bytesWritten ( ) + this . indexVariableBuffer . bytesWritten ( ) ) ; this . indexFixedBuffer . writeExternal ( out ) ; this . indexVariableBuffer . writeExternal ( out ) ; checkOverflow ( this . dataFixedBuffer . bytesWritten ( ) , this . dataVariableBuffer . bytesWritten ( ) ) ; out . writeInt ( this . dataFixedBuffer . bytesWritten ( ) + this . dataVariableBuffer . bytesWritten ( ) ) ; this . dataFixedBuffer . writeExternal ( out ) ; this . dataVariableBuffer . writeExternal ( out ) ; }
Write content of internal row into output stream.
Write content of internal row into output stream .
// collect null information // bufffer index region, this fills fixed and variable buffers // bufffer data region, this fills fixed and variable buffers // write values according to specification // we use magic numbers to check if row is written correctly and as indicators of nullability // for each row; nulls are only written if exist // write index region // write data region