@@ -452,31 +452,10 @@ private[columnar] case object DictionaryEncoding extends CompressionScheme {
452452
453453 class Decoder [T <: AtomicType ](buffer : ByteBuffer , columnType : NativeColumnType [T ])
454454 extends compression.Decoder [T ] {
455- val elementNum = ByteBufferHelper .getInt(buffer)
456- private val dictionary : Array [Any ] = new Array [Any ](elementNum)
457- private var intDictionary : Array [Int ] = null
458- private var longDictionary : Array [Long ] = null
459-
460- columnType.dataType match {
461- case _ : IntegerType =>
462- intDictionary = new Array [Int ](elementNum)
463- for (i <- 0 until elementNum) {
464- val v = columnType.extract(buffer).asInstanceOf [Int ]
465- intDictionary(i) = v
466- dictionary(i) = v
467- }
468- case _ : LongType =>
469- longDictionary = new Array [Long ](elementNum)
470- for (i <- 0 until elementNum) {
471- val v = columnType.extract(buffer).asInstanceOf [Long ]
472- longDictionary(i) = v
473- dictionary(i) = v
474- }
475- case _ : StringType =>
476- for (i <- 0 until elementNum) {
477- val v = columnType.extract(buffer).asInstanceOf [Any ]
478- dictionary(i) = v
479- }
455+
456+ private val dictionary : Array [Any ] = {
457+ val elementNum = ByteBufferHelper .getInt(buffer)
458+ Array .fill[Any ](elementNum)(columnType.extract(buffer).asInstanceOf [Any ])
480459 }
481460
482461 override def next (row : InternalRow , ordinal : Int ): Unit = {
@@ -495,6 +474,8 @@ private[columnar] case object DictionaryEncoding extends CompressionScheme {
495474 columnType.dataType match {
496475 case _ : IntegerType =>
497476 val dictionaryIds = columnVector.reserveDictionaryIds(capacity)
477+ val intDictionary = dictionary.map(_.asInstanceOf [Int ])
478+
498479 columnVector.setDictionary(new ColumnDictionary (intDictionary))
499480 while (pos < capacity) {
500481 if (pos != nextNullIndex) {
@@ -508,6 +489,8 @@ private[columnar] case object DictionaryEncoding extends CompressionScheme {
508489 }
509490 case _ : LongType =>
510491 val dictionaryIds = columnVector.reserveDictionaryIds(capacity)
492+ val longDictionary = dictionary.map(_.asInstanceOf [Long ])
493+
511494 columnVector.setDictionary(new ColumnDictionary (longDictionary))
512495 while (pos < capacity) {
513496 if (pos != nextNullIndex) {
0 commit comments