获取异常java.util.NoSuchElementException:找不到密钥:' text'在spark-cassandra-connector中

时间:2015-12-16 04:54:15

标签: java cassandra spark-streaming twitter-streaming-api spark-cassandra-connector

我想将spark RDD中的数据保存到cassandra表中。我正在使用spark-cassandra-connector for java from https://github.com/datastax/spark-cassandra-connector

根据文档保存的代码

rddJavaFunctions.writerBuilder("populartweets", "stream_tag_count",
                CassandraJavaUtil.mapToRow(Tag.class)).withColumnSelector(CassandraJavaUtil.someColumns("tag","count"))
                .saveToCassandra();

此操作后我收到错误

    New Cassandra host /127.0.0.1:9042 added
15/12/16 10:18:06 INFO CassandraConnector: Connected to Cassandra cluster: Test Cluster
Exception in thread "main" java.util.NoSuchElementException: key not found: 'text'
    at scala.collection.MapLike$class.default(MapLike.scala:228)
    at scala.collection.AbstractMap.default(Map.scala:58)
    at scala.collection.MapLike$class.apply(MapLike.scala:141)
    at scala.collection.AbstractMap.apply(Map.scala:58)
    at com.datastax.spark.connector.types.ColumnType$.fromDriverType(ColumnType.scala:81)
    at com.datastax.spark.connector.cql.ColumnDef$.apply(Schema.scala:117)
    at com.datastax.spark.connector.cql.Schema$$anonfun$com$datastax$spark$connector$cql$Schema$$fetchPartitionKey$1.apply(Schema.scala:199)
    at com.datastax.spark.connector.cql.Schema$$anonfun$com$datastax$spark$connector$cql$Schema$$fetchPartitionKey$1.apply(Schema.scala:198)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
    at scala.collection.Iterator$class.foreach(Iterator.scala:727)
    at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
    at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
    at scala.collection.AbstractIterable.foreach(Iterable.scala:54)

我正在使用spark 1.5.2

1 个答案:

答案 0 :(得分:-1)

这个问题已经解决了Cassandra 3.x.使用spark-connector 1.5.0-RC1(截至今日)。