Example usage for org.apache.hadoop.mapred KeyValueTextInputFormat KeyValueTextInputFormat

List of usage examples for org.apache.hadoop.mapred KeyValueTextInputFormat KeyValueTextInputFormat

Introduction

In this page you can find the example usage for org.apache.hadoop.mapred KeyValueTextInputFormat KeyValueTextInputFormat.

Prototype

KeyValueTextInputFormat

Source Link

Usage

From source file:crunch.MaxTemperature.java

License:Apache License

@Test
    public void keyValue() throws Exception {
        String input = "line1\tOn the top of the Crumpetty Tree\n" + "line2\tThe Quangle Wangle sat,\n"
                + "line3\tBut his face you could not see,\n" + "line4\tOn account of his Beaver Hat.";

        writeInput(input);//ww  w. ja  va2s.com

        KeyValueTextInputFormat format = new KeyValueTextInputFormat();
        format.configure(conf);
        InputSplit[] splits = format.getSplits(conf, 1);
        RecordReader<Text, Text> recordReader = format.getRecordReader(splits[0], conf, Reporter.NULL);
        checkNextLine(recordReader, "line1", "On the top of the Crumpetty Tree");
        checkNextLine(recordReader, "line2", "The Quangle Wangle sat,");
        checkNextLine(recordReader, "line3", "But his face you could not see,");
        checkNextLine(recordReader, "line4", "On account of his Beaver Hat.");
    }