关注 spark技术分享,
撸spark源码 玩spark最佳实践

ForeachSink

ForeachSink

ForeachSink is a typed streaming sink that passes rows (of the type T) to ForeachWriter (one record at a time per partition).

Note
ForeachSink is assigned a ForeachWriter when DataStreamWriter is started.

ForeachSink is used exclusively in foreach operator.

Internally, addBatch (the only method from the Sink Contract) takes records from the input DataFrame (as data), transforms them to expected type T (of this ForeachSink) and (now as a Dataset) processes each partition.

addBatch then opens the constructor’s ForeachWriter (for the current partition and the input batch) and passes the records to process (one at a time per partition).

Caution
FIXME Why does Spark track whether the writer failed or not? Why couldn’t it finally and do close?
Caution
FIXME Can we have a constant for "foreach" for source in DataStreamWriter?
赞(0) 打赏
未经允许不得转载:spark技术分享 » ForeachSink
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏