Skip to Content
Kafka权威指南
book

Kafka权威指南

by Neha Narkhede, Gwen Shapira, Todd Palino
January 2018
Beginner to intermediate
234 pages
7h 8m
Chinese
Posts & Telecom Press
Content preview from Kafka权威指南
流式处理
195
之所以将这种方案叫作流和表的连接,是因为其中的一个流代表了本地缓存表的变更。
11.3.5
 流与流的连接
有时候需要连接两个真实的事件流。什么是“真实”的流?本章开始的时候曾经说过,流
是无边界的。如果使用一个流来表示一个表,那么就可以忽略流的大部分历史事件,因为
你只关心表的当前状态。不过,如果要连接两个流,那么就是在连接所有的历史事件——
将两个流里具有相同键和发生在相同时间窗口内的事件匹配起来。这就是为什么流和流的
连接也叫作基于时间窗口的连接(
windowed-join
)。
假设有一个由网站用户输入的搜索事件流和一个由用户对搜索结果进行点击的事件流。对用
户的搜索和用户对搜索结果的点击进行匹配,就可以知道哪一个搜索的热度更高。很显然,
我们需要基于搜索关键词进行匹配,而且每个关键词只能与一定时间窗口内的事件进行匹
配——假设用户在输入搜索关键词后几秒钟就会点击搜索结果。因此,我们为每一个流维护
了以几秒钟为单位的时间窗口,并对这些时间窗口事件结果进行匹配,如图
11-8
所示。
点击
本地状态
本地状态
5秒钟的时间窗口
连接
连接过的事件
搜索
5秒钟的时间窗口
11-8:连接两个流,通常包含一个移动时间窗
Streams
中,上述的两个流都是通过相同的键来进行分区的,这个键也是用于连接两个
流的键。这样一来,
user_id:42
的点击事件就被保存在点击主题的分区
5
上,而所有
user_
id:42
的搜索事件被保存在搜索主题的分区
5
上。
Streams
可以确保这两个主题的分区
5
事件被分配给同一个任务,这个任务就会得到所有与 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

精通機器學習

精通機器學習

Aurélien Géron
精通特征工程

精通特征工程

Alice Zheng, Amanda Casari
高效能PYTHON程式設計

高效能PYTHON程式設計

Micha Gorelick, Ian Ozsvald

Publisher Resources

ISBN: 9787115473271