ConstantFields in Java API

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

ConstantFields in Java API

Janani Chakkaradhari
Hi,

Can someone check the following UDF for constantFileds setup?

In simple, I wanted to do :
First Input of Join :    Tuple3<Long, FMCounter, Double> first,
Second Input of Join: Tuple2<Long, Long> second
Output:                     Tuple3<second.f0, first.f1, first.f1>


UDF:
    @ConstantFieldsFirst("2 -> 2")
    @ConstantFieldsSecond("0 -> 0")
    public static final class SendingMessageToNeighbors
        extends
        JoinFunction<Tuple3<Long, FMCounter, Double>,
        Tuple2<Long, Long>, Tuple3<Long, FMCounter, Double>> {

        @Override
        public Tuple3<Long, FMCounter, Double> join(
            Tuple3<Long, FMCounter, Double> vertex_workset,
            Tuple2<Long, Long> neighbors) throws Exception {
            return new Tuple3<Long,
                    FMCounter,
Double>(neighbors.f0,vertex_workset.f1,vertex_workset.f2);
        }

    }

Here, I only mapped for two fields (0 and 2) in output tuple. Is it fine?

Regards,
Janani
Reply | Threaded
Open this post in threaded view
|

Re: ConstantFields in Java API

Fabian Hueske
Hi Janani,

You can also use the projection join as:

ds1.join(ds2).where(0).equalTo(0).projectFirst(0).projectSecond(1,2).types(Long.class,
Long.class, Long.class)

That should also automatically set the correct annotations.

Best, Fabian
On Jun 25, 2014 7:41 PM, "Janani Chakkaradhari" <[hidden email]>
wrote:

> Hi,
>
> Can someone check the following UDF for constantFileds setup?
>
> In simple, I wanted to do :
> First Input of Join :    Tuple3<Long, FMCounter, Double> first,
> Second Input of Join: Tuple2<Long, Long> second
> Output:                     Tuple3<second.f0, first.f1, first.f1>
>
>
> UDF:
>     @ConstantFieldsFirst("2 -> 2")
>     @ConstantFieldsSecond("0 -> 0")
>     public static final class SendingMessageToNeighbors
>         extends
>         JoinFunction<Tuple3<Long, FMCounter, Double>,
>         Tuple2<Long, Long>, Tuple3<Long, FMCounter, Double>> {
>
>         @Override
>         public Tuple3<Long, FMCounter, Double> join(
>             Tuple3<Long, FMCounter, Double> vertex_workset,
>             Tuple2<Long, Long> neighbors) throws Exception {
>             return new Tuple3<Long,
>                     FMCounter,
> Double>(neighbors.f0,vertex_workset.f1,vertex_workset.f2);
>         }
>
>     }
>
> Here, I only mapped for two fields (0 and 2) in output tuple. Is it fine?
>
> Regards,
> Janani
>
Reply | Threaded
Open this post in threaded view
|

Re: ConstantFields in Java API

Sebastian Kunert
Hi,

@Fabian: Are you sure that is the case? I don't think that the annotations
are set correctly automatically at the moment. There is a pullrequest open,
but it was not yet merged.

Your UDF looks like field 1 of the first tuple input is also constant:
 @ConstantFieldsFirst("1->1;2 -> 2")
 @ConstantFieldsSecond("0 -> 0")

Regards,

Sebastian


2014-06-25 20:09 GMT+02:00 Fabian Hueske <[hidden email]>:

> Hi Janani,
>
> You can also use the projection join as:
>
>
> ds1.join(ds2).where(0).equalTo(0).projectFirst(0).projectSecond(1,2).types(Long.class,
> Long.class, Long.class)
>
> That should also automatically set the correct annotations.
>
> Best, Fabian
> On Jun 25, 2014 7:41 PM, "Janani Chakkaradhari" <[hidden email]>
> wrote:
>
> > Hi,
> >
> > Can someone check the following UDF for constantFileds setup?
> >
> > In simple, I wanted to do :
> > First Input of Join :    Tuple3<Long, FMCounter, Double> first,
> > Second Input of Join: Tuple2<Long, Long> second
> > Output:                     Tuple3<second.f0, first.f1, first.f1>
> >
> >
> > UDF:
> >     @ConstantFieldsFirst("2 -> 2")
> >     @ConstantFieldsSecond("0 -> 0")
> >     public static final class SendingMessageToNeighbors
> >         extends
> >         JoinFunction<Tuple3<Long, FMCounter, Double>,
> >         Tuple2<Long, Long>, Tuple3<Long, FMCounter, Double>> {
> >
> >         @Override
> >         public Tuple3<Long, FMCounter, Double> join(
> >             Tuple3<Long, FMCounter, Double> vertex_workset,
> >             Tuple2<Long, Long> neighbors) throws Exception {
> >             return new Tuple3<Long,
> >                     FMCounter,
> > Double>(neighbors.f0,vertex_workset.f1,vertex_workset.f2);
> >         }
> >
> >     }
> >
> > Here, I only mapped for two fields (0 and 2) in output tuple. Is it fine?
> >
> > Regards,
> > Janani
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: ConstantFields in Java API

Janani Chakkaradhari
Hi Fabian and Sebastian, thanks for the comments and corrections.




On Wed, Jun 25, 2014 at 8:18 PM, Sebastian Kunert <[hidden email]>
wrote:

> Hi,
>
> @Fabian: Are you sure that is the case? I don't think that the annotations
> are set correctly automatically at the moment. There is a pullrequest open,
> but it was not yet merged.
>
> Your UDF looks like field 1 of the first tuple input is also constant:
>  @ConstantFieldsFirst("1->1;2 -> 2")
>  @ConstantFieldsSecond("0 -> 0")
>
> Regards,
>
> Sebastian
>
>
> 2014-06-25 20:09 GMT+02:00 Fabian Hueske <[hidden email]>:
>
> > Hi Janani,
> >
> > You can also use the projection join as:
> >
> >
> >
> ds1.join(ds2).where(0).equalTo(0).projectFirst(0).projectSecond(1,2).types(Long.class,
> > Long.class, Long.class)
> >
> > That should also automatically set the correct annotations.
> >
> > Best, Fabian
> > On Jun 25, 2014 7:41 PM, "Janani Chakkaradhari" <[hidden email]>
> > wrote:
> >
> > > Hi,
> > >
> > > Can someone check the following UDF for constantFileds setup?
> > >
> > > In simple, I wanted to do :
> > > First Input of Join :    Tuple3<Long, FMCounter, Double> first,
> > > Second Input of Join: Tuple2<Long, Long> second
> > > Output:                     Tuple3<second.f0, first.f1, first.f1>
> > >
> > >
> > > UDF:
> > >     @ConstantFieldsFirst("2 -> 2")
> > >     @ConstantFieldsSecond("0 -> 0")
> > >     public static final class SendingMessageToNeighbors
> > >         extends
> > >         JoinFunction<Tuple3<Long, FMCounter, Double>,
> > >         Tuple2<Long, Long>, Tuple3<Long, FMCounter, Double>> {
> > >
> > >         @Override
> > >         public Tuple3<Long, FMCounter, Double> join(
> > >             Tuple3<Long, FMCounter, Double> vertex_workset,
> > >             Tuple2<Long, Long> neighbors) throws Exception {
> > >             return new Tuple3<Long,
> > >                     FMCounter,
> > > Double>(neighbors.f0,vertex_workset.f1,vertex_workset.f2);
> > >         }
> > >
> > >     }
> > >
> > > Here, I only mapped for two fields (0 and 2) in output tuple. Is it
> fine?
> > >
> > > Regards,
> > > Janani
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: ConstantFields in Java API

Fabian Hueske
In reply to this post by Sebastian Kunert
@Sebastian, Thanks for the correction!
I thought the code was already merged.

Cheers, Fabian


2014-06-25 20:18 GMT+02:00 Sebastian Kunert <[hidden email]>:

> Hi,
>
> @Fabian: Are you sure that is the case? I don't think that the annotations
> are set correctly automatically at the moment. There is a pullrequest open,
> but it was not yet merged.
>
> Your UDF looks like field 1 of the first tuple input is also constant:
>  @ConstantFieldsFirst("1->1;2 -> 2")
>  @ConstantFieldsSecond("0 -> 0")
>
> Regards,
>
> Sebastian
>
>
> 2014-06-25 20:09 GMT+02:00 Fabian Hueske <[hidden email]>:
>
> > Hi Janani,
> >
> > You can also use the projection join as:
> >
> >
> >
> ds1.join(ds2).where(0).equalTo(0).projectFirst(0).projectSecond(1,2).types(Long.class,
> > Long.class, Long.class)
> >
> > That should also automatically set the correct annotations.
> >
> > Best, Fabian
> > On Jun 25, 2014 7:41 PM, "Janani Chakkaradhari" <[hidden email]>
> > wrote:
> >
> > > Hi,
> > >
> > > Can someone check the following UDF for constantFileds setup?
> > >
> > > In simple, I wanted to do :
> > > First Input of Join :    Tuple3<Long, FMCounter, Double> first,
> > > Second Input of Join: Tuple2<Long, Long> second
> > > Output:                     Tuple3<second.f0, first.f1, first.f1>
> > >
> > >
> > > UDF:
> > >     @ConstantFieldsFirst("2 -> 2")
> > >     @ConstantFieldsSecond("0 -> 0")
> > >     public static final class SendingMessageToNeighbors
> > >         extends
> > >         JoinFunction<Tuple3<Long, FMCounter, Double>,
> > >         Tuple2<Long, Long>, Tuple3<Long, FMCounter, Double>> {
> > >
> > >         @Override
> > >         public Tuple3<Long, FMCounter, Double> join(
> > >             Tuple3<Long, FMCounter, Double> vertex_workset,
> > >             Tuple2<Long, Long> neighbors) throws Exception {
> > >             return new Tuple3<Long,
> > >                     FMCounter,
> > > Double>(neighbors.f0,vertex_workset.f1,vertex_workset.f2);
> > >         }
> > >
> > >     }
> > >
> > > Here, I only mapped for two fields (0 and 2) in output tuple. Is it
> fine?
> > >
> > > Regards,
> > > Janani
> > >
> >
>