Return-Path: X-Original-To: apmail-flink-user-archive@minotaur.apache.org Delivered-To: apmail-flink-user-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7ED5D182C0 for ; Wed, 23 Sep 2015 11:38:01 +0000 (UTC) Received: (qmail 49018 invoked by uid 500); 23 Sep 2015 11:37:56 -0000 Delivered-To: apmail-flink-user-archive@flink.apache.org Received: (qmail 48941 invoked by uid 500); 23 Sep 2015 11:37:56 -0000 Mailing-List: contact user-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@flink.apache.org Delivered-To: mailing list user@flink.apache.org Received: (qmail 48931 invoked by uid 99); 23 Sep 2015 11:37:56 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Sep 2015 11:37:56 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id DF3FBC093F for ; Wed, 23 Sep 2015 11:37:55 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3 X-Spam-Level: *** X-Spam-Status: No, score=3 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id eUsghZFa_WMM for ; Wed, 23 Sep 2015 11:37:54 +0000 (UTC) Received: from mail-qg0-f52.google.com (mail-qg0-f52.google.com [209.85.192.52]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 1A5AA20F5E for ; Wed, 23 Sep 2015 11:37:54 +0000 (UTC) Received: by qgev79 with SMTP id v79so16508688qge.0 for ; Wed, 23 Sep 2015 04:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=huD+KdAFklEzv1kMOO31E8Zk3WCDwa0WO3ur/dlgPDk=; b=m8mZMPDGI1UPEZOLyFgss7mZhVwNdwcmVOx4woy0TOdOAkSjh24qto6z1bsEMf24WQ thLllvkhxAvvcKXcJwkAbXbey6Ak31faPm59ixG+Tfb8OT6XVzgtz6k2Bb+PJXh9jovn 7uD9cLmuJQrbSXkGU0Oimxoptdf+5De7Z0Zusz0xeCWh0y0fJ+PWw9fe8NUBnGIRO9pj YRLuz/CP2asxR+db5/SyNcZwZMYajy+4h3KcosWcK48Um4a6TL7edq6NleVw9VdXQxV8 4chAddaugCh0OnkVq2KANKJTmI80PeAEG16rWUU7nFp3SpSSePVgqapZoYg4iJ5PvCea YZWQ== MIME-Version: 1.0 X-Received: by 10.140.202.210 with SMTP id x201mr37724107qha.0.1443008266915; Wed, 23 Sep 2015 04:37:46 -0700 (PDT) Sender: ewenstephan@gmail.com Received: by 10.55.37.5 with HTTP; Wed, 23 Sep 2015 04:37:46 -0700 (PDT) In-Reply-To: <22186F9B-5EE7-4FC6-9408-087205DC1D23@marmelandia.com> References: <22186F9B-5EE7-4FC6-9408-087205DC1D23@marmelandia.com> Date: Wed, 23 Sep 2015 13:37:46 +0200 X-Google-Sender-Auth: hF0RsrFnX23nSngjyNz8L8eKqVI Message-ID: Subject: Re: Immutable data From: Stephan Ewen To: user@flink.apache.org Content-Type: multipart/alternative; boundary=001a1142767e28560e0520688b7f --001a1142767e28560e0520688b7f Content-Type: text/plain; charset=UTF-8 Hi Jack! This should be supported, there is no strict requirement for mutable types. The POJO rules apply only if you want to use the "by-field-name" addressing for keys. In Scala, you should be able to use case classes as well, even if they are immutable. Can you post the exception that you get? Greetings, Stephan On Wed, Sep 23, 2015 at 1:29 PM, Jack wrote: > Hi, > > I'm having trouble integrating existing Scala code with Flink, due to > POJO-only requirement. > > We're using AnyVal heavily for type safety, and immutable classes as a > default. For example, the following does not work: > > object Test { > class Id(val underlying: Int) extends AnyVal > > class X(var id: Id) { > def this() { this(new Id(0)) } > } > > class MySource extends SourceFunction[X] { > def run(ctx: SourceFunction.SourceContext[X]) { > ctx.collect(new X(new Id(1))) > } > def cancel() {} > } > > def main(args: Array[String]) { > val env = StreamExecutionContext.getExecutionContext > env.addSource(new MySource).print > env.execute("Test") > } > } > > Currently I'm thinking that I would need to have duplicate classes and > code for Flint and for non-Flint code, or somehow use immutable interfaces > for non-Flint code. Both ways are expensive in terms of development time. > > Would you have any guidance on how to integrate Flink with a code base > that has immutability as a norm? > > Thanks --001a1142767e28560e0520688b7f Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Jack!

This should be supported, ther= e is no strict requirement for mutable types.

The = POJO rules apply only if you want to use the "by-field-name" addr= essing for keys. In Scala, you should be able to use case classes as well, = even if they are immutable.

Can you post the excep= tion that you get?

Greetings,
Stephan


= On Wed, Sep 23, 2015 at 1:29 PM, Jack <jack-knilf@marmelandia.com= > wrote:
Hi,

I'm having trouble integrating existing Scala code with Flink, due to P= OJO-only requirement.

We're using AnyVal heavily for type safety, and immutable classes as a = default. For example, the following does not work:

object Test {
=C2=A0 class Id(val underlying: Int) extends AnyVal

=C2=A0 class X(var id: Id) {
=C2=A0 =C2=A0 def this() { this(new Id(0)) }
=C2=A0 }

=C2=A0 class MySource extends SourceFunction[X] {
=C2=A0 =C2=A0 def run(ctx: SourceFunction.SourceContext[X]) {
=C2=A0 =C2=A0 =C2=A0 ctx.collect(new X(new Id(1)))
=C2=A0 =C2=A0 }
=C2=A0 =C2=A0 def cancel() {}
=C2=A0 }

=C2=A0 def main(args: Array[String]) {
=C2=A0 =C2=A0 val env =3D StreamExecutionContext.getExecutionContext
=C2=A0 =C2=A0 env.addSource(new MySource).print
=C2=A0 =C2=A0 env.execute("Test")
=C2=A0 }
}

Currently I'm thinking that I would need to have duplicate classes and = code for Flint and for non-Flint code, or somehow use immutable interfaces = for non-Flint code. Both ways are expensive in terms of development time.
Would you have any guidance on how to integrate Flink with a code base that= has immutability as a norm?

Thanks

--001a1142767e28560e0520688b7f--