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权威指南
190
11
窗口的大小。是基于
5
分钟进行平均,还是
15
分钟,或者一天?窗口越小,就能越快
地发现变更,不过噪声也越多。窗口越大,变更就越平滑,不过延迟也越严重,如果价
格涨了,需要更长的时间才能看出来。
窗口移动的频率(“移动间隔”)。
5
分钟的平均数可以每分钟变化一次,或者每秒钟变
化一次,或者每当有新事件到达时发生变化。如果“移动间隔”与窗口大小相等,这种
情况被称为“滚动窗口(
tumbling window
)”。如果窗口随着每一条记录移动,这种情况
被称为“滑动窗口(
sliding window
)”。
窗口的可更新时间多长。假设计算了
00:00
00:05
之间的移动平均数,一个小时之后
又得到了一些“事件时间”是
00:02
的事件,那么需要更新
00:00
00:05
这个窗口的
结果吗?或者就这么算了?理想情况下,可以定义一个时间段,在这个时间段内,事件
可以被添加到与它们相应的时间片段里。如果事件处于
4
个小时以内,那么就更新它们,
否则就忽略它们。
窗口可以与时间对齐,比如
5
分钟的窗口如果每分钟移动一次,那么第一个分片可以是
00:00~00:05
,第二个就是
00:01~00:06
。它也可以不与时间对齐,应用可以在任何时候启
动,那么第一个分片有可能是
03:17~03:22
。滑动窗口永远不会与时间对齐,因为只要有新
记录到达,它们就会发生移动。图
11-2
展示了这两种时间窗口的不同之处。
滚动窗口——5分钟的时间窗口5分钟滚动一次
时间窗口1 时间窗口2 时间窗口3
时间窗口3
时间
时间
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