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 */
018package org.apache.hadoop.hbase.regionserver;
019
020import java.io.IOException;
021import java.util.Optional;
022import java.util.OptionalLong;
023
024import org.apache.hadoop.fs.Path;
025import org.apache.hadoop.hbase.Cell;
026import org.apache.hadoop.hbase.CellComparator;
027import org.apache.hadoop.hbase.HBaseInterfaceAudience;
028import org.apache.yetus.audience.InterfaceAudience;
029import org.apache.yetus.audience.InterfaceStability;
030
031/**
032 * An interface to describe a store data file.
033 * <p>
034 * <strong>NOTICE: </strong>this interface is mainly designed for coprocessor, so it will not expose
035 * all the internal APIs for a 'store file'. If you are implementing something inside HBase, i.e,
036 * not a coprocessor hook, usually you should use {@link HStoreFile} directly as it is the only
037 * implementation of this interface.
038 */
039@InterfaceAudience.LimitedPrivate(HBaseInterfaceAudience.COPROC)
040@InterfaceStability.Evolving
041public interface StoreFile {
042
043  /**
044   * Get the first key in this store file.
045   */
046  Optional<Cell> getFirstKey();
047
048  /**
049   * Get the last key in this store file.
050   */
051  Optional<Cell> getLastKey();
052
053  /**
054   * Get the comparator for comparing two cells.
055   */
056  CellComparator getComparator();
057
058  /**
059   * Get max of the MemstoreTS in the KV's in this store file.
060   */
061  long getMaxMemStoreTS();
062
063  /**
064   * @return Path or null if this StoreFile was made with a Stream.
065   */
066  Path getPath();
067
068  /**
069   * @return Encoded Path if this StoreFile was made with a Stream.
070   */
071  Path getEncodedPath();
072
073  /**
074   * @return Returns the qualified path of this StoreFile
075   */
076  Path getQualifiedPath();
077
078  /**
079   * @return True if this is a StoreFile Reference.
080   */
081  boolean isReference();
082
083  /**
084   * @return True if this is HFile.
085   */
086  boolean isHFile();
087
088  /**
089   * @return True if this file was made by a major compaction.
090   */
091  boolean isMajorCompactionResult();
092
093  /**
094   * @return True if this file should not be part of a minor compaction.
095   */
096  boolean excludeFromMinorCompaction();
097
098  /**
099   * @return This files maximum edit sequence id.
100   */
101  long getMaxSequenceId();
102
103  /**
104   * Get the modification time of this store file. Usually will access the file system so throws
105   * IOException.
106   * @deprecated Since 2.0.0. Will be removed in 3.0.0.
107   * @see #getModificationTimestamp()
108   */
109  @Deprecated
110  long getModificationTimeStamp() throws IOException;
111
112  /**
113   * Get the modification time of this store file. Usually will access the file system so throws
114   * IOException.
115   */
116  long getModificationTimestamp() throws IOException;
117
118  /**
119   * Check if this storefile was created by bulk load. When a hfile is bulk loaded into HBase, we
120   * append {@code '_SeqId_<id-when-loaded>'} to the hfile name, unless
121   * "hbase.mapreduce.bulkload.assign.sequenceNumbers" is explicitly turned off. If
122   * "hbase.mapreduce.bulkload.assign.sequenceNumbers" is turned off, fall back to
123   * BULKLOAD_TIME_KEY.
124   * @return true if this storefile was created by bulk load.
125   */
126  boolean isBulkLoadResult();
127
128  /**
129   * Return the timestamp at which this bulk load file was generated.
130   */
131  OptionalLong getBulkLoadTimestamp();
132
133  /**
134   * @return a length description of this StoreFile, suitable for debug output
135   */
136  String toStringDetailed();
137
138  /**
139   * Get the min timestamp of all the cells in the store file.
140   */
141  OptionalLong getMinimumTimestamp();
142
143  /**
144   * Get the max timestamp of all the cells in the store file.
145   */
146  OptionalLong getMaximumTimestamp();
147}