File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -141,28 +141,29 @@ abstract class ArrayData extends SpecializedGetters with Serializable {
141141
142142 def toArray [T : ClassTag ](elementType : DataType ): Array [T ] = {
143143 val size = numElements()
144+ val accessor = InternalRow .getAccessor(elementType)
144145 val values = new Array [T ](size)
145146 var i = 0
146147 while (i < size) {
147148 if (isNullAt(i)) {
148149 values(i) = null .asInstanceOf [T ]
149150 } else {
150- values(i) = get(i, elementType ).asInstanceOf [T ]
151+ values(i) = accessor( this , i ).asInstanceOf [T ]
151152 }
152153 i += 1
153154 }
154155 values
155156 }
156157
157- // todo: specialize this.
158158 def foreach (elementType : DataType , f : (Int , Any ) => Unit ): Unit = {
159159 val size = numElements()
160+ val accessor = InternalRow .getAccessor(elementType)
160161 var i = 0
161162 while (i < size) {
162163 if (isNullAt(i)) {
163164 f(i, null )
164165 } else {
165- f(i, get(i, elementType ))
166+ f(i, accessor( this , i ))
166167 }
167168 i += 1
168169 }
You can’t perform that action at this time.
0 commit comments