Bird
0
0

Find the mistake in this code snippet for merging small files into a SequenceFile:

medium📝 Debug Q7 of 15
Hadoop - Performance Tuning
Find the mistake in this code snippet for merging small files into a SequenceFile:
SequenceFile.Writer writer = SequenceFile.createWriter(conf, path, keyClass, valueClass);
for (File file : files) {
  writer.append(file.getName(), file);
}
writer.close();
AFile object cannot be used directly as value in append method
BWriter should not be closed after appending files
CFile names cannot be keys in SequenceFile
DNo mistake, code is correct
Step-by-Step Solution
Solution:
  1. Step 1: Understand SequenceFile append method parameters

    append expects Writable key and Writable value objects, not File objects.
  2. Step 2: Identify why File object is incorrect

    File is not Writable; file content should be read and converted to Writable type.
  3. Final Answer:

    File object cannot be used directly as value in append method -> Option A
  4. Quick Check:

    File must be converted to Writable before append [OK]
Quick Trick: Convert file content to Writable before append [OK]
Common Mistakes:
  • Closing writer too early is not an error here
  • Thinking file name cannot be key
  • Assuming code is correct as is

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Hadoop Quizzes