Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
641 views
in Technique[技术] by (71.8m points)

spark streaming - Custom partiotioning of JavaDStreamPairRDD

In Spark streaming, what's the recommended way to implement a custom partiotioner on DStreams?

I've used the JavaPairRDD.partitionBy(Partitioner) in batch mode but haven't found an equivalent on JavaDStreamPairRDD.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Partitions on DStreams are created by the process of getting data from the receiver. The data stream created by each receiver is cut in micro batches of size spark.streaming.blockInterval (200ms by default) each micro batch becomes a partition on the RDD produced for the streaming interval. Hence, the streaming partitioning is a consequence of micro batching and custom partitioner wouldn't make sense at this level.

If you need those partitions in a certain custom shape, you could repartition each RDD of the DStream:

dstream.foreachRDD{rdd => 
val repRDD = rdd.partitionBy(...)
... do stuff ...
}

Be aware that you pay the shuffle price for repartitioning, so use with care.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...