Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ private[columnar] abstract class BasicColumnAccessor[JvmType](
}

protected def underlyingBuffer = buffer

def getByteBuffer: ByteBuffer =

Copy link
Copy Markdown
Member

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.

buffer.duplicate.order(ByteOrder.nativeOrder())
}

private[columnar] class NullColumnAccessor(buffer: ByteBuffer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The 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?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The 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) {
Expand All @@ -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) {
Expand Down