[英]Columns not found in class error
I'm trying to pull certain data out of a cassandra table, and then write it back to a different table in cassandra. 我试图从cassandra表中拉出某些数据,然后将其写回到cassandra中的另一个表中。
This is what I have: 这就是我所拥有的:
JavaRDD<MeasuredValue> mvRDD = javaFunctions(sc).cassandraTable("SB1000_47130646", "Measured_Value", mapRowTo(MeasuredValue.class))
.where ("\"Time_Key\" IN (1601823,1601824)")
.select("Time_Key","Start_Frequency","Bandwidth", "Power");
Then I write back to a new table with: 然后我写回一个新表:
javaFunctions(mvRDD).writerBuilder("spark_reports","SB1000_47130646", mapToRow(MeasuredValue.class)).withColumnSelector(someColumns("Time_Key", "Start_Frequency", "Bandwidth", "Power")).saveToCassandra();
My MeasuredValue Class looks like this: 我的MeasuredValue类看起来像这样:
public static class MeasuredValue implements Serializable {
public MeasuredValue() { }
public MeasuredValue(Long Time_Key, Double Start_Frequency, Double Bandwidth, Float Power) {
this.Time_Key = Time_Key;
this.Start_Frequency = Start_Frequency;
this.Bandwidth = Bandwidth;
this.Power = Power;
}
private Long Time_Key;
public Long gettime_key() { return Time_Key; }
public void settime_key(Long Time_Key) { this.Time_Key = Time_Key; }
private Double Start_Frequency;
public Double getstart_frequency() { return Start_Frequency; }
public void setstart_frequency(Double Start_Frequency) { this.Start_Frequency = Start_Frequency; }
private Double Bandwidth;
public Double getbandwidth() { return Bandwidth; }
public void setbandwidth(Double Bandwidth) { this.Bandwidth = Bandwidth; }
private Float Power;
public Float getpower() { return Power; }
public void setpower(Float Power) { this.Power = Power;
}
The error I get when running is: 运行时出现的错误是:
Exception in thread "main" java.lang.IllegalArgumentException: requirement failed: Columns not found in class com.neutronis.spark_reports.Spark_Reports$MeasuredValue: [Time_Key, Start_Frequency, Bandwidth, Power]
I discovered that this is due to the fact that the getters/setters follow the JAVA naming scheme as far as capital letters and variables. 我发现这是由于以下事实:吸气剂/设置剂在大写字母和变量方面都遵循JAVA命名方案。 Since the columns in my table were camel case I had too reconfigure the column names to a proper all lower case naming convention for it to work correctly. 由于表中的列均为驼峰式,因此我不得不将列名重新配置为适当的所有小写命名约定,以使其正常工作。
In order to use capital letters I had to use a HashMap: 为了使用大写字母,我必须使用HashMap:
HashMap<String,String> colmap = new HashMap<String,String>();
colmap.put( "start_frequency", "Start_Frequency" );
colmap.put( "bandwith", "Bandwidth" );
colmap.put( "power", "Power" );
RowReaderFactory<MeasuredValue> mapRowTo = mapRowTo(MeasuredValue.class, colmap);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.