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权威指南
202
11
KStream<Integer, UserActivity> userActivityKStream =
viewsWithProfile.leftJoin(searches,
󲣁
(userActivity, search) ->
userActivity.updateSearch(search.getSearchTerms()),
󲣂
JoinWindows.of(1000), Serdes.Integer(),
new UserActivitySerde(), new SearchSerde());
➐
➊
首先为点击事件和搜索事件创建流对象。
➋
为用户信息定义一个
KTable
KTable
是本地缓存,可以通过变更流来对其进行更新。
➌
将点击事件流与信息表连接起来,将用户信息填充到点击事件里。在一个流和表的连接
操作里,每个事件都会收到来自信息表缓存副本里的信息。这是一个左连接操作,所以
如果有的点击事件没有匹配的用户信息,这些事件仍然会被保留下来。
➍
这是连接方法,它接受两个参数,一个来自事件流,一个来自表记录,并返回一个值。
如果是在数据库里,必须知道如何将两个值合并成一个结果。这里创建了一个
activity
对象,它包含了用户的详细信息和用户浏览过的页面。
󲣁
接下来要将点击信息和用户的搜索事件连接起来。这也是一个左连接操作,不过现在连
接的是两个流,而不是流和表。
󲣂
这是连接方法,这里只是简单地将搜索关键词添加到匹配的页面视图。
󲣃
这是最有意思的部分,流和流之间的连接是基于相同的时间窗口。如果只是把每个用户 ...
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