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