-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-20783][SQL][Follow-up] Create ColumnVector to abstract existing compressed column #19508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -452,31 +452,10 @@ private[columnar] case object DictionaryEncoding extends CompressionScheme { | |
|
|
||
| class Decoder[T <: AtomicType](buffer: ByteBuffer, columnType: NativeColumnType[T]) | ||
| extends compression.Decoder[T] { | ||
| val elementNum = ByteBufferHelper.getInt(buffer) | ||
| private val dictionary: Array[Any] = new Array[Any](elementNum) | ||
| private var intDictionary: Array[Int] = null | ||
| private var longDictionary: Array[Long] = null | ||
|
|
||
| columnType.dataType match { | ||
| case _: IntegerType => | ||
| intDictionary = new Array[Int](elementNum) | ||
| for (i <- 0 until elementNum) { | ||
| val v = columnType.extract(buffer).asInstanceOf[Int] | ||
| intDictionary(i) = v | ||
| dictionary(i) = v | ||
| } | ||
| case _: LongType => | ||
| longDictionary = new Array[Long](elementNum) | ||
| for (i <- 0 until elementNum) { | ||
| val v = columnType.extract(buffer).asInstanceOf[Long] | ||
| longDictionary(i) = v | ||
| dictionary(i) = v | ||
| } | ||
| case _: StringType => | ||
| for (i <- 0 until elementNum) { | ||
| val v = columnType.extract(buffer).asInstanceOf[Any] | ||
| dictionary(i) = v | ||
| } | ||
|
|
||
| private val dictionary: Array[Any] = { | ||
| val elementNum = ByteBufferHelper.getInt(buffer) | ||
| Array.fill[Any](elementNum)(columnType.extract(buffer).asInstanceOf[Any]) | ||
| } | ||
|
|
||
| override def next(row: InternalRow, ordinal: Int): Unit = { | ||
|
|
@@ -495,6 +474,8 @@ private[columnar] case object DictionaryEncoding extends CompressionScheme { | |
| columnType.dataType match { | ||
| case _: IntegerType => | ||
| val dictionaryIds = columnVector.reserveDictionaryIds(capacity) | ||
| val intDictionary = dictionary.map(_.asInstanceOf[Int]) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @viirya Could you please see this comment to avoid unboxing? IIUC, this code still causes unboxing. What do you think?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't notice that comment. Let me check it then. If we can't avoid, I will revert this and only remove the unused method. Thanks.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @kiszk. I checked the comment and code and reverted this change. |
||
|
|
||
| columnVector.setDictionary(new ColumnDictionary(intDictionary)) | ||
| while (pos < capacity) { | ||
| if (pos != nextNullIndex) { | ||
|
|
@@ -508,6 +489,8 @@ private[columnar] case object DictionaryEncoding extends CompressionScheme { | |
| } | ||
| case _: LongType => | ||
| val dictionaryIds = columnVector.reserveDictionaryIds(capacity) | ||
| val longDictionary = dictionary.map(_.asInstanceOf[Long]) | ||
|
|
||
| columnVector.setDictionary(new ColumnDictionary(longDictionary)) | ||
| while (pos < capacity) { | ||
| if (pos != nextNullIndex) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, it is not used.