0
0
Hadoopdata~10 mins

Row key design strategies in Hadoop - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a row key by concatenating user ID and timestamp.

Hadoop
row_key = user_id + [1] + timestamp
Drag options to blanks, or click blank then click option'
A_
B:
C-
D+
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' can cause confusion with arithmetic operations.
Using '-' might be confused with negative numbers.
2fill in blank
medium

Complete the code to reverse the timestamp string for better row key distribution.

Hadoop
reversed_ts = timestamp[::[1]1]
Drag options to blanks, or click blank then click option'
A{
B[
C(
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using brackets without proper slice causes syntax error.
Using parentheses or braces is invalid for slicing.
3fill in blank
hard

Fix the error in the code to create a salted row key for load balancing.

Hadoop
salt = str(hash(user_id) [1] 10)
salted_key = salt + '_' + user_id + '_' + timestamp
Drag options to blanks, or click blank then click option'
A+
B%
C**
D//
Attempts:
3 left
💡 Hint
Common Mistakes
Using '//' causes integer division but not remainder.
Using '+' or '**' causes type errors.
4fill in blank
hard

Fill both blanks to create a set comprehension that combines user IDs with reversed timestamps to form row keys.

Hadoop
row_keys = {user_id[1] '_' + timestamp[::[2]1] for user_id, timestamp in data.items()}
Drag options to blanks, or click blank then click option'
A+
B.
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' or '*' for string concatenation causes errors.
Omitting the step in slicing causes incorrect reversal.
5fill in blank
hard

Fill all three blanks to create a filtered set of row keys where timestamp is greater than a threshold.

Hadoop
filtered_keys = {user_id[1] timestamp for user_id, timestamp in data.items() if timestamp [2] threshold and user_id[3] 'active'}
Drag options to blanks, or click blank then click option'
A+
B>
C==
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' for string concatenation causes errors.
Using '=' instead of '==' in condition causes syntax errors.