Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
608 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.8k users

...