HADOOP-6842. "hadoop fs -text" does not give a useful text representation of MapWritable objects

(cherry picked from commit cc17c83585)
This commit is contained in:
Robert (Bobby) Evans 2015-05-08 11:56:59 -05:00
parent d4d7d7bf22
commit eef8d70bb0
3 changed files with 18 additions and 1 deletions

View File

@ -19,6 +19,9 @@ Release 2.8.0 - UNRELEASED
IMPROVEMENTS IMPROVEMENTS
HADOOP-6842. "hadoop fs -text" does not give a useful text representation
of MapWritable objects (Akira Ajisaka via bobby)
HADOOP-11719. [Fsshell] Remove bin/hadoop reference from HADOOP-11719. [Fsshell] Remove bin/hadoop reference from
GenericOptionsParser default help text. GenericOptionsParser default help text.

View File

@ -189,4 +189,9 @@ public class MapWritable extends AbstractMapWritable
instance.put(key, value); instance.put(key, value);
} }
} }
@Override
public String toString() {
return instance.toString();
}
} }

View File

@ -148,5 +148,14 @@ public class TestMapWritable extends TestCase {
assertEquals(map1.hashCode(), map2.hashCode()); assertEquals(map1.hashCode(), map2.hashCode());
assertFalse(map1.hashCode() == map3.hashCode()); assertFalse(map1.hashCode() == map3.hashCode());
} }
/** Verify text command outputs a useful representation for MapWritable. */
public void testToString() {
MapWritable map = new MapWritable();
final IntWritable key = new IntWritable(5);
final Text value = new Text("value");
map.put(key, value);
assertEquals("{5=value}", map.toString());
}
} }