JavaRDD 转化为 Dataset方案一:
实体类作为schema定义规范,使用反射,实现JavaRDD转化为Dataset
Student.java实体类:
import java.io.Serializable;
@SuppressWarnings("serial")
public class Student implements Serializable {
private String sid;
private String sname;
private int sage;
public String getSid() {
return sid;
}
public void setSid(String sid) {
this.sid = sid;
}
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
public int getSage() {
return sage;
}
public void setSage(int sage) {
this.sage = sage;
}
@Override
public String toString() {
return "Student