From reviews-return-634762-archive-asf-public=cust-asf.ponee.io@spark.apache.org Thu Apr 12 18:18:13 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id AE9F4180634 for ; Thu, 12 Apr 2018 18:18:12 +0200 (CEST) Received: (qmail 44472 invoked by uid 500); 12 Apr 2018 16:18:11 -0000 Mailing-List: contact reviews-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list reviews@spark.apache.org Received: (qmail 44452 invoked by uid 99); 12 Apr 2018 16:18:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Apr 2018 16:18:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 07375E09E2; Thu, 12 Apr 2018 16:18:11 +0000 (UTC) From: dongjoon-hyun To: reviews@spark.apache.org Reply-To: reviews@spark.apache.org References: In-Reply-To: Subject: [GitHub] spark pull request #20984: [SPARK-23875][SQL] Add IndexedSeq wrapper for Arr... Content-Type: text/plain Message-Id: <20180412161811.07375E09E2@git1-us-west.apache.org> Date: Thu, 12 Apr 2018 16:18:11 +0000 (UTC) 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: reviews-unsubscribe@spark.apache.org For additional commands, e-mail: reviews-help@spark.apache.org