Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [geomesa-users] Compilaiton error in Java when applying "map" to an RDD generated via GeoMesaSpark.rdd

Hi Luca,

Great question. Sadly, I haven't used Spark from Java, nor have I used Java 8. That said, from some quick research and knowing Scala, I have a suggestion to try.

To me, the error is saying that the Java 8 lambda isn't being understood as a scala.Function1. There may be some way to help cross that gap, but the Java compiler isn't going to sort that out for you.

Defining the scala.Function1 directly should work though:

import scala.runtime.AbstractFunction1;

public static RDD<Object> loadFromGeoMesaTable(Configuration conf, SparkContext sc) {

scala.Function1 transform = new AbstractFunction1<SimpleFeature, Tweet>() {
            public Tweet apply(SimpleFeature feature) {
                return new Tweet(feature);
            }
        };

        RDD<Object> rddOut = GeoMesaSpark.rdd(conf, sc, null, null, false)
.map( transform, scala.reflect.ClassTag$.MODULE$.apply(Tweet.class));

        return rddOut;
    }

At the very least, this should be closer; I was able to get this to compile.

Cheers,

Jim

On 05/08/2015 05:02 AM, Luca Morandini wrote:
I am trying to generate an RDD of Objects from an RDD of SimpleFeatures, but I was not able to find a way to do it.

Here's the failing code:
public static RDD<Object> loadFromGeoMesaTable(Configuration conf,
      SparkContext sc, GeoMesaOptions options) {

    RDD<Object> rddOut = GeoMesaSpark.rdd(conf, sc,
TweetFeatureStore.getFeatureType(options).getDataStore(), null, false)
        .map((feat) -> {
          return new Tweet(feat);
        }, scala.reflect.ClassTag$.MODULE$.apply(Object.class));

    return rddOut;
  }

Here's the compilation error:
method map in class org.apache.spark.rdd.RDD<T> cannot be applied to given types; [ERROR] required: scala.Function1<org.opengis.feature.simple.SimpleFeature,U>,scala.reflect.ClassTag<U> [ERROR] found: (feat)->{ [...]t); },scala.reflect.ClassTag<java.lang.Object>
[ERROR] reason: cannot infer type-variable(s) U,T
[ERROR] (argument mismatch; scala.Function1 is not a functional interface
[ERROR] multiple non-overriding abstract methods found in interface scala.Function1)

Any help much appreciated,

Luca Morandini
Data Architect - AURIN project
Melbourne eResearch Group
Department of Computing and Information Systems
University of Melbourne
Tel. +61 03 903 58 380
Skype: lmorandini
_______________________________________________
geomesa-users mailing list
geomesa-users@xxxxxxxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
http://www.locationtech.org/mailman/listinfo/geomesa-users



Back to the top