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

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

Introduction

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

Prototype

public void configure(JobConf conf) 

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);/*  w  w  w .  j  a  v  a2s.  c o m*/

        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.");
    }