From issues-return-186534-archive-asf-public=cust-asf.ponee.io@spark.apache.org Wed Mar 7 07:56:04 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 CBBA3180676 for ; Wed, 7 Mar 2018 07:56:03 +0100 (CET) Received: (qmail 97216 invoked by uid 500); 7 Mar 2018 06:56:02 -0000 Mailing-List: contact issues-help@spark.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@spark.apache.org Received: (qmail 97207 invoked by uid 99); 7 Mar 2018 06:56:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Mar 2018 06:56:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 53DB11A0FCF for ; Wed, 7 Mar 2018 06:56:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -102.311 X-Spam-Level: X-Spam-Status: No, score=-102.311 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id nYXSVSCFa60h for ; Wed, 7 Mar 2018 06:56:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 036385F1E7 for ; Wed, 7 Mar 2018 06:56:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 74454E0291 for ; Wed, 7 Mar 2018 06:56:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 2CBBC253FB for ; Wed, 7 Mar 2018 06:56:00 +0000 (UTC) Date: Wed, 7 Mar 2018 06:56:00 +0000 (UTC) From: "Reynold Xin (JIRA)" To: issues@spark.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (SPARK-23325) DataSourceV2 readers should always produce InternalRow. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/SPARK-23325?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D163= 89135#comment-16389135 ]=20 Reynold Xin commented on SPARK-23325: ------------------------------------- Yes perhaps we should do that. It is a lot more work than what you guys thi= nk though, because as Wenchen said we need to properly define the semantics= of all the data, similar to all of Hadoop IO (Text, etc) but more, because= we have more data types. I'd probably prefer us defining the columnar format first, since if one is = going after high performance, one'd probably prefer using that one... =C2=A0 > DataSourceV2 readers should always produce InternalRow. > ------------------------------------------------------- > > Key: SPARK-23325 > URL: https://issues.apache.org/jira/browse/SPARK-23325 > Project: Spark > Issue Type: Sub-task > Components: SQL > Affects Versions: 2.3.0 > Reporter: Ryan Blue > Priority: Major > > DataSourceV2 row-oriented implementations are limited to producing either= =C2=A0{{Row}} instances=C2=A0or {{UnsafeRow}} instances by implementing {{S= upportsScanUnsafeRow}}. Instead, I think that implementations should always= produce {{InternalRow}}. > The=C2=A0problem with the choice between {{Row}} and {{UnsafeRow}} is tha= t neither one is appropriate for implementers. > File formats don't produce=C2=A0{{Row}}=C2=A0instances or the data values= used by {{Row}},=C2=A0like=C2=A0{{java.sql.Timestamp}} and {{java.sql.Date= }}.=C2=A0An implementation that uses=C2=A0{{Row}} instances must produce da= ta that is immediately translated from the representation that was just pro= duced by Spark. In my experience, it made little sense to translate a times= tamp in microseconds to=C2=A0a (milliseconds, nanoseconds) pair, create a {= {Timestamp}} instance, and pass that instance to Spark for immediate transl= ation back. > On the other hand, {{UnsafeRow}} is very difficult to produce unless data= is already held in memory. Even the=C2=A0Parquet support built into Spark = deserializes to {{InternalRow}}=C2=A0and then uses {{UnsafeProjection}} to = produce unsafe rows. When I went to build an implementation that deserializ= es Parquet or Avro directly to {{UnsafeRow}}=C2=A0(I tried both), I found t= hat it couldn't be done without first deserializing into memory because the= size of an array must be known before any values are written. > I ended up deciding to=C2=A0deserialize to {{InternalRow}} and=C2=A0use {= {UnsafeProjection}} to convert to unsafe. There are two problems with this:= first, this is Scala and was difficult to call from Java (it required refl= ection), and second, this=C2=A0causes double projection in the physical pla= n (a copy for unsafe to unsafe) if there is a projection that wasn't fully = pushed to the data source. > I think the solution is to have a single interface for readers that expec= ts {{InternalRow}}. Then, a projection should be added in the Spark plan to= convert to unsafe and avoid projection in the plan and in the data source.= If the data source already produces unsafe rows by deserializing directly,= this still minimizes the number of copies because=C2=A0the unsafe projecti= on will check whether the incoming data is already {{UnsafeRow}}. > Using {{InternalRow}} would also match the interface on the write side. -- This message was sent by Atlassian JIRA (v7.6.3#76005) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org For additional commands, e-mail: issues-help@spark.apache.org