You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by Amit Pawar <am...@gmail.com> on 2015/05/28 01:30:59 UTC

Adding custom Tuple to a DataSet

Hi

Is there a way, where I can add a custom (newly created) Tuple to a new
DataSet or already existing DataSet?

DataSet set = env.fromElements (myCustomTuple);
works fine, but only with same datatype in case of Tuple2 or higher.
Tuple2<String,Long> creates a problem (as stated in JavaDoc it needs all
elements to be of same type).

Is there any workaround? Or using fromCollection is the only option?

Thanks for your help in advance.

Thanks and Regards
Amit Pawar

Re: Adding custom Tuple to a DataSet

Posted by Amit Pawar <am...@gmail.com>.
Thanks Stephan :)
Will try the same.

Thanks and Regards
Amit Pawar


On Thu, May 28, 2015 at 10:41 AM, Stephan Ewen <se...@apache.org> wrote:

> Hi!
>
> If you want to have type hierarchies (like base tuples and different
> classes), you cannot use tuples (they are expected to be 'exact schema'),
> but you can use other classes. Create your own tuple POJO with subclasses,
> and it should work.
>
> Stephan
>
>
> On Thu, May 28, 2015 at 1:30 AM, Amit Pawar <am...@gmail.com>
> wrote:
>
> > Hi
> >
> > Is there a way, where I can add a custom (newly created) Tuple to a new
> > DataSet or already existing DataSet?
> >
> > DataSet set = env.fromElements (myCustomTuple);
> > works fine, but only with same datatype in case of Tuple2 or higher.
> > Tuple2<String,Long> creates a problem (as stated in JavaDoc it needs all
> > elements to be of same type).
> >
> > Is there any workaround? Or using fromCollection is the only option?
> >
> > Thanks for your help in advance.
> >
> > Thanks and Regards
> > Amit Pawar
> >
>

Re: Adding custom Tuple to a DataSet

Posted by Stephan Ewen <se...@apache.org>.
Hi!

If you want to have type hierarchies (like base tuples and different
classes), you cannot use tuples (they are expected to be 'exact schema'),
but you can use other classes. Create your own tuple POJO with subclasses,
and it should work.

Stephan


On Thu, May 28, 2015 at 1:30 AM, Amit Pawar <am...@gmail.com> wrote:

> Hi
>
> Is there a way, where I can add a custom (newly created) Tuple to a new
> DataSet or already existing DataSet?
>
> DataSet set = env.fromElements (myCustomTuple);
> works fine, but only with same datatype in case of Tuple2 or higher.
> Tuple2<String,Long> creates a problem (as stated in JavaDoc it needs all
> elements to be of same type).
>
> Is there any workaround? Or using fromCollection is the only option?
>
> Thanks for your help in advance.
>
> Thanks and Regards
> Amit Pawar
>