【发布时间】:2017-05-19 22:05:12
【问题描述】:
我正在通过 PySpark 探索 Spark Streaming,当我尝试将 transform 函数与 take 一起使用时遇到错误。
我可以通过transform 和pprint 结果成功地使用sortBy 对抗DStream。
author_counts_sorted_dstream = author_counts_dstream.transform\
(lambda foo:foo\
.sortBy(lambda x:x[0].lower())\
.sortBy(lambda x:x[1],ascending=False))
author_counts_sorted_dstream.pprint()
但是如果我按照相同的模式使用take 并尝试pprint 它:
top_five = author_counts_sorted_dstream.transform\
(lambda rdd:rdd.take(5))
top_five.pprint()
作业因
而失败Py4JJavaError: An error occurred while calling o25.awaitTermination. : org.apache.spark.SparkException: An exception was raised by Python: Traceback (most recent call last): File "/usr/local/spark/python/pyspark/streaming/util.py", line 67, in call return r._jrdd AttributeError: 'list' object has no attribute '_jrdd'
你可以在the notebook here看到完整的代码和输出。
我做错了什么?
【问题讨论】:
标签: apache-spark pyspark spark-streaming dstream