Github user dongjoon-hyun commented on a diff in the pull request:
https://github.com/apache/spark/pull/20984#discussion_r181140698
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/ArrayData.scala
---
@@ -164,3 +167,46 @@ abstract class ArrayData extends SpecializedGetters
with Serializable {
}
}
}
+
+/**
+ * Implements an `IndexedSeq` interface for `ArrayData`. Notice that if
the original `ArrayData`
+ * is a primitive array and contains null elements, it is better to ask
for `IndexedSeq[Any]`,
+ * instead of `IndexedSeq[Int]`, in order to keep the null elements.
+ */
+class ArrayDataIndexedSeq[T](arrayData: ArrayData, dataType: DataType)
extends IndexedSeq[T] {
+
+ private def getAccessor(dataType: DataType): (Int) => Any = dataType
match {
+ case BooleanType => (idx: Int) => arrayData.getBoolean(idx)
+ case ByteType => (idx: Int) => arrayData.getByte(idx)
+ case ShortType => (idx: Int) => arrayData.getShort(idx)
+ case IntegerType => (idx: Int) => arrayData.getInt(idx)
--- End diff --
`DateType` and `TimestampType`?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]