Core Transformations⏱️ ~8 mins
3. String Length Extractor
Enterprise Architecture Context
In production stream-processing architectures (Google Cloud Dataflow / Flink), pipeline stages must handle parallel transformations without data loss, managing schema mutations and aggregations across distributed worker workers.
Problem Statement
### Business Context
Natural Language Processing (NLP) tokenizers extract token length characteristics to evaluate token entropy and model embeddings.
### Problem Statement
Write a function `get_word_lengths(input_pcoll)` that maps each incoming string word to its integer character count.
Key Learning Objectives
- Understand distributed Apache Beam execution DAG stages and pipeline lifecycle.
- Apply idiomatic functional Python transforms using the pipe operator
|. - Ensure data consistency and idempotency across distributed stream workers.
Sample Data Fixtures
Sample Example 1
Input Stream:
['beam', 'dataflow']
Expected Output:
[4, 8]
Sample Example 2
Input Stream:
['apache', 'spark', 'flink']
Expected Output:
[5, 5, 6]
Topics:#Map#Strings
solution.pyPython 3.11 (Apache Beam)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Input PCollection2 elements
| # | Element / Payload |
|---|---|
| 1 | "beam" |
| 2 | "dataflow" |
Expected Output PCollection2 elements
| # | Output Element |
|---|---|
| 1 | 4 |
| 2 | 8 |
Core Transformations⏱️ ~8 mins
3. String Length Extractor
Enterprise Architecture Context
In production stream-processing architectures (Google Cloud Dataflow / Flink), pipeline stages must handle parallel transformations without data loss, managing schema mutations and aggregations across distributed worker workers.
Problem Statement
### Business Context
Natural Language Processing (NLP) tokenizers extract token length characteristics to evaluate token entropy and model embeddings.
### Problem Statement
Write a function `get_word_lengths(input_pcoll)` that maps each incoming string word to its integer character count.
Key Learning Objectives
- Understand distributed Apache Beam execution DAG stages and pipeline lifecycle.
- Apply idiomatic functional Python transforms using the pipe operator
|. - Ensure data consistency and idempotency across distributed stream workers.
Sample Data Fixtures
Sample Example 1
Input Stream:
['beam', 'dataflow']
Expected Output:
[4, 8]
Sample Example 2
Input Stream:
['apache', 'spark', 'flink']
Expected Output:
[5, 5, 6]
Topics:#Map#Strings