Exam Review and Preparation Guidance
Prerequisite Knowledge
This lecture builds on the following concepts from earlier lectures. If any feel unfamiliar, review the linked notes before proceeding.
Previously Covered in This Subject
- Batch vs stream processing — covered in Lecture 1 (1.6) and Lecture 4 (4.1)
- Lambda and Kappa architectures — covered in Lecture 4 (4.5)
- Message delivery semantics — covered in Lecture 6 (6.2) and Lecture 7 (7.1)
- Kafka streaming and the producer–consumer demo — covered in Lecture 9 (9.2)
- RDD versus Structured Streaming — covered in Lecture 9 (9.3.3)
- Spark transformations and actions — covered in Lecture 11 (11.1.1)
- The streaming word count over micro-batches — covered in Lecture 11 (11.2)
- Tumbling and sliding windows — covered in Lecture 11 (11.6, 11.7) and Lecture 12 (12.2, 12.3)
- Timing diagram basics and the batch interval — covered in Lecture 12 (12.1)
- Reservoir sampling — covered in Lecture 12 (12.8) and Lecture 13 (13.1)
- The decaying window algorithm — covered in Lecture 13 (13.3)
- The Bloom filter and the Count-Min Sketch — covered in Lecture 14 (14.1, 14.2)
15.1 Exam Blueprint: The Three Sample Questions
Hook: Three sample questions describe the entire exam. The professor walked through all three before even sharing the paper — so each one carries real weight about what will be asked and how.
The session opened as a review: a walk through the sample questions before the paper itself was shared. The three questions form the exam blueprint — one on Spark Structured Streaming, one on the Count-Min Sketch, and one on Spark transformations and actions. The message that runs through all three: the exam is problem-based, so know how to do each technique, not just how to talk about it.
15.1.1 Question 1 — Spark Structured Streaming and the Timing Diagram
The first sample question is built around Spark Structured Streaming. It expects you to recall what was covered in class: the Spark Structured Streaming model and the timing diagram.
A timing diagram shows how the streaming engine processes micro-batches over time. It is a picture of the streaming loop, and every exam answer on it should walk the same four steps:
- Arrival — data arrives from the source (a socket, Kafka, a file directory) as a continuous stream of records.
- Batching — the engine collects everything that arrived since the last interval into a small batch, called a micro-batch.
- Processing — the micro-batch runs through the same query you would write for batch data (filters, groupings, aggregations).
- Emission — the result of that batch is written out, the next interval starts, and the loop repeats.
The question will ask you to draw or explain that diagram: what happens at each step of the streaming pipeline. Keep the loop in order — arrival, grouping into a batch, processing, emission — because the marks sit on the sequence, not on decoration.
Worked example — one timing diagram, ten-second batches. Suppose the stream emits records at seconds 0, 3, 7, 12, 15, 22 (wall-clock arrival times) and the engine forms a micro-batch every 10 seconds.
- Arrival: records land continuously at 0, 3, 7, 12, 15, 22.
- Batching: batch 1 collects records from [0, 10) — arrivals at 0, 3, 7. Batch 2 collects [10, 20) — arrivals at 12, 15. Batch 3 collects [20, 30) — the arrival at 22.
- Processing: each batch runs the same query; for word count, batch 1 produces counts from three records, batch 2 from two, batch 3 from one.
- Emission: results are written out at t = 10 (batch 1), t = 20 (batch 2), t = 30 (batch 3).
Sense check: every record lands in exactly one batch, each batch is processed once, and the output timestamps are the batch boundaries — the diagram's shape is a staircase of arrivals stepping up, then flat processing lines, then emitted results at fixed intervals.
A solution to this question is provided alongside the sample paper, so there is no need to worry about whether your version is right. The guidance given was direct: refer to the class notes on Spark Structured Streaming, and the timing diagram exactly as it was explained in class.
Exam note: the number of pages in the sample paper and similar packaging details can be ignored. What matters is the content of the three questions. For this one: the timing diagram exactly as it was explained in class, supported by the class notes.
15.1.2 Question 2 — Count-Min Sketch Table Construction
The second sample question is an algorithm problem on the Count-Min Sketch. The name of the algorithm was also rendered as "quantum mean sketch" and "Count Moon sketch" in places; those are mishearings of the spoken name — the technique taught in class is the Count-Min Sketch, and that is the name to write in the exam.
You should be constructing the Count-Min Sketch table: given a stream of items and a set of hash functions, fill in the sketch table, row by row, and use it to answer frequency-estimation questions. This is a hands-on problem: you are given the items, the hash functions, and an empty table, and you must produce the completed table plus the estimated counts.
The one caveat emphasized in class: when you apply hash functions, sometimes the hash value can be zero. The exam will state explicitly whether the table's index starts from zero or from one — whether to resume from one or start indices from zero — so read that convention from the question itself and apply it consistently. Section 15.5 covers this question in full detail, including a worked table under both conventions.
Exam note: expect this style of problem — build the table, do not just explain the concept. The solution to this sample question is also provided; if you notice anything you would change in it, you can raise it — that is not a problem.
15.1.3 Question 3 — Spark Transformations, Actions, and the Lifecycle
The third sample question is about Spark transformations and actions, and the entire Spark lifecycle related to them.
The Spark lifecycle in four stages:
- Load — read the input data into a distributed collection.
- Transform — chain transformations (
map,filter,groupByKey); nothing computes yet. - Build the DAG — the engine records every transformation as a lineage graph of steps.
- Act — an action (
count,collect,saveAsTextFile) triggers job execution; only now does the actual computation run.
A Spark program builds a lineage of transformations — nothing executes at the moment you call a transformation — and only when an action is invoked does the engine actually evaluate the computation. The lifecycle question ties these together: from loading the data, through the DAG of transformations, to the action that triggers job execution.
The order matters more than it looks: the transformation stage is nearly free (the engine just records the operation), while the action stage is where every job's real cost lands. Section 15.4 goes deeper into the lazy behavior this depends on.
15.1.4 Format Facts: Open Book, Numerical, Balanced
The exam is open book. When asked directly, the answer was confirmed: yes, it is open book only.
Q: It is open book only, right? A: Yes, it is open book only.
The student who had previewed the model sample paper observed that the exam looked largely numerical this time and asked whether that was the case. It is: the exam is going to be more numerical this time, but that does not mean there are no theory questions — it will be balanced. Numerical problems will carry most of the weight, with conceptual questions sitting alongside them.
Q: It is going to be largely numerical this time, as I can see from the model sample paper, right? A: Yes, it is going to be more numerical this time. But it is not that you will not have theory questions — it will be balanced.
Exam note: expect problems, not essays. The guidance was explicit — it will expect only problems, no theory or derivation. Even though derivations were done in class, they will not be asked in the exam. The numerical problems will still have some conceptual questions attached to them, so keep the concepts, not just the calculations.
That combination — open book, numerical, balanced, problem-only — sets the study direction for everything that follows: learn to perform the techniques, and carry the concept that sits under each one.
15.2 Where the Weightage Sits: 30% Pre-Mid-Sem, 70% Post-Mid-Sem
15.2.1 What the Mid-Sem Already Tested
The course split into two major halves, and the exam weightage follows that split: roughly 30% pre-mid-semester content and 70% post-mid-semester content. That split is the single most useful number for planning revision — it tells you where marks live, so it tells you where hours should go.
The mid-sem already tested the architecture-side items: message delivery semantics, when to use which architecture, and the differences between batch processing and stream processing. These were the architecture topics, and they are now checked off — the exam will not re-ask them at depth.
One student was confused about message writing mechanisms — the instructor clarified that message writing was among the things discussed in the mid-sem: there are certain aspects, like writing directly or writing indirectly, that were covered then. Some parts can be ignored; just go through the topics listed and it will come back.
Q: I'm confused about message writing mechanisms — I studied message delivery semantics, but I can't recall message writing. What is it? A: Message writing mechanisms were among the things we discussed in the mid-sem — there are certain aspects, like writing directly or writing indirectly. You can ignore some of it. Just go through these topics.
The distinction the student was tripping on: message delivery semantics (the guarantees about whether a message arrives, such as at-least-once or at-most-once delivery) and message writing mechanisms (how a producer actually writes messages into the system — directly, or indirectly through an intermediate component) are two different topics. Both were covered before the mid-sem. If either one feels foggy, a quick pass over the pre-mid-sem list is enough to bring it back — this is 30% material, not the place to invest deep revision.
15.2.2 Where to Spend Your Time Now
The architecture aspect was already evaluated in the mid-sem, so do not spend too much time on it — except a few topics. Do not develop too much into pre-mid-sem content: generalized streaming architecture, Lambda architecture, Kappa architecture, message delivery semantics, and how data gets into the system. On those, only look at the basics — the differences between batch processing, stream processing, and real-time processing.
The reason for stating this is direction: "You should know where to focus." The post-mid-sem portion — algorithms and structured streaming — is where the weight sits, and the sample questions reflect that: two of the three sample questions are streaming-related.
Exam note: 30% pre-mid-sem, 70% post-mid-sem. Spend your effort accordingly — algorithms and structured streaming first, architecture basics only.
15.2.3 The "Dirty Frog" Study Plan
The professor's study rule: "We should always eat the dirty frog first" — meaning do the ugliest, most important topic first while you still have energy, rather than the comfortable parts.
The analogy is a sequencing rule for revision. Picture your topic list as a plate of frogs: some look ugly and taste worse, some are fine. Everyone naturally picks the fine ones first and pushes the ugly one aside — and then the ugly one is all that is left when energy runs out. The professor's rule inverts that instinct: eat the dirty frog first. The "dirty frog" here is the most important topic that feels hardest — the algorithms and structured streaming material — so you face it at your freshest and feel confident early.
Mapping it to this course:
| Study rule | What it means here |
|---|---|
| Dirty frog first | Count-Min Sketch, Bloom filter, reservoir sampling, decaying window, Structured Streaming — the 70% post-mid-sem material |
| Comfortable topics later | Architecture basics (Lambda, Kappa, generalized) — thin revision is enough |
| Why the order | Confidence builds early; the heavy topics are not rushed at the last minute |
Other topics are not unimportant, but the highlighted ones — the algorithms and structured streaming — should come first so you feel confident early. The extra special classes exist precisely so the techniques can be discussed in detail instead of being rushed in the last class, when people get nervous.
Where the analogy breaks: a frog stays ugly no matter when you eat it. Revision topics do not — with the post-mid-sem material done first, the remaining architecture topics become lighter, so the plan is not about punishment, it is about ordering effort while energy is high.
15.3 The Course at a Glance: Architecture and Processing
The course was divided into two major aspects: architecture and processing. Keeping that split in mind is useful because the weightage split follows it — architecture was mostly tested in the mid-sem, processing (algorithms and structured streaming) carries the post-mid-sem exam.
15.3.1 The Architecture Side
Under architecture, the class covered:
- batch processing, stream processing, and real-time processing, and the differences between them;
- data: the sources of data, and after data ingestion, the common interaction patterns;
- the components of the Lambda architecture, the Kappa architecture, and the generalized architecture;
- message delivery semantics and the importance of long-term storage;
- the message-routing mechanisms (the recording rendered this as "message-rating"; the surrounding discussion of message delivery and long-term storage points to routing or ordering as the intended topic).
The message-routing item is the only one whose phrasing is unclear in the recording; the surrounding discussion is about message delivery and long-term storage, so routing or ordering is the likely intent. If the sample paper or your class notes use a different name for this item, follow those.
Scope: the architecture side was already evaluated in the mid-sem. For the final exam, only the basics are needed: how batch, stream, and real-time processing differ, and a working sense of the three architectures — not every component in depth. Treat this list as a names-to-recognize inventory, not a deep-revision list.
15.3.2 The Processing Side
Under processing, the class worked with PySpark:
- the difference between RDD and Structured Streaming;
- various clauses, like group by and where — how you group records, the same way SQL statements group them;
- the word count problem, and the streaming version of word count;
- setting up Kafka path integration;
- as part of the assignment, how to run machine learning experiments in PySpark;
- streaming algorithms.
Q: Is complex event processing part of the slide material? A: The answer was not preserved. Treat complex event processing as part of the broader stream-processing discussion rather than a separately weighted topic, unless the sample paper says otherwise.
Another student was confused about Spark's place in the stack — Spark resides in the processing layer. The answer pointed to the links shared from the Spark documentation in earlier classes; refer to those.
Q: I'm a little confused about Spark. It resides in the processing layer, right? A: Yes — I shared some links from the Spark documentation in the earlier classes. Just refer to those.
15.3.3 Streaming Algorithms Covered
Under streaming algorithms, a few are important: the Bloom filter, the Count-Min Sketch, reservoir sampling, and the decaying window. These algorithms are the core machinery of stream analytics — approximate membership testing (Bloom filter), approximate frequency counting (Count-Min Sketch), unbiased random sampling from a stream (reservoir sampling), and recency-weighted aggregation (decaying window).
Each one answers a different question about a stream, so it helps to keep them separated by question type:
| Algorithm | Question it answers | One-line method | Typical trade-off |
|---|---|---|---|
| Bloom filter | "Have I seen this item before?" | Set bits with hash functions in an -bit array | False positives possible, false negatives impossible |
| Count-Min Sketch | "How many times has this item appeared?" | counter rows, one per hash function; estimate by row minimum | Slight over-counts, tiny memory |
| Reservoir sampling | "Give me a fixed-size random sample of the whole stream" | Keep items; replace with probability | Sample is unbiased but not exact in time order |
| Decaying window | "What is the recent weighted aggregate?" | Weight old observations less than new ones | Recency bias by design |
Real-world: the same ideas power production stream-processing pipelines — Bloom filters in database and cache layers, Count-Min sketches in network monitoring and analytics engines, reservoir sampling wherever a fixed-size random sample of an unbounded stream is needed.
15.4 Lazy Evaluation in Spark
15.4.1 The Question and the Answer
A student asked a question that reveals a common gap: the class covered wide and narrow transformations, but the student did not remember whether lazy transformation was studied. The answer connected the two ideas: lazy transformation is nothing but the wide transformation — the evaluation is delayed until the point where it has to be evaluated. Lazy means expression evaluation is delayed till the point where it is needed.
Q: We studied wide and narrow transformations, but I don't remember studying lazy transformation. What is a lazy transformation? A: Lazy transformation is nothing but wide transformation only. Evaluation will be delayed till the point where it has to be evaluated. Lazy means expression evaluation is delayed till the point where it is needed.
The point of the correction: the student had learned the idea without attaching the name. The name "lazy transformation" was not a separate topic to remember — it is the same deferred-evaluation behavior, and in this course the term is tied to the wide transformation. Once the name is connected to the behavior, the topic stops looking like a gap.
15.4.2 Lazy Versus Wide: What the Terms Mean
Two ideas are being joined here. Wide transformations are transformations that need data from other partitions — shuffles — like groupByKey, join, or distinct. Narrow transformations work on data within one partition — like map or filter — and can be executed without shuffling.
Analogy — the kitchen model of laziness: writing a transformation is like writing down a recipe: you list the steps on paper, and nothing in the kitchen changes. Calling an action is like starting to cook: only now does food get chopped, mixed, and plated. Writing the recipe is cheap and can be postponed; cooking is where all the work and cost happen. The lazy engine writes as much of the recipe as it can and only cooks when the meal is actually needed — which is why Spark feels instant while you build transformations and slow when you call an action.
Laziness is a property of the whole Spark lifecycle: building a transformation only records the operation in the lineage; no computation happens until an action forces it. Wide transformations in particular are postponed because they are expensive — the engine waits, collects the lineage, and then evaluates. So "lazy" and "wide" describe different axes, but in the way this course treats them for the exam, the lazy transformation is the wide transformation: the point being that its evaluation is deferred until it is needed.
| Dimension | Narrow transformation | Wide transformation |
|---|---|---|
| Data needed | One partition only | Other partitions (shuffle) |
| Examples | map, filter | groupByKey, join, distinct |
| Execution | Can run locally per partition | Needs data movement across nodes |
| Postponed because | Not especially expensive | Expensive — the engine defers them |
The two axes, made explicit: narrow vs wide says where the data comes from (same partition or other partitions). Lazy vs eager says when the computation runs (never at call time, only when an action demands it). The professor's exam shorthand collapses these: the lazy transformation is the wide transformation, because both descriptions single out the operations whose evaluation is deferred until they are truly needed.
That single idea is the backbone of the Spark lifecycle question in Section 15.1.3: transformations build a plan, actions trigger execution, and laziness is why building a transformation is cheap but evaluating it is where the work happens.
15.5 The Count-Min Sketch Question in Detail
15.5.1 How the Table Is Built
The Count-Min Sketch answers one question about a stream: how many times has this item appeared? It trades exactness for memory — a small two-dimensional table instead of a full count per item.
Purpose: estimate item frequencies in a stream too large to store, using a fixed-size table. The name comes from the two-step idea: count first, then take the minimum to read the answer. Inputs: the stream of items , a chosen depth (number of hash functions / rows), a chosen width (number of columns per row), and hash functions mapping items to columns. Outputs: for any queried item , an estimated frequency that never undercounts and may slightly overcount.
Construction: the sketch is a table of rows and columns. Each row gets its own hash function , mapping an item to a column of that row. For every incoming item , you hash it with every hash function and add one to the cell it lands in. Because different items can collide into the same cell, the counts are over-estimates — a cell may hold the counts of several colliding items.
The steps in exam order:
- Draw the table: rows (one per hash function ) and columns, every cell started at 0.
- For each incoming item , compute — one column per row.
- Add 1 to each of those cells, one per row.
- When asked for the frequency of , hash again with all functions and take the smallest of the cell values.
The verbal description of the table in this session: you should be constructing this Count-Min Sketch table. Only thing is that — when you do hash functions, sometimes the hash value might be zero.
15.5.2 The Hash-Value-Zero Convention
This is the specific trap the exam flags: a hash function can output zero. The point was made twice for emphasis: "Sometimes the hash value might be zero. The hash value is zero. We will tell that."
The exam question will tell you which convention applies — whether to resume from one, or whether the start indices start from zero. In other words: if the hash value is 0, does that mean column index 1, or column index 0? Apply the stated convention consistently across the whole table, because a single off-by-one error cascades through every row.
Worked example — one stream, two conventions. Stream: a, b, c, a, b, a (6 items). The exam gives hash functions and columns:
| Hash function | a | b | c |
|---|---|---|---|
| 1 | 2 | 1 | |
| 0 | 3 | 0 | |
| 2 | 1 | 2 |
Note returns 0 for both a and c — this is exactly where the convention bites.
Trace, zero-indexed columns (hash value = column index):
| Item | Row | Row | Row |
|---|---|---|---|
a |
+1 at col 1 | +1 at col 0 | +1 at col 2 |
b |
+1 at col 2 | +1 at col 3 | +1 at col 1 |
c |
+1 at col 1 | +1 at col 0 | +1 at col 2 |
a |
+1 at col 1 | +1 at col 0 | +1 at col 2 |
b |
+1 at col 2 | +1 at col 3 | +1 at col 1 |
a |
+1 at col 1 | +1 at col 0 | +1 at col 2 |
Final table (columns 0 to 7):
| col 0 | col 1 | col 2 | col 3 | col 4–7 | |
|---|---|---|---|---|---|
| row | 0 | 4 | 2 | 0 | 0 |
| row | 4 | 0 | 0 | 2 | 0 |
| row | 0 | 2 | 4 | 0 | 0 |
Estimates (row-wise minimum): , , .
Trace, one-indexed columns (cell index = hash value + 1, so hash 0 lands in column 1): the same items land one column to the right in every row.
| col 1 | col 2 | col 3 | col 4 | col 5–8 | |
|---|---|---|---|---|---|
| row | 0 | 4 | 2 | 0 | 0 |
| row | 4 | 0 | 0 | 2 | 0 |
| row | 0 | 2 | 4 | 0 | 0 |
Estimates are unchanged: , , .
Sense check: a appears 3 times, b 2 times, c once. Every row gives a count that is at least the true count: a and c collide in all three rows, so each of their cells also carries the other's count — their estimates inflate to 4, while collision-free b stays exact at 2. That is the sketch working as designed: never undercount, and read the answer from the least-inflated row.
Exam note: this detail is exactly what separates a clean table from a failed problem. Read the question's index convention first, then build every row the same way.
15.5.3 The Update and Estimate Rules
With the sketch table, the number of hash functions (rows), the number of columns, and the hash function of row , the update for an incoming item is:
where is the item, indexes the row, and is the column that maps to under row 's hash function. This is the standard form: hash the item with every row's hash function and increment each target cell by 1, exactly as the class's table construction describes.
The frequency estimate for an item takes the minimum over the rows — the cell with the least count bounds the true count from above:
where is the estimated frequency of , and the minimum over rows is what makes collisions hurt least: the true count is at most this value, and no single collision inflates every row.
The reason the minimum works: every row gives a count that is at least the true frequency, and errors come from collisions with other items. The smallest count across rows is the closest to the truth. Concretely, a row can only gain from collisions — each colliding item adds 1 to a shared cell — so row 's value is the true count plus the collision noise of that row. The minimum picks the row with the least noise.
Assumption and scope: counts only grow — the sketch supports additions, not deletions (the references call this the Cash Register model, where every frequency stays non-negative). If the stream could remove items, the estimate logic changes. Also, accuracy depends on the hash functions being pairwise independent; weak hash functions make collisions more likely and the estimates noisier.
The standard guarantee bounds how bad the overcount can be. If the sketch has width and depth , then with probability at least the estimate for an item whose true count is falls between and , where is the total number of items entered. Two practical sizes from the course references: width 40 with depth 7 keeps the estimate within 5% of the total with 99% probability; depth 8 with width 128 gives about 1.5% relative error at about 99.6% probability. That is why a small fixed table can stand in for unbounded per-item counters: memory stays and each update or query costs hash computations, no matter how long the stream runs.
Pitfalls:
- Using the wrong zero convention — if the question says indices start from one and you keep hash 0 as column 0, every row that touches a zero-valued hash is wrong.
- Applying the convention row by row differently — pick the convention once and use it for every row and every item.
- Forgetting that cells accumulate collisions, so a single cell value is never a trustworthy count by itself; always read the row-wise minimum.
- Quoting the table as if it were exact — the sketch overestimates by design; the exam asks for the estimated count, and the estimate is the minimum.
Recap: count into every row, read the minimum, never undercount. When building the table in the exam, work row by row — for each hash function, list the hash value per item, apply the zero-convention from the question, add one to that cell, and then answer the frequency question with the row-wise minimum.
15.6 Structured Streaming: The Word Count Problem and Window Concepts
15.6.1 Word Count in Structured Streaming
Structured streaming was covered in detail in the course — the word count problem being the canonical example. The streaming word count mirrors the batch word count: read a stream of text, split it into words, and aggregate counts over the arriving data. The difference is that the aggregation happens over micro-batches as data streams in, not once over a static file.
The emphasis was explicit: focus more on algorithms and structured streaming, because structured streaming was done in detail — like the word count problem and other things; for the class notes, just refer to them.
Batch versus streaming word count:
| Step | Batch word count | Streaming word count |
|---|---|---|
| Input | One static file | Continuous stream of records |
| Splitting | Split every line once | Split every arriving record |
| Aggregation | One full pass over the file | Incremental counts over micro-batches |
| When results exist | After the single run ends | After every micro-batch, continuously |
Algorithms are the core part of structured streaming. You may wonder why the course did not start with algorithms if they are so central. The reason given: unless you have a formal understanding of these techniques, discussing just the algorithms becomes a little dry. So the course laid the foundation first, then built the algorithms on top of it.
Exam note: the sample question on Structured Streaming is about the timing diagram — whatever was explained in class: how micro-batches are formed from the stream, processed, and emitted. A solution is provided with the sample paper.
15.6.2 Group By and Where Clauses
Within PySpark, the class looked at various clauses, including group by and where. A student asked about the group by clause — the instructor confirmed it was discussed: it is how you group records, like SQL statements group them.
Q: The group by clause — where was that? What is it? A: Yes, we discussed the group by clause — how you group records, like SQL statements.
Group by splits the data into groups by key so that aggregations (counts, sums) apply per group; where filters rows. In structured streaming both clauses work on the streaming DataFrame the same way they do in batch — the engine turns the query into the same plan, then executes it incrementally over micro-batches.
| Clause | What it does | Typical use |
|---|---|---|
groupBy |
Splits records into groups by key | groupBy("word").count() — the heart of word count |
where |
Keeps only rows that pass a condition | where("count > 10") or a filter on arrival |
The SQL connection is the fastest way to stay oriented: any query you can write for a static table, you can write for the streaming DataFrame — the engine just runs it repeatedly, once per micro-batch.
15.6.3 Window Concepts and the Spark Documentation
Window concepts were explained using the Spark documentation: links were shared while explaining windowing — how streaming aggregations are bucketed over time windows (tumbling or sliding), which is how the timing diagram in the sample question ties to real behavior.
Q: In the Spark documentation, you shared some links while explaining window concepts, right? A: Yes — please refer to those links.
Windowed aggregation answers a timing question that word count alone cannot: "how many occurrences fell inside this time bucket?" Two window shapes matter:
- Tumbling window — fixed-size, non-overlapping buckets. A 1-minute tumbling window yields bucket 0–1 min, 1–2 min, 2–3 min; each event belongs to exactly one bucket.
- Sliding window — fixed-size buckets that overlap. With a 10-minute window sliding every 5 minutes, an event at 12:00 belongs to the 11:50–12:00 bucket and the 11:55–12:05 bucket.
The timing diagram question is the visual of this machinery: events arriving on the left, micro-batches formed at each interval, the windowed query applied, and results emitted on the right — then the next interval begins.
Real-world: windowing is what makes streaming analytics usable in production — dashboards and alerting systems aggregate over time windows rather than per event, exactly the pattern the Spark documentation shows.
Exam note: to be safe on the timing-diagram question, go through the windowing sections of the Spark documentation links plus the class notes; that combination covers the streaming question.
15.7 Answer Strategy and Exam-Day Advice
15.7.1 Be Specific, Not Verbose
The single most direct piece of exam technique: don't write some verbose thing — be specific on what is expected, and that will save everybody's time mutually. Answer exactly what the question asks, in the format it expects: a constructed table, a drawn timing diagram, a lifecycle walk-through. Extra prose does not earn extra marks in an open-book, problem-heavy exam.
The format of the answer is part of the answer. If the question asks for the Count-Min Sketch table, draw the table with every cell filled; if it asks for the timing diagram, draw the micro-batch loop; if it asks for the lifecycle, walk the stages in order. Unrequested explanation is not a safety net — it is time spent that could have been spent checking the artifact.
15.7.2 Regular Versus Makeup
Asked about the makeup exam, the advice was to prefer the regular exam — especially for this course. The student confirmed the regular slot, as in the mid-sem.
Q: Should we give the makeup exam instead? A: Don't prefer to give makeup exams, especially for this course. Regular only.
15.7.3 Practical Preparation
The sample paper was shared on the course channel during the session — check there if you missed it.
Q: The sample paper you were sharing today — is it available? A: Give me one minute — I will put it there in the course channel.
The sample questions come with solutions, and if you find anything you would change in a solution, you can raise it. The solutions are a working reference, not a secret answer key — questioning them is part of understanding.
On preparation overall: spend enough time on the class notes, and focus on the topics that were highlighted. It is not that other topics are unimportant — it is a question of direction and of where the weight sits (Section 15.2). Also, if any area still feels weak — Spark itself, for example — go back to the documentation links shared in class rather than searching the internet blind.
Exam note: expect numerical problems, open book, balanced with conceptual questions; be specific in answers; prefer the regular exam.
15.8 The Approach Behind the Course
15.8.1 Why Orchestration Fear Is the Real Barrier
The reasoning behind how the course was taught: most working professionals get afraid and frightened when they look at the installation and orchestration side of these systems — Kafka, Zookeeper, and related tools. That fear blocks learning before the concepts even start. So the course was shaped to minimize that complexity: everything was demonstrated on a laptop with simple steps, packaged as a final set of steps in a text file — follow the file and it works without referring to the internet for anything.
The insight: the barrier to these systems is not the ideas — it is the setup. A fixed, tested step file removes the unknown unknowns of installation, so the concepts can be learned without the fear of orchestration standing in the way.
Real-world: Kafka's path integration (streaming data into Spark) and Zookeeper's coordination role are exactly the pieces people find intimidating; the course's message is that these tools are complex but there is a way to learn and a way to teach them.
The instructor also admitted to struggling in the beginning: "I also struggled like you guys in the beginning. Then I realized, why can't I make a document which can be used for everybody." The point extends beyond the course — the mechanisms learned here can be reused for any other framework later.
15.8.2 Learning by Exploration: The Assignment's Intent
The assignment — running machine learning experiments in PySpark — was designed for exploration, not just evaluation. All the resources are available on the internet, but exploring them and running your own experiment is itself the learning. "If people are not serious about the quality of the assignment, then I cannot help — it is a platform to learn." Marks will be there for the exploration. One month was given so there is enough time to do it leisurely, because after this course nobody will hand over this kind of platform for learning streaming machine learning. "Once you know it, it is very simple. But if you don't know, it will become a bottleneck."
15.8.3 Known Unknowns and Unknown Unknowns
The distinction about finding things out: finding an unknown known is easy — the unknown is unknown to you but known to somebody else, so it can be found. Finding an unknown unknown is different — keep digging. The course design tries to spare students the sleepless nights spent hunting unknown unknowns and brainstorming without direction. The intention: people should feel that they are learning. Giving marks is not a problem — the purpose is learning.
Why the distinction matters for study: the exam topics are all unknown-knowns — the class notes and sample paper are the answer bank. Revision should be searching that bank, not digging for unknown-unknowns that nobody wrote down.
15.8.4 A Five-Credit Course Is About Your Own Time
The course is a five-credit course, and the point about what that means: apart from the lecture classes, how much time you spend on your own is the main intention behind it — that is why it carries heavy weightage. Choose the course because you have an aspiration to learn, but it should not happen at the cost of sleepless nights: be leisurely, do what is needed, without wasting time on brainstorming and finding unknown unknowns.
This session itself was one of the extra special classes — held to discuss the techniques in detail instead of rushing everything at the end, when people get nervous and the last class becomes a panic.
Exam Guidance Summary
Weightage and focus
- Weightage: roughly 30% pre-mid-semester, 70% post-mid-semester.
- Already tested in the mid-sem: message delivery semantics, when to use which architecture, batch vs stream processing differences, message writing mechanisms (direct vs indirect write).
- Post-mid-sem focus: algorithms (Bloom filter, Count-Min Sketch, reservoir sampling, decaying window) and structured streaming (word count problem, timing diagram). Class notes are the reference.
- Pre-mid-sem revision should be shallow: only the basics of generalized/Lambda/Kappa architectures, message delivery semantics, how data enters the system, and batch vs stream vs real-time differences.
The three sample questions
- Three sample questions: (1) Spark Structured Streaming + timing diagram, (2) Count-Min Sketch table construction, (3) Spark transformations and actions lifecycle. Solutions are provided with the sample paper; the number of pages can be ignored.
- Count-Min Sketch convention: hash values can be zero; the question will state whether indices start from zero or from one — apply it consistently.
- Window concepts: refer to the Spark documentation links shared in class.
Format and technique
- Format: open book; mostly numerical problems; no theory or derivation answers even though derivations were taught; conceptual questions sit alongside numericals; balanced overall.
- Answer technique: be specific, not verbose; construct the expected artifact (table, diagram, lifecycle).
- Regular exam preferred over makeup, especially for this course.
Key Industry Applications
- Real-world: Apache Spark Structured Streaming — production stream processing over micro-batches; the timing diagram pattern is how streaming engines actually schedule and emit results.
- Real-world: Apache Kafka path integration with PySpark — streaming data into a processing pipeline; Zookeeper handles coordination. Installation and orchestration are the practical barrier that the course's step-by-step approach removes.
- Real-world: streaming algorithms — Bloom filter (approximate membership, used in databases and caches), Count-Min Sketch (approximate frequency counts, used in network monitoring and analytics engines), reservoir sampling (fixed-size unbiased random sample of an unbounded stream), decaying window (recency-weighted aggregation for dashboards and trending).
- Real-world: running machine learning experiments in PySpark — the assignment pattern: exploration of real frameworks is the intended learning outcome, and the same mechanisms transfer to any other framework later.
- Real-world: windowing in the Spark documentation — time-based aggregation is the standard production pattern for dashboards and alerting.
SPA Lecture 15 notes · Exam Review and Preparation Guidance
Sections Breakdown
The three sample questions that define the exam: the timing diagram, Count-Min Sketch table construction, and the Spark transformations and actions lifecycle.
Roughly 30% pre-mid-semester and 70% post-mid-semester weightage; what the mid-sem already tested and where effort should go, with the dirty-frog study plan.
The course split into architecture (batch, stream, real-time, Lambda, Kappa) and processing with PySpark, plus the four streaming algorithms.
Lazy transformation is nothing but the wide transformation: evaluation delayed until needed, with the kitchen analogy for the Spark lifecycle.
Building the Count-Min Sketch table row by row, the hash-value-zero index convention, and the update and estimate rules with a worked table.
Streaming word count over micro-batches, group by and where clauses, and tumbling versus sliding window concepts tied to the timing diagram.
Exam-day strategy: be specific not verbose, produce the requested artifact, prefer the regular exam, and prepare from class notes and the sample paper.
The teaching philosophy behind the course: packaged steps against orchestration fear, exploration as learning, and known versus unknown unknowns.
Consolidated exam guidance: weightage, the three sample questions, the Count-Min Sketch convention, and format and technique.
Production systems behind the course: Spark Structured Streaming, Kafka path integration, streaming algorithms, and time-windowed aggregation.
Exam Revision Notes
Below is the distilled, exam-ready core. Every entry comes from the full explanation above. Use this section for rapid review; return to the main notes when a point needs more context.
Exam Blueprint: The Three Sample Questions
Must-know: Three sample questions define the exam: (1) Structured Streaming timing diagram, (2) Count-Min Sketch table construction, (3) transformations/actions lifecycle. Open book, more numerical than before, balanced with conceptual questions, problems only.
⚠️ Top pitfall: Writing theory or derivation answers: the exam expects problems only; keep the concepts alongside the calculations but produce artifacts (table, diagram, lifecycle walk-through).
Self-check: What are the four stages of the Spark lifecycle from loading data to job execution?
Connects to: Lazy Evaluation in Spark; The Count-Min Sketch Question in Detail
Where the Weightage Sits: 30% Pre-Mid-Sem, 70% Post-Mid-Sem
Must-know: Weightage is about 30% pre-mid-sem and 70% post-mid-sem; the mid-sem already tested the architecture side (message delivery semantics, when to use which architecture, batch vs stream differences, message writing mechanisms); focus revision on algorithms and structured streaming, architecture basics only.
⚠️ Top pitfall: Over-revising pre-mid-sem architecture topics (Lambda, Kappa, generalized architecture, message delivery semantics) that already appeared in the mid-sem and carry only 30% weight.
Self-check: Roughly what share of the exam comes from post-mid-semester content, and what does 'eat the dirty frog first' mean?
Connects to: The Course at a Glance: Architecture and Processing; Structured Streaming: The Word Count Problem and Window Concepts
The Course at a Glance: Architecture and Processing
Must-know: Architecture side (batch vs stream vs real-time, Lambda/Kappa/generalized, message delivery semantics, long-term storage, message routing) was mostly mid-sem; processing side with PySpark (RDD vs Structured Streaming, clauses, word count, Kafka, streaming algorithms) carries the exam. Four key algorithms: Bloom filter, Count-Min Sketch, reservoir sampling, decaying window.
⚠️ Top pitfall: Deep-revising architecture components that were already tested in the mid-sem; only the basics (batch vs stream vs real-time differences) are needed.
Self-check: Which of the four streaming algorithms answers 'how many times has this item appeared?' and which answers 'have I seen this before?'
Connects to: Where the Weightage Sits: 30% Pre-Mid-Sem, 70% Post-Mid-Sem; The Count-Min Sketch Question in Detail
Lazy Evaluation in Spark
Must-know: Lazy transformation is nothing but the wide transformation: evaluation is delayed until the point where it is needed. Wide transformations (groupByKey, join, distinct) shuffle data across partitions; narrow transformations (map, filter) stay within one partition. Transformations record lineage; actions trigger job execution.
⚠️ Top pitfall: Believing a transformation computes when it is called; nothing runs until an action (count, collect, save) forces evaluation.
Self-check: Why does calling a transformation feel instant while calling an action can be slow?
Connects to: Question 3 — Spark Transformations, Actions, and the Lifecycle
The Count-Min Sketch Question in Detail
Must-know: Build the table row by row: for every item x, add 1 to C[j][h_j(x)] for each row j; estimate frequency as the minimum over rows of C[j][h_j(x)]. Hash values can be zero: the question states whether indices start from zero or one, and the convention must be applied consistently. The sketch never undercounts, only overcounts.
⚠️ Top pitfall: Applying the zero-versus-one index convention inconsistently across rows, which cascades an off-by-one error through the whole table.
Self-check: A stream a, b, a is hashed with h(a)=0, h(b)=1 into two rows of width 4. What is the estimated frequency of a under one-indexed columns?
Connects to: Question 2 — Count-Min Sketch Table Construction; Streaming Algorithms Covered
Structured Streaming: The Word Count Problem and Window Concepts
Must-know: Streaming word count mirrors batch word count but aggregates over micro-batches; group by/where clauses work on the streaming DataFrame like SQL; windowing buckets aggregations over time (tumbling non-overlapping, sliding overlapping); the sample question is the timing diagram as explained in class.
⚠️ Top pitfall: Confusing tumbling and sliding windows: tumbling buckets never overlap; sliding buckets do, so one event can fall in several buckets.
Self-check: Why did the course teach algorithms only after laying the foundation, rather than starting with them?
Connects to: Question 1 — Spark Structured Streaming and the Timing Diagram; Where the Weightage Sits: 30% Pre-Mid-Sem, 70% Post-Mid-Sem
Answer Strategy and Exam-Day Advice
Must-know: Answer exactly what the question asks, in the format it expects; extra prose earns no marks. Prefer the regular exam over makeup for this course. Sample paper and solutions are in the course channel.
⚠️ Top pitfall: Writing verbose explanatory prose around a numerical answer instead of delivering the requested artifact (constructed table, drawn diagram, lifecycle order).
Self-check: Which exam slot did the professor advise for this course, regular or makeup?
Connects to: Exam Blueprint: The Three Sample Questions; Where the Weightage Sits: 30% Pre-Mid-Sem, 70% Post-Mid-Sem
The Approach Behind the Course
Must-know: The course packages installation and orchestration into simple laptop steps so concepts are not blocked by tool fear; the assignment rewards exploration; the exam topics are unknown-knowns already covered in class notes and the sample paper.
⚠️ Top pitfall: Hunting 'unknown unknowns' during revision when every exam topic is an unknown known already present in the class notes or sample paper.
Self-check: What is the difference between an unknown known and an unknown unknown?
Connects to: Where the Weightage Sits: 30% Pre-Mid-Sem, 70% Post-Mid-Sem; Answer Strategy and Exam-Day Advice
Exam Guidance Summary
Must-know: 30% pre-mid-sem, 70% post-mid-sem; three sample questions (timing diagram, Count-Min Sketch table, transformations/actions lifecycle); open book, mostly numerical but balanced, problems only; be specific, not verbose; regular exam over makeup.
⚠️ Top pitfall: Revising pre-mid-sem architecture topics deeply instead of the post-mid-sem algorithms and structured streaming that carry 70% weight.
Self-check: Which two of the three sample questions are streaming-related?
Connects to: Exam Blueprint: The Three Sample Questions; Where the Weightage Sits: 30% Pre-Mid-Sem, 70% Post-Mid-Sem; The Count-Min Sketch Question in Detail; Structured Streaming: The Word Count Problem and Window Concepts; Answer Strategy and Exam-Day Advice
Key Industry Applications
Must-know: Streaming algorithms and windowing are the production patterns behind dashboards, alerting, network monitoring, and analytics engines.
Self-check: Where is the Count-Min Sketch used in industry?
Connects to: The Course at a Glance: Architecture and Processing; The Count-Min Sketch Question in Detail; Structured Streaming: The Word Count Problem and Window Concepts
Was this lecture useful?
BitsNotes AI Assistant
Subject Notes AssistantConfigure AI Chat
Choose how to access the chatbotSigned in as
Powered by BitsNotes — 20 messages per day. No API key needed. Want unlimited access? Use "Bring Your Own Key" mode.
Sign in to use AI Chat
Get 20 free AI messages per day to ask questions about your lecture notes. Sign in with Google or GitHub — it takes 5 seconds.
Sign In to BitsNotesSwitch to "Bring Your Own Key" tab above for unlimited access with any OpenAI-compatible provider.