Spark RDD地图如何到Cassandra桌子?
我是Spark的新手,最近我看到一个代码将RDD格式的数据保存到Cassandra Table。但是我无法弄清楚它如何进行列映射。它都不使用案例类,也指定了以下代码中的任何列名称:
rdd
.map(x => (x._1, x._2, x_3)) // x is a List here
.repartitionByCassandraReplica(keyspace, tableName)
.saveToCassandra(keyspace, tableName)
因为x内部只是list [(int,string,int)]
,这不是案例类,没有名字映射到卡桑德拉桌子上。因此,在Cassandra表中,是否有任何确定的顺序可以匹配我们在代码中指定的列的顺序?
I am new to Spark, and recently I saw a code is saving data in RDD format to Cassandra table. But I am not able to figure it out how it is doing the column mapping. It neither uses case class, also specifies any column names in the code like below:
rdd
.map(x => (x._1, x._2, x_3)) // x is a List here
.repartitionByCassandraReplica(keyspace, tableName)
.saveToCassandra(keyspace, tableName)
Since x inside is simply a List[(Int, String, Int)]
, which is not a case class, there is no name mapping to Cassandra table. So is there any definite order in Cassandra table that can match the order of columns we specify in the code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
该映射依赖于Cassandra表定义中的列的顺序,如以下内容:
Spark Cassandra Connector依赖于表定义的这些列来自表将与Scala元组中的字段顺序匹配。您可以看到,在源代码
This mapping relies on the order of columns in the Cassandra table definition that is as following:
Spark Cassandra Connector relies that these columns from table definition will be matched to the order of fields in the Scala tuple. You can see that in the source code of
TupleColumnMapper
class.