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权威指南
流式处理
189
事件保存到流里。大部分数据库提供了用于捕捉变更的“
Change Data Capture
”(
CDC
)解
决方案,
Kafka
连接器将这些变更发送到
Kafka
,用于后续的流式处理。
为了将流转化成表,需要“应用”流里所包含的所有变更,这也叫作流的“物化”。首
先在内存里、内部状态存储或外部数据库里创建一个表,然后从头到尾遍历流里的所
有事件,逐个地改变状态。在完成这个过程之后,得到了一个表,它代表了某个时间
点的状态。
假设有一个鞋店,某零售活动可以使用一个事件流来表示:
“红色、蓝色和绿色鞋子到货”
“蓝色鞋子卖出”
“红色鞋子卖出”
“蓝色鞋子退货”
“绿色鞋子卖出”
如果想知道现在仓库里还有哪些库存,或者到目前为止赚了多少钱,需要对视图进行物
化。图
11-1
告诉我们,目前还有蓝色和黄色鞋子,账户上有
170
美元。如果想知道鞋店的
繁忙程度,可以查看整个事件流,会发现总共发生了
5
个交易,还可以查出为什么蓝色鞋
子被退货。
发货
仓库变更事件流
销售退货
蓝色鞋子
红色鞋子
蓝色鞋子
红色鞋子
绿色鞋子
红色鞋子
蓝色鞋子
绿色鞋子
蓝色鞋子
绿色鞋子
代表仓库最新状态
的表或物化视图
11-1:物化仓库变更事件流
11.2.4
 时间窗口
大部分针对流的操作都是基于时间窗口的,比如移动平均数、一周内销量最好的产品、系
统的
99
百分位等。两个流的合并操作也是基于时间窗口的,我们会合并发生在相同时间
片段上的事件。不过,很少人会停下来仔细想想时间窗口的类型。例如,在计算移动平均
数时,需要知道以下几个问题。
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