You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Mohit Anchlia <mo...@gmail.com> on 2015/03/10 21:32:42 UTC

Compilation error on JavaPairDStream

I am getting following error. When I look at the sources it seems to be a
scala source, but not sure why it's complaining about it.

The method map(Function<String,R>) in the type JavaDStream<String> is not
applicable for the arguments (new

PairFunction<String,String,Integer>(){})


And my code has been taken from the spark examples site:


JavaPairDStream<String, Integer> pairs = words.*map*(

 *new* *PairFunction<String, String, Integer>()* {

 @Override *public* Tuple2<String, Integer> call(String s) *throws*
Exception {

 *return* *new* Tuple2<String, Integer>(s, 1);


 }

 });

Re: Compilation error on JavaPairDStream

Posted by Mohit Anchlia <mo...@gmail.com>.
works now. I should have checked :)

On Tue, Mar 10, 2015 at 1:44 PM, Sean Owen <so...@cloudera.com> wrote:

> Ah, that's a typo in the example: use words.mapToPair
> I can make a little PR to fix that.
>
> On Tue, Mar 10, 2015 at 8:32 PM, Mohit Anchlia <mo...@gmail.com>
> wrote:
> > I am getting following error. When I look at the sources it seems to be a
> > scala source, but not sure why it's complaining about it.
> >
> > The method map(Function<String,R>) in the type JavaDStream<String> is not
> > applicable for the arguments (new
> >
> > PairFunction<String,String,Integer>(){})
> >
> >
> > And my code has been taken from the spark examples site:
> >
> >
> > JavaPairDStream<String, Integer> pairs = words.map(
> >
> > new PairFunction<String, String, Integer>() {
> >
> > @Override public Tuple2<String, Integer> call(String s) throws Exception
> {
> >
> > return new Tuple2<String, Integer>(s, 1);
> >
> >
> > }
> >
> > });
> >
> >
>

Re: Compilation error on JavaPairDStream

Posted by Sean Owen <so...@cloudera.com>.
Ah, that's a typo in the example: use words.mapToPair
I can make a little PR to fix that.

On Tue, Mar 10, 2015 at 8:32 PM, Mohit Anchlia <mo...@gmail.com> wrote:
> I am getting following error. When I look at the sources it seems to be a
> scala source, but not sure why it's complaining about it.
>
> The method map(Function<String,R>) in the type JavaDStream<String> is not
> applicable for the arguments (new
>
> PairFunction<String,String,Integer>(){})
>
>
> And my code has been taken from the spark examples site:
>
>
> JavaPairDStream<String, Integer> pairs = words.map(
>
> new PairFunction<String, String, Integer>() {
>
> @Override public Tuple2<String, Integer> call(String s) throws Exception {
>
> return new Tuple2<String, Integer>(s, 1);
>
>
> }
>
> });
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org