Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20986#discussion_r179644530
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateUnsafeProjection.scala
 ---
    @@ -286,23 +239,32 @@ object GenerateUnsafeProjection extends 
CodeGenerator[Seq[Expression], UnsafePro
             Platform.putLong($rowWriter.getBuffer(), $tmpCursor - 8, 
$rowWriter.cursor() - $tmpCursor);
     
             ${writeArrayToBuffer(ctx, s"$tmpInput.valueArray()", valueType, 
rowWriter)}
    +        $rowWriter.setOffsetAndSizeFromPreviousCursor($index, 
$previousCursor);
           }
         """
       }
     
    -  /**
    -   * If the input is already in unsafe format, we don't need to go through 
all elements/fields,
    -   * we can directly write it.
    -   */
    -  private def writeUnsafeData(ctx: CodegenContext, input: String, 
rowWriter: String) = {
    -    val sizeInBytes = ctx.freshName("sizeInBytes")
    -    s"""
    -      final int $sizeInBytes = $input.getSizeInBytes();
    -      // grow the global buffer before writing data.
    -      $rowWriter.grow($sizeInBytes);
    -      $input.writeToMemory($rowWriter.getBuffer(), $rowWriter.cursor());
    -      $rowWriter.increaseCursor($sizeInBytes);
    -    """
    +  private def writeElement(
    +    ctx: CodegenContext,
    --- End diff --
    
    4 space indentation


---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to