What are the advantages of using NullWritable
for null
keys/values over using null
texts (i.e. new Text(null)
). I see the fol
You can always wrap your string in your own Writable class and have a boolean indicating it has blank strings or not:
@Override
public void readFields(DataInput in) throws IOException {
...
boolean hasWord = in.readBoolean();
if( hasWord ) {
word = in.readUTF();
}
...
}
and
@Override
public void write(DataOutput out) throws IOException {
...
boolean hasWord = StringUtils.isNotBlank(word);
out.writeBoolean(hasWord);
if(hasWord) {
out.writeUTF(word);
}
...
}