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    package org.apache.hadoop.io.compress;
019    
020    import java.io.IOException;
021    import java.io.InputStream;
022    
023    import org.apache.hadoop.classification.InterfaceAudience;
024    import org.apache.hadoop.classification.InterfaceStability;
025    
026    /**
027     * An InputStream covering a range of compressed data. The start and end
028     * offsets requested by a client may be modified by the codec to fit block
029     * boundaries or other algorithm-dependent requirements.
030     */
031    @InterfaceAudience.Public
032    @InterfaceStability.Evolving
033    public abstract class SplitCompressionInputStream
034        extends CompressionInputStream {
035    
036      private long start;
037      private long end;
038    
039      public SplitCompressionInputStream(InputStream in, long start, long end)
040          throws IOException {
041        super(in);
042        this.start = start;
043        this.end = end;
044      }
045    
046      protected void setStart(long start) {
047        this.start = start;
048      }
049    
050      protected void setEnd(long end) {
051        this.end = end;
052      }
053    
054      /**
055       * After calling createInputStream, the values of start or end
056       * might change.  So this method can be used to get the new value of start.
057       * @return The changed value of start
058       */
059      public long getAdjustedStart() {
060        return start;
061      }
062    
063      /**
064       * After calling createInputStream, the values of start or end
065       * might change.  So this method can be used to get the new value of end.
066       * @return The changed value of end
067       */
068      public long getAdjustedEnd() {
069        return end;
070      }
071    }