Viky Leaf
Viky Leaf

Reputation: 195

Why can't output value of hadoop map be null?

I just want to use hadoop mapreduce to sort my lines of log. I put all fields of the line as the output key, and set output value as null. But when run, null pointer exception is raised at line

context.write(new Text(outkeystr), null);

So why can't output value of hadoop map be null? Why output value of hadoop reduce can (I tested)?

Upvotes: 0

Views: 2071

Answers (2)

mikk3l
mikk3l

Reputation: 75

You cannot output a null value. You can output a null key though:

context.write(null, new Text(outkeystr));

Upvotes: 0

FuriousGeorge
FuriousGeorge

Reputation: 4681

You can't use the explict value null but you can use a NullWritable class if you don't care about the Value

Upvotes: 2

Related Questions