diff options
author | Liang-Chi Hsieh <viirya@gmail.com> | 2014-09-02 20:51:25 -0700 |
---|---|---|
committer | Michael Armbrust <michael@databricks.com> | 2014-09-02 20:51:25 -0700 |
commit | 24ab384018270e4f7af7eb8ca7192f337498eaf5 (patch) | |
tree | 0779cdbe04c3262a6e94f7262e78db9d752c91d5 /sql | |
parent | 19d3e1e8e9c25c0936c0ad6efbc2092b473723aa (diff) | |
download | spark-24ab384018270e4f7af7eb8ca7192f337498eaf5.tar.gz spark-24ab384018270e4f7af7eb8ca7192f337498eaf5.tar.bz2 spark-24ab384018270e4f7af7eb8ca7192f337498eaf5.zip |
[SPARK-3300][SQL] No need to call clear() and shorten build()
The function `ensureFreeSpace` in object `ColumnBuilder` clears old buffer before copying its content to new buffer. This PR fixes it.
Author: Liang-Chi Hsieh <viirya@gmail.com>
Closes #2195 from viirya/fix_buffer_clear and squashes the following commits:
792f009 [Liang-Chi Hsieh] no need to call clear(). use flip() instead of calling limit(), position() and rewind().
df2169f [Liang-Chi Hsieh] should clean old buffer after copying its content.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/core/src/main/scala/org/apache/spark/sql/columnar/ColumnBuilder.scala | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/sql/core/src/main/scala/org/apache/spark/sql/columnar/ColumnBuilder.scala b/sql/core/src/main/scala/org/apache/spark/sql/columnar/ColumnBuilder.scala index 7e7bb2859b..247337a875 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/columnar/ColumnBuilder.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/columnar/ColumnBuilder.scala @@ -75,8 +75,7 @@ private[sql] class BasicColumnBuilder[T <: DataType, JvmType]( } override def build() = { - buffer.limit(buffer.position()).rewind() - buffer + buffer.flip().asInstanceOf[ByteBuffer] } } @@ -129,7 +128,6 @@ private[sql] object ColumnBuilder { val newSize = capacity + size.max(capacity / 8 + 1) val pos = orig.position() - orig.clear() ByteBuffer .allocate(newSize) .order(ByteOrder.nativeOrder()) |