    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
    019    package org.apache.hadoop.mapreduce;
    020
    021    import java.io.IOException;
    022
    023    import org.apache.hadoop.classification.InterfaceAudience;
    024    import org.apache.hadoop.classification.InterfaceStability;
    025
    026    /**
    027     * A context object that allows input and output from the task. It is only
    028     * supplied to the {@link Mapper} or {@link Reducer}.
    029     * @param <KEYIN> the input key type for the task
    030     * @param <VALUEIN> the input value type for the task
    031     * @param <KEYOUT> the output key type for the task
    032     * @param <VALUEOUT> the output value type for the task
    033     */
    034    @InterfaceAudience.Public
    035    @InterfaceStability.Evolving
    036    public interface TaskInputOutputContext<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
    037           extends TaskAttemptContext {
    038
    039      /**
    040       * Advance to the next key, value pair, returning null if at end.
    041       * @return the key object that was read into, or null if no more
    042       */
    043      public boolean nextKeyValue() throws IOException, InterruptedException;
    044
    045      /**
    046       * Get the current key.
    047       * @return the current key object or null if there isn't one
    048       * @throws IOException
    049       * @throws InterruptedException
    050       */
    051      public KEYIN getCurrentKey() throws IOException, InterruptedException;
    052
    053      /**
    054       * Get the current value.
    055       * @return the value object that was read into
    056       * @throws IOException
    057       * @throws InterruptedException
    058       */
    059      public VALUEIN getCurrentValue() throws IOException, InterruptedException;
    060
    061      /**
    062       * Generate an output key/value pair.
    063       */
    064      public void write(KEYOUT key, VALUEOUT value)
    065          throws IOException, InterruptedException;
    066
    067      /**
    068       * Get the {@link OutputCommitter} for the task-attempt.
    069       * @return the <code>OutputCommitter</code> for the task-attempt
    070       */
    071      public OutputCommitter getOutputCommitter();
    072    }