Hi all,

I successfully implemented my algorithm in Scala but my team wants it in Java. I have a problem with Generics, can anyone help me?

I have a first JavaPairRDD with a structure like ((ean, key), [from, to, value])

 * ean and key are string
 * from and to are DateTime
 * value is a Double

JavaPairRDD<StringString, List<Serializable>> eanKeyTsParameters = javaRDD.mapToPair( ... );

Then I try to do flatMapValues to apply the GenerateTimeSeries Function, it takes the /from, to /and /values/ to generate a List<LongDouble>. Here is the error I get when compiling:

error: incompatible types: no instance(s) of type variable(s) U exist so that JavaPairRDD<StringString,U> conforms to JavaPairRDD<String,LongDouble>

Here is what IntelliJ tells me:
flatMapValues( Function<List<Serializable>, Iterable<U>> ) in JavaPairRDD cannot be applied to Transformations.GenerateTimeSeries

Here is the problematic transformation:

JavaPairRDD<String, LongDouble> keyLongDouble =
eanKeyTsParameters.flatMapValues(new Transformations.GenerateTimeSeries());

And here is the Function:

import org.apache.spark.api.java.function.Function; [...]

public class Transformations {
    public static class GenerateTimeSeries
            implements Function<List<Serializable>, Iterable<LongDouble>> {

        @Override
        public Iterable<LongDouble> call(List<Serializable> args) {
            DateTime start = (DateTime) args.get(0);
            DateTime end = (DateTime) args.get(1);
            Double value  = (Double) args.get(2);
            int granularity = 24*60*60*1000; // 1 day

return AggregationUtils.createTimeSeries(start, end, value, granularity);
        }
    }
}

Any idea?

Thanks

--

Robin Keunen
Software Engineer
robin.keu...@lampiris.be
www.lampiris.be

Reply via email to