format/src/main/java/com/github/sadikovi/riff/IndexedRowWriter.java
/**
   * Buffer current region into fixed and variable buffers.
   * If field is not null we write fixed portion of value and variable bytes (if applicable). For
   * variable part we maintain offset (as total number of bytes written for fixed part) so each row
   * converter is supposed to write necessary metadata to access raw bytes in variable part.
   */
Buffer current region into fixed and variable buffers.
If field is not null we write fixed portion of value and variable bytes (if applicable). For
variable part we maintain offset (as total number of bytes written for fixed part) so each row
converter is supposed to write necessary metadata to access raw bytes in variable part.
Buffer current region into fixed and variable buffers . If field is not null we write fixed portion of value and variable bytes ( if applicable ) . For variable part we maintain offset ( as total number of bytes written for fixed part ) so each row converter is supposed to write necessary metadata to access raw bytes in variable part .
private void bufferRegion(
      InternalRow row,
      TypeSpec[] fields,
      OutputBuffer fixedBuffer,
      OutputBuffer variableBuffer) throws IOException {
    int fixedOffset = 0;
    for (int i = 0; i < fields.length; i++) {
      if (!row.isNullAt(fields[i].origSQLPos())) {
        fixedOffset += this.converters[fields[i].position()].byteOffset();
      }
    }
    for (int i = 0; i < fields.length; i++) {
      if (!row.isNullAt(fields[i].origSQLPos())) {
        this.converters[fields[i].position()].writeDirect(
          row, fields[i].origSQLPos(), fixedBuffer, fixedOffset, variableBuffer);
      }
    }
    if (fixedBuffer.bytesWritten() != fixedOffset) {
      throw new AssertionError(
        "Written bytes " + fixedBuffer.bytesWritten() + " != " + fixedOffset + " bytes");
    }
  }
private void bufferRegion ( InternalRow row , TypeSpec [ ] fields , OutputBuffer fixedBuffer , OutputBuffer variableBuffer ) throws IOException { int fixedOffset = 0 ; for ( int i = 0 ; i < fields . length ; i ++ ) { if ( ! row . isNullAt ( fields [ i ] . origSQLPos ( ) ) ) { fixedOffset += this . converters [ fields [ i ] . position ( ) ] . byteOffset ( ) ; } } for ( int i = 0 ; i < fields . length ; i ++ ) { if ( ! row . isNullAt ( fields [ i ] . origSQLPos ( ) ) ) { this . converters [ fields [ i ] . position ( ) ] . writeDirect ( row , fields [ i ] . origSQLPos ( ) , fixedBuffer , fixedOffset , variableBuffer ) ; } } if ( fixedBuffer . bytesWritten ( ) != fixedOffset ) { throw new AssertionError ( "Written bytes " + fixedBuffer . bytesWritten ( ) + " != " + fixedOffset + " bytes" ) ; } }
Buffer current region into fixed and variable buffers.
Buffer current region into fixed and variable buffers .
// compute total offset for fixed part // write value using row converters // assertion should hold for fixed part