Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Hadoop(1.1.2)XML处理和重写文件_Java_Xml_Apache_Hadoop_Mapreduce - Fatal编程技术网

Java Hadoop(1.1.2)XML处理和重写文件

Java Hadoop(1.1.2)XML处理和重写文件,java,xml,apache,hadoop,mapreduce,Java,Xml,Apache,Hadoop,Mapreduce,这里的第一个问题。。。学习hadoop 在过去的两周里,我一直试图了解hadoop的一切,但似乎每座山背后都有一座山 以下是设置: 我认为一个简单的解决方案是使用TextOutputFormat,然后使用Text作为输出键,使用NullWritable作为输出值 TextOutputFormat使用分隔符分隔作业中输出的键和值对。对于您的需求,您不需要这种安排,但您只想输出一个XML体。如果将null或NullWritable作为输出键或值传递,TextOutputFormat将不会写入null

这里的第一个问题。。。学习hadoop

在过去的两周里,我一直试图了解hadoop的一切,但似乎每座山背后都有一座山

以下是设置:


我认为一个简单的解决方案是使用TextOutputFormat,然后使用Text作为输出键,使用NullWritable作为输出值

TextOutputFormat使用分隔符分隔作业中输出的键和值对。对于您的需求,您不需要这种安排,但您只想输出一个XML体。如果将null或NullWritable作为输出键或值传递,TextOutputFormat将不会写入null或分隔符,而只写入非null键或值

使用XmlINputFormat的另一种方法是使用完整的FileInput,如Tom White的Hadoop(最终指南)中所述

因此,您需要编写映射程序,使用XML SAX或DOM解析器使用输入值文本对象,然后将转换后的XML作为文本对象输出

public static void main(String[] args) {
    JobConf conf = new JobConf(myDriver.class);
    conf.setJobName("bigjob");
    // Input/Output Directories
    if (args[0].length()==0 || args[1].length()==0) System.exit(-1);
    FileInputFormat.setInputPaths(conf, new Path(args[0]));
    FileOutputFormat.setOutputPath(conf, new Path(args[1]));

    conf.set("xmlinput.start", "<document>");
    conf.set("xmlinput.end", "</document>");

    // Mapper & Combiner & Reducer
    conf.setMapperClass(Mapper.class);
    conf.setReducerClass(Reduce.class);
    conf.setNumReduceTasks(0);

    // Input/Output Types
    conf.setInputFormat(XmlInputFormat.class);

    conf.setOutputFormat(?????);

    conf.setOutputKeyClass(????);
    conf.setOutputValueClass(????);


    try {
            JobClient.runJob(conf);
    } catch (Exception e) {
            e.printStackTrace();
    }
}