在 Spark 1.6 中使用 readStream?
use readStream in Spark 1.6?
我是 spark 菜鸟,正在尝试从 Spark 1.6.0 中的套接字读取数据。
以下是我的代码做的是-
val sqc = new org.apache.spark.sql.SQLContext(sc)
val socketop = sqc.readStream.format("socket").option("myhost","localhost").option("port",1111).load
但我收到如下所示的错误 -
readStream is not a member of org.apache.spark.sql.SQLContext
我做错了什么?
参考这个它使用的是spark 1.6,它可能对你有帮助
https://spark.apache.org/docs/1.6.0/streaming-programming-guide.html#a-quick-example
readStream.format("socket")
它在 Spark 1.6.0 中不起作用,因为此代码所属的 Spark Structured Streaming 仅在 Spark 2.0 及更高版本中可用。
引用 Input Sources:
In Spark 2.0, there are a few built-in sources.
Socket source (for testing) - Reads UTF8 text data from a socket connection. The listening server socket is at the driver. Note that this should be used only for testing as this does not provide end-to-end fault-tolerance guarantees.
为了读取 "来自 Spark 1.6.0 套接字的数据" 你必须使用 Spark Streaming(我个人认为它已经死了,建议不要使用除非你必须这样做)。
我是 spark 菜鸟,正在尝试从 Spark 1.6.0 中的套接字读取数据。
以下是我的代码做的是-
val sqc = new org.apache.spark.sql.SQLContext(sc)
val socketop = sqc.readStream.format("socket").option("myhost","localhost").option("port",1111).load
但我收到如下所示的错误 -
readStream is not a member of org.apache.spark.sql.SQLContext
我做错了什么?
参考这个它使用的是spark 1.6,它可能对你有帮助 https://spark.apache.org/docs/1.6.0/streaming-programming-guide.html#a-quick-example
readStream.format("socket")
它在 Spark 1.6.0 中不起作用,因为此代码所属的 Spark Structured Streaming 仅在 Spark 2.0 及更高版本中可用。
引用 Input Sources:
In Spark 2.0, there are a few built-in sources.
Socket source (for testing) - Reads UTF8 text data from a socket connection. The listening server socket is at the driver. Note that this should be used only for testing as this does not provide end-to-end fault-tolerance guarantees.
为了读取 "来自 Spark 1.6.0 套接字的数据" 你必须使用 Spark Streaming(我个人认为它已经死了,建议不要使用除非你必须这样做)。