hadoop-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bertrand Dechoux <decho...@gmail.com>
Subject Re: Mapper outputs an empty file
Date Fri, 30 Nov 2012 13:06:19 GMT
You should write unit tests (MRUnit) and do debugging if that's not enough.
I would assume that you are a reading your file line by line. And each line
is not a valid xml, thus an exception is thrown and then caught but without
any logs or counters.

Regards

Bertrand

On Fri, Nov 30, 2012 at 1:21 PM, dyuti a <hadoop.hive04@gmail.com> wrote:

> Hi All,
> Am trying with xml processing in hadoop,used the below code inside map
> method. It results an empty file (not used reducer class).is there anything
>  wrong ?
>
> //code used inside map method
> public void map(LongWritable key, Text value1,Context context)
> throws IOException, InterruptedException {
>         String xmlString = value1.toString();
> SAXBuilder builder = new SAXBuilder();
>  Reader in = new StringReader(xmlString);
> String value="";
> try {
>                         Document doc = builder.build(in);
>  Element rootNode = doc.getRootElement();
>                         List<Element> list = rootNode.getChildren("staff");
>             for (int i = 0; i < list.size(); i++) {
>  Element node = (Element) list.get(i);
>               String tag1 = node.getChildText("firstname");
>                                 String tag2 =
> node.getChildText("lastname");
>                          String tag3 = node.getChildText("nickname");
>                    String tag4 = node.getChildText("salary");
>
> value = tag1 + "," + tag2 + "," + tag3 + "," + tag4;
>  context.write(NullWritable.get(), new Text(value));
>  }
> } followed by catch statements....................
>
> //xml input file
> <?xml version="1.0" encoding="UTF-8"?>
> <company>
>  <staff>
> <firstname>yong</firstname>
>  <lastname>mook kim</lastname>
> <nickname>mkyong</nickname>
>  <salary>100000</salary>
> </staff>
>  <staff>
> <firstname>low121</firstname>
>  <lastname>yin fong1</lastname>
> <nickname>fong fong1</nickname>
>  <salary>2000001</salary>
> </staff>
> </company>
>
> Thanks for your help!
>
> Regards,
> dti
>
>


-- 
Bertrand Dechoux

Mime
View raw message