0
0
Hadoopdata~10 mins

Block storage and replication 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 specify the default replication factor in Hadoop configuration.

Hadoop
conf.set("dfs.replication", [1])
Drag options to blanks, or click blank then click option'
A"1"
B"5"
C"3"
D"0"
Attempts:
3 left
💡 Hint
Common Mistakes
Setting replication factor to 0 disables replication, which is not recommended.
Using replication factor 1 means no copies, risking data loss.
2fill in blank
medium

Complete the code to get the block size from Hadoop configuration.

Hadoop
long blockSize = conf.getLong("dfs.blocksize", [1]);
Drag options to blanks, or click blank then click option'
A67108864
B262144
C33554432
D134217728
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing block size with replication factor.
Using too small or too large block sizes without reason.
3fill in blank
hard

Fix the error in the code to correctly retrieve the replication factor as an integer.

Hadoop
int replication = conf.getInt("dfs.replication", [1]);
Drag options to blanks, or click blank then click option'
A3
B"3"
Cnull
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string instead of an integer causes a type error.
Using null as default causes runtime exceptions.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps block IDs to their replication counts, filtering blocks with replication less than 3.

Hadoop
block_replications = {block_id: replication for block_id, replication in blocks.items() if replication [1] [2]
Drag options to blanks, or click blank then click option'
A>=
B<
C3
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using >= instead of < changes the filter logic.
Using wrong threshold number.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps block IDs to their sizes for blocks with size greater than 128 MB.

Hadoop
large_blocks = { [1] : [2] for [3] in blocks.items() if size > 134217728 }
Drag options to blanks, or click blank then click option'
Ablock_id
Bsize
C(block_id, size)
Dblock
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names causing errors.
Not unpacking the tuple correctly.