Github user liancheng commented on a diff in the pull request:
https://github.com/apache/spark/pull/1880#discussion_r16036330
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/columnar/InMemoryColumnarTableScan.scala
---
@@ -43,22 +44,31 @@ private[sql] case class InMemoryRelation(
// As in Spark, the actual work of caching is lazy.
if (_cachedColumnBuffers == null) {
val output = child.output
- val cached = child.execute().mapPartitions { iterator =>
- val columnBuilders = output.map { attribute =>
- ColumnBuilder(ColumnType(attribute.dataType).typeId, 0,
attribute.name, useCompression)
- }.toArray
-
- var row: Row = null
- while (iterator.hasNext) {
- row = iterator.next()
- var i = 0
- while (i < row.length) {
- columnBuilders(i).appendFrom(row, i)
- i += 1
+ val cached = child.execute().mapPartitions { baseIterator =>
+ new Iterator[Array[ByteBuffer]] {
+ def next() = {
+ val columnBuilders = output.map { attribute =>
+ ColumnBuilder(ColumnType(attribute.dataType).typeId, 0,
attribute.name, useCompression)
--- End diff --
A more precise initial buffer size can be used here:
```scala
val columnType = ColumnType(attribute.dataType)
ColumnBuilder(columnType.typeId, columnType.defaultSize * batchSize,
attribute.name, useCompression)
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]