用bean的选定属性编写镶木素输出

发布于 2025-02-04 07:29:52 字数 602 浏览 3 评论 0原文

我有一个bean类

@Getter
@Setter
public class Employee {
    String id;
    String name;
    String depart;
    String address;
    final String pipe= "|";

    @Override
    public String toString() {
        return id +pipe+ name +pipe+depart;
    }
}

,我有一个javardd<雇员> emprdd; 当我进行emprdd.saveastext(path);时。我将输出作为基于Tostring方法的输出。 现在,我想在将其转换为dataframe之后写入镶木quet格式,但我只需要(id,name,drake)。我尝试了sqlContext.CreateDataFrame(rdd,employee.class);(语法被忽略),但我不需要所有属性。

任何人都可以指导我完成这个问题。 (这是一个样本,我有350多个属性的Bean类)

I have a bean class

@Getter
@Setter
public class Employee {
    String id;
    String name;
    String depart;
    String address;
    final String pipe= "|";

    @Override
    public String toString() {
        return id +pipe+ name +pipe+depart;
    }
}

And I have a JavaRDD<Employee> emprdd;
and when I do the emprdd.saveAsText(path);. I get the output as based on the toString method.
Now I wanted to write into the parquet format after converting it to the dataframe but I need only (id,name,depart). I tried sqlContext.createDataframe(rdd,Employee.class); (syntax ignored), but I dont need all the properties.

Can anyone guide me through this. (This is a sample , I have bean class with 350+ attributes)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文