Package com.btaz.util.mr

Examples of com.btaz.util.mr.FileOutputCollector


        if(prefix == null) {
            prefix = "map";
        }

        // setup output collector
        FileOutputCollector collector = new FileOutputCollector(workDir, prefix);

        // map all data
        try {
            for(File file : inputFiles) {
                FileInputStream inputStream;

                try {
                    inputStream = new FileInputStream(file);
                    BufferedReader br = new BufferedReader(new InputStreamReader(inputStream,
                            DataUtilDefaults.charSet));

                    // map data
                    String row;
                    while((row = br.readLine()) != null) {
                        mapper.map(row, collector);
                    }

                    inputStream.close();
                } catch (IOException e) {
                    throw new DataUtilException(e);
                } catch (MapReduceException e) {
                    throw new DataUtilException("Irrecoverable map operation", e);
                }
            }
        } finally {
            collector.close();
        }

        // return output files
        return collector.getFiles();
    }
View Full Code Here

TOP

Related Classes of com.btaz.util.mr.FileOutputCollector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.