// Path: kiji-mapreduce/src/main/java/org/kiji/mapreduce/gather/GathererContext.java
// @ApiAudience.Public
// @ApiStability.Stable
// @Inheritance.Sealed
// public interface GathererContext<K, V> extends KijiContext {
//   /**
//    * Emits a key/value pair.
//    *
//    * @param key Emit this key.
//    * @param value Emit this value.
//    * @throws IOException on I/O error.
//    */
//   void write(K key, V value) throws IOException;
// }


import org.kiji.mapreduce.avro.AvroValueWriter;
import org.kiji.mapreduce.framework.JobHistoryCounters;
import org.kiji.mapreduce.framework.KijiConfKeys;
import org.kiji.mapreduce.gather.GathererContext;
import org.kiji.mapreduce.gather.KijiGatherer;
import org.kiji.mapreduce.impl.KijiTableMapper;
import org.kiji.schema.KijiDataRequest;
import org.kiji.schema.KijiRowData;
import java.io.IOException;
import com.google.common.base.Preconditions;
import org.apache.avro.Schema;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.ReflectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.kiji.annotations.ApiAudience;
import org.kiji.mapreduce.avro.AvroKeyWriter;
/**
 * (c) Copyright 2012 WibiData, Inc.
 *
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * Licensed 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.kiji.mapreduce.gather.impl;




/**
 * Mapper that executes a gatherer over the rows of a Kiji table.
 *
 * @param <K> The type of the MapReduce output key.
 * @param <V> The type of the MapReduce output value.
 */
@ApiAudience.Private
public final class GatherMapper<K, V>
    extends KijiTableMapper<K, V>
    implements AvroKeyWriter, AvroValueWriter {

  private static final Logger LOG = LoggerFactory.getLogger(GatherMapper.class);

  /** The gatherer to execute. */
  private KijiGatherer<K, V> mGatherer;

  /**
   * The context object that allows the gatherer to interact with MapReduce,
   * KVStores, etc.
   */
// Path: kiji-mapreduce/src/main/java/org/kiji/mapreduce/gather/GathererContext.java
// @ApiAudience.Public
// @ApiStability.Stable
// @Inheritance.Sealed
// public interface GathererContext<K, V> extends KijiContext {
//   /**
//    * Emits a key/value pair.
//    *
//    * @param key Emit this key.
//    * @param value Emit this value.
//    * @throws IOException on I/O error.
//    */
//   void write(K key, V value) throws IOException;
// }


// Path: kiji-mapreduce/src/main/java/org/kiji/mapreduce/gather/impl/GatherMapper.java
import org.kiji.mapreduce.avro.AvroValueWriter;
import org.kiji.mapreduce.framework.JobHistoryCounters;
import org.kiji.mapreduce.framework.KijiConfKeys;
import org.kiji.mapreduce.gather.GathererContext;
import org.kiji.mapreduce.gather.KijiGatherer;
import org.kiji.mapreduce.impl.KijiTableMapper;
import org.kiji.schema.KijiDataRequest;
import org.kiji.schema.KijiRowData;
import java.io.IOException;
import com.google.common.base.Preconditions;
import org.apache.avro.Schema;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.util.ReflectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.kiji.annotations.ApiAudience;
import org.kiji.mapreduce.avro.AvroKeyWriter;

/**
 * (c) Copyright 2012 WibiData, Inc.
 *
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * Licensed 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.kiji.mapreduce.gather.impl;




/**
 * Mapper that executes a gatherer over the rows of a Kiji table.
 *
 * @param <K> The type of the MapReduce output key.
 * @param <V> The type of the MapReduce output value.
 */
@ApiAudience.Private
public final class GatherMapper<K, V>
    extends KijiTableMapper<K, V>
    implements AvroKeyWriter, AvroValueWriter {

  private static final Logger LOG = LoggerFactory.getLogger(GatherMapper.class);

  /** The gatherer to execute. */
  private KijiGatherer<K, V> mGatherer;

  /**
   * The context object that allows the gatherer to interact with MapReduce,
   * KVStores, etc.
   */
  private GathererContext<K, V> mGathererContext;