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.mapred.join;
020    
021    import org.apache.hadoop.classification.InterfaceAudience;
022    import org.apache.hadoop.classification.InterfaceStability;
023    import org.apache.hadoop.io.Writable;
024    
025    /**
026     * Writable type storing multiple {@link org.apache.hadoop.io.Writable}s.
027     *
028     * This is *not* a general-purpose tuple type. In almost all cases, users are
029     * encouraged to implement their own serializable types, which can perform
030     * better validation and provide more efficient encodings than this class is
031     * capable. TupleWritable relies on the join framework for type safety and
032     * assumes its instances will rarely be persisted, assumptions not only
033     * incompatible with, but contrary to the general case.
034     *
035     * @see org.apache.hadoop.io.Writable
036     */
037    @InterfaceAudience.Public
038    @InterfaceStability.Stable
039    public class TupleWritable 
040        extends org.apache.hadoop.mapreduce.lib.join.TupleWritable {
041    
042      /**
043       * Create an empty tuple with no allocated storage for writables.
044       */
045      public TupleWritable() {
046        super();
047      }
048    
049      /**
050       * Initialize tuple with storage; unknown whether any of them contain
051       * "written" values.
052       */
053      public TupleWritable(Writable[] vals) {
054        super(vals);
055      }
056    
057      /**
058       * Record that the tuple contains an element at the position provided.
059       */
060      void setWritten(int i) {
061        written.set(i);
062      }
063    
064      /**
065       * Record that the tuple does not contain an element at the position
066       * provided.
067       */
068      void clearWritten(int i) {
069        written.clear(i);
070      }
071    
072      /**
073       * Clear any record of which writables have been written to, without
074       * releasing storage.
075       */
076      void clearWritten() {
077        written.clear();
078      }
079    
080    
081    }