Skip to Content
Kafka权威指南(第2版)
book

Kafka权威指南(第2版)

by Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty
November 2022
Beginner to intermediate
346 pages
11h
Chinese
Posts & Telecom Press
Content preview from Kafka权威指南(第2版)
300
14
➏
这是
join
方法,我们只是简单地将搜索关键词添加到与之匹配的页面浏览事件中。
➐
这部分很有意思。
流和流的连接
是基于时间窗口的。如果只是把每个用户所有的点击事
件和所有的搜索事件连接起来,那么并没有什么意义。我们要把具有相关性的搜索事件
和点击事件连接起来,也就是说,具有相关性的点击事件应该发生在搜索之后的一小段
时间内。所以,我们定义了一个
1
秒的连接时间窗口
。首先调用
of
方法创建了一个在
搜索之前一秒和搜索之后一秒的时间窗口,然后再调用
before
方法,间隔时间为
0
秒,
确保只连接了发生在搜索之后而不是搜索之前一秒的单击事件。结果中将包含相关的点
击、搜索关键词和用户信息。这样有助于对搜索和其结果进行全面的分析。
➑
这里定义了连接结果的
Serde
,包括键和值的
Serde
。在这个例子中,键是用户
ID
,所
以我们使用了简单的
Integer
Serde
定义好流程之后,用它生成
KafkaStreams
对象,并运行这个对象,就像
14.4.1
节中的“字
数统计”示例一样。
这个例子演示了不同类型的两种连接模式,一种是连接流和表,用于将表里的信息填充到
流的事件里,这与在数据仓库中运行查询时连接事实表与维度表有点儿相似;另一种是基
于时间窗口连接两个流,这种操作只会在流式处理中出现。
完整的例子和运行说明可以在
GitHub
网站上找到。
14.5
 
Streams
架构概览
前面演示了如何使用
Streams API
实现众所周知的流式处理设计模式。为了更好地理解
Streams
的工作原理,需要深入了解并理解 ...
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

时间序列分析实战:基于机器学习和统计学

时间序列分析实战:基于机器学习和统计学

Aileen Nielsen
Spark机器学习实战

Spark机器学习实战

Posts & Telecom Press, Siamak Amirghodsi, Meenakshi Rajendran, Broderick Hall, Shuen Mei
写给系统管理员的Python脚本编程指南

写给系统管理员的Python脚本编程指南

Posts & Telecom Press, Ganesh Sanjiv Naik
Kubernetes编程

Kubernetes编程

Michael Hausenblas, Stefan Schimanski

Publisher Resources

ISBN: 9787115601421