在合并流星火两股 [英] Merging two streams in Spark Streaming

查看:177
本文介绍了在合并流星火两股的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

难道你推我到正确的方向由以下问题? (即使是链接到包含所需信息将是AP preciated的文档。)

Could you push me into right direction by the following question? (Even link to the documentation containing the required info would be appreciated.)

有没有将多个数据流合并成元组流的能力。

Is there any ability to merge multiple streams of data into stream of tuples.

例如。我们已经与元件(A1,T1),(A2,T2),...(安,田纳西州)和流B与元件(B1,T1'),(B2,T2'),......,(流A BN,TN')

E.g. we have stream A with elements (A1, t1), (A2, t2), ...(An, tn) and stream B with elements (B1, t1'), (B2, t2'), ... , (Bn, tn').

其中T是有价值的时间(值时间序列实际上)。

Where t is time of value (values are time series actually).

我想收到价值观物流c

I would like to receive stream C with values

(A1B1,T1),...,(一个,BN,TN)

(A1", B1", t1"), ...,(An", Bn", tn")

从流A和B的时间可能有所不同(这就是为什么我使用'和)。度量可以在不同的时间和不同的速度被消耗掉。在这种情况下,用最新的所需时间标记值必须采取同时合并流。

Time from streams A and B could differ (that's why I am using ' and "). Metrics could be consumed in different time and by different rate. In such case, value with the latest to required time stamp must be taken while merging streams.

推荐答案

您可以使用DStream.join。当上的(K,V)和(K,W)两个成对的DStreams调用,返回(K,(V,W))对的新DSTREAM与所有成对每个键元件。

You can use DStream.join. When called on two DStreams of (K, V) and (K, W) pairs, return a new DStream of (K, (V, W)) pairs with all pairs of elements for each key.

这篇关于在合并流星火两股的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆