001/**
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *     http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019package org.apache.hadoop.hbase.mapred;
020
021import java.io.IOException;
022
023import org.apache.yetus.audience.InterfaceAudience;
024import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
025import org.apache.hadoop.hbase.client.Result;
026import org.apache.hadoop.mapred.JobConf;
027import org.apache.hadoop.mapred.MapReduceBase;
028import org.apache.hadoop.mapred.OutputCollector;
029import org.apache.hadoop.mapred.Reporter;
030
031/**
032 * Pass the given key and record as-is to reduce
033 */
034@InterfaceAudience.Public
035public class IdentityTableMap
036extends MapReduceBase
037implements TableMap<ImmutableBytesWritable, Result> {
038
039  /** constructor */
040  public IdentityTableMap() {
041    super();
042  }
043
044  /**
045   * Use this before submitting a TableMap job. It will
046   * appropriately set up the JobConf.
047   *
048   * @param table table name
049   * @param columns columns to scan
050   * @param mapper mapper class
051   * @param job job configuration
052   */
053  @SuppressWarnings("unchecked")
054  public static void initJob(String table, String columns,
055    Class<? extends TableMap> mapper, JobConf job) {
056    TableMapReduceUtil.initTableMapJob(table, columns, mapper,
057      ImmutableBytesWritable.class,
058      Result.class, job);
059  }
060
061  /**
062   * Pass the key, value to reduce
063   * @param key
064   * @param value
065   * @param output
066   * @param reporter
067   * @throws IOException
068   */
069  public void map(ImmutableBytesWritable key, Result value,
070      OutputCollector<ImmutableBytesWritable,Result> output,
071      Reporter reporter) throws IOException {
072
073    // convert
074    output.collect(key, value);
075  }
076}