001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.apache.hadoop.mapred.lib; 020 021import java.io.IOException; 022 023import org.apache.hadoop.classification.InterfaceAudience; 024import org.apache.hadoop.classification.InterfaceStability; 025import org.apache.hadoop.conf.Configuration; 026import org.apache.hadoop.io.LongWritable; 027import org.apache.hadoop.io.Text; 028import org.apache.hadoop.mapred.InputSplit; 029import org.apache.hadoop.mapred.JobConf; 030import org.apache.hadoop.mapred.RecordReader; 031import org.apache.hadoop.mapred.Reporter; 032import org.apache.hadoop.mapred.TextInputFormat; 033 034/** 035 * Input format that is a <code>CombineFileInputFormat</code>-equivalent for 036 * <code>TextInputFormat</code>. 037 * 038 * @see CombineFileInputFormat 039 */ 040@InterfaceAudience.Public 041@InterfaceStability.Stable 042public class CombineTextInputFormat 043 extends CombineFileInputFormat<LongWritable,Text> { 044 @SuppressWarnings({ "rawtypes", "unchecked" }) 045 public RecordReader<LongWritable,Text> getRecordReader(InputSplit split, 046 JobConf conf, Reporter reporter) throws IOException { 047 return new CombineFileRecordReader(conf, (CombineFileSplit)split, reporter, 048 TextRecordReaderWrapper.class); 049 } 050 051 /** 052 * A record reader that may be passed to <code>CombineFileRecordReader</code> 053 * so that it can be used in a <code>CombineFileInputFormat</code>-equivalent 054 * for <code>TextInputFormat</code>. 055 * 056 * @see CombineFileRecordReader 057 * @see CombineFileInputFormat 058 * @see TextInputFormat 059 */ 060 private static class TextRecordReaderWrapper 061 extends CombineFileRecordReaderWrapper<LongWritable,Text> { 062 // this constructor signature is required by CombineFileRecordReader 063 public TextRecordReaderWrapper(CombineFileSplit split, Configuration conf, 064 Reporter reporter, Integer idx) throws IOException { 065 super(new TextInputFormat(), split, conf, reporter, idx); 066 } 067 } 068}