I have a mapFunction as below
Function1 mapFunction = ( record ) ->{
CompanyInfoTransformedRecord transRec = new CompanyInfoTransformedRecord();
//popluate
return transRec ;
};
Which takes CompanyInfoRecordNew object and return CompanyInfoTransformedRecord.
But while invoking this as below
JavaRDD companyInfoTransformedRecord = baseDs.map(mapFunction, comanyInfoTransEncoder);
Giving Error :
The method map(Function1, Encoder) in the type Dataset is not applicable for the arguments (Function1, Encoder)
What is wrong here ?
Code Link for the same :
How to return a List from map function?
Code updated in the link
Section 2 :
MapFunction> mapFunction = ( record ) ->{
List transRecList = new ArrayList();
return transRecList ;
}
Dataset> companyInfoTransformedRecords = baseDs.map(mapFunction, comanyInfoTransEncoder);
//Error
The method map(Function1, Encoder) in the
type Dataset is not applicable for the arguments
MapFunction>,
Encoder)
companyInfoTransformedRecord.show();
Not able to do show due to error , how to get show() working. ??
解决方案
Your imports are wrong, instead of this:
import org.apache.calcite.linq4j.function.Function1;
Use this
org.apache.spark.api.java.function.MapFunction;
baseDs.map(new MapFunction() {...}, encoder);