Spark Connector - 使用List of Tuples时无法获取数据

时间:2016-08-20 01:19:37

标签: java apache-spark spark-cassandra-connector

我有以下JavaBean定义

public class LiveResultsFrmCassandra implements Serializable{


    UUID id;

    String userdn;
    String queryid;

    private List<Tuple4<String, String, String, String>> docList = new ArrayList();


    public LiveResultsFrmCassandra() {
    }

    public UUID getId() {
        return id;
    }

    public String getUserdn() {
        return userdn;
    }

    public String getQueryid() {
        return queryid;
    }


    public void setId(UUID id) {
        this.id = id;
    }

    public void setUserdn(String userdn) {
        this.userdn = userdn;
    }

    public void setQueryid(String queryid) {
        this.queryid = queryid;
    }

    public List<Tuple4<String, String, String, String>> getDocList() {
        return docList;
    }

    public void setDocList(List<Tuple4<String, String, String, String>> docList) {
        this.docList = docList;
    }
}

我有以下代码使用Spark Connector读取数据,

JavaRDD<LiveResultsFrmCassandra> resultsRDD = javaFunctions(sparkContext).cassandraTable(mf.getConfig().getDatabaseName(), LIVERESULTS, mapRowTo(LiveResultsFrmCassandra.class));

我的表定义如下

CREATE TABLE IF NOT EXISTS LiveResults (
 id uuid PRIMARY KEY,
 doclist list<frozen<tuple<text, text, text, text>>>,
 queryid text,
 userdn text );

我看到数据来自其他字段,但我没有获取docList的数据。有没有人看到过同样的行为?

1 个答案:

答案 0 :(得分:2)

对于docklist使用小写,并使用下面的getter和setter。

List<Tuple4<String, String, String, String>> doclist =  new ArrayList();

public List<Tuple4<String, String, String, String>> getDoclist() {
    return doclist;
}

public void setDoclist(List<Tuple4<String, String, String, String>> doclist) {
    this.doclist = doclist;
}