Repository: spark
Updated Branches:
  refs/heads/master 6c83d938c -> b504b6a90


[SPARK-12470] [SQL] Fix size reduction calculation

also only allocate required buffer size

Author: Pete Robbins <robbin...@gmail.com>

Closes #10421 from robbinspg/master.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/b504b6a9
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/b504b6a9
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/b504b6a9

Branch: refs/heads/master
Commit: b504b6a90a95a723210beb0031ed41a75d702f66
Parents: 6c83d93
Author: Pete Robbins <robbin...@gmail.com>
Authored: Mon Jan 4 10:43:21 2016 -0800
Committer: Davies Liu <davies....@gmail.com>
Committed: Mon Jan 4 10:43:21 2016 -0800

----------------------------------------------------------------------
 .../expressions/codegen/GenerateUnsafeRowJoiner.scala        | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/b504b6a9/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateUnsafeRowJoiner.scala
----------------------------------------------------------------------
diff --git 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateUnsafeRowJoiner.scala
 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateUnsafeRowJoiner.scala
index c9ff357..037ae83 100644
--- 
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateUnsafeRowJoiner.scala
+++ 
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/GenerateUnsafeRowJoiner.scala
@@ -61,9 +61,9 @@ object GenerateUnsafeRowJoiner extends 
CodeGenerator[(StructType, StructType), U
     val outputBitsetWords = (schema1.size + schema2.size + 63) / 64
     val bitset1Remainder = schema1.size % 64
 
-    // The number of words we can reduce when we concat two rows together.
+    // The number of bytes we can reduce when we concat two rows together.
     // The only reduction comes from merging the bitset portion of the two 
rows, saving 1 word.
-    val sizeReduction = bitset1Words + bitset2Words - outputBitsetWords
+    val sizeReduction = (bitset1Words + bitset2Words - outputBitsetWords) * 8
 
     // --------------------- copy bitset from row 1 and row 2 
--------------------------- //
     val copyBitset = Seq.tabulate(outputBitsetWords) { i =>
@@ -171,7 +171,7 @@ object GenerateUnsafeRowJoiner extends 
CodeGenerator[(StructType, StructType), U
        |    // row1: ${schema1.size} fields, $bitset1Words words in bitset
        |    // row2: ${schema2.size}, $bitset2Words words in bitset
        |    // output: ${schema1.size + schema2.size} fields, 
$outputBitsetWords words in bitset
-       |    final int sizeInBytes = row1.getSizeInBytes() + 
row2.getSizeInBytes();
+       |    final int sizeInBytes = row1.getSizeInBytes() + 
row2.getSizeInBytes() - $sizeReduction;
        |    if (sizeInBytes > buf.length) {
        |      buf = new byte[sizeInBytes];
        |    }
@@ -188,7 +188,7 @@ object GenerateUnsafeRowJoiner extends 
CodeGenerator[(StructType, StructType), U
        |    $copyVariableLengthRow2
        |    $updateOffset
        |
-       |    out.pointTo(buf, sizeInBytes - $sizeReduction);
+       |    out.pointTo(buf, sizeInBytes);
        |
        |    return out;
        |  }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to