All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.hadoop.hive.ql.io.esriJson.UnenclosedEsriJsonInputFormat Maven / Gradle / Ivy

There is a newer version: 4.0.0
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.hadoop.hive.ql.io.esriJson;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import java.io.IOException;

// MRv2 by inheritance; MRv1 by composition/hybrid
public class UnenclosedEsriJsonInputFormat extends FileInputFormat
    implements org.apache.hadoop.mapred.InputFormat {

  // Mrv1 implementation member will be used only for getSplits().
  // Will be instantiated only when Mrv1 in use.
  private org.apache.hadoop.mapred.FileInputFormat baseIfmt = null;

  @Override
  public RecordReader createRecordReader(InputSplit arg0, TaskAttemptContext arg1)
      throws IOException, InterruptedException {  // MRv2
    return new UnenclosedEsriJsonRecordReader();
  }

  @Override
  public org.apache.hadoop.mapred.RecordReader getRecordReader(  // MRv1
      org.apache.hadoop.mapred.InputSplit arg0, org.apache.hadoop.mapred.JobConf arg1,
      org.apache.hadoop.mapred.Reporter arg2) throws IOException {
    return new UnenclosedEsriJsonRecordReader(arg0, arg1);
  }

  @Override
  public org.apache.hadoop.mapred.InputSplit[] getSplits(  // MRv1
      org.apache.hadoop.mapred.JobConf arg0, int arg1) throws IOException {
    baseIfmt = (baseIfmt != null) ? baseIfmt : new org.apache.hadoop.mapred.FileInputFormat() {
      // Dummy method to satisfy interface but not meant to be called
      public org.apache.hadoop.mapred.RecordReader getRecordReader(
          org.apache.hadoop.mapred.InputSplit ign0, org.apache.hadoop.mapred.JobConf ign1,
          org.apache.hadoop.mapred.Reporter ign2) throws IOException {
        throw new UnsupportedOperationException("not meant to be called");
      }
    };
    return baseIfmt.getSplits(arg0, arg1);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy